* [dpdk-dev] [PATCH v1 00/16] Flow API overhaul for switch offloads @ 2018-04-04 15:56 Adrien Mazarguil 2018-04-04 15:56 ` [dpdk-dev] [PATCH v1 01/16] ethdev: update ABI for flow API functions Adrien Mazarguil ` (16 more replies) 0 siblings, 17 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-04 15:56 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev As summarized in a prior RFC [1], the flow API (rte_flow) was chosen as a means to manage switch offloads supported by many devices (usually going by names such as E-Switch or vSwitch) through user-specified flow rules. Combined with the need to support encap/decap actions, this requires a change in the way flow actions are processed (in order and possibly repeated) which modifies the behavior of some of the existing actions, thus warranting a major ABI breakage. Given this ABI breakage is also required by other work submitted for the current release [2][3], this series addresses various longstanding issues with the flow API and makes minor improvements in preparation for upcoming features. Changes summary: - Additional error types. - Clearer documentation. - Improved C++ compatibility. - Exhaustive RSS action. - Consistent behavior of VLAN pattern item. - New "transfer" attribute bringing consistency to VF/PF pattern items. - Confusing "PORT" pattern item renamed "PHY_PORT", with new action counterpart. - New "PORT_ID" pattern item and action to be used with port representors. This series piggybacks on the major ABI update introduced by a prior commit [4] for DPDK 18.05 and depends on several fixes [5] which must be applied first. [1] "[RFC] Switch device offload with DPDK" http://dpdk.org/ml/archives/dev/2018-March/092513.html [2] commit 676b605182a5 ("doc: announce ethdev API change for RSS configuration") [3] "[PATCH v1 00/21] MLX5 tunnel Rx offloading" http://dpdk.org/ml/archives/dev/2018-March/092264.html [4] commit 653e038efc9b ("ethdev: remove versioning of filter control function") [5] "[PATCH v2 00/13] Bunch of flow API-related fixes" http://dpdk.org/ml/archives/dev/2018-April/095273.html Adrien Mazarguil (16): ethdev: update ABI for flow API functions ethdev: add error types to flow API ethdev: clarify flow API pattern items and actions doc: remove flow API migration section ethdev: remove DUP action from flow API ethdev: alter behavior of flow API actions ethdev: remove C99 flexible arrays from flow API ethdev: flatten RSS configuration in flow API ethdev: add hash function to RSS flow API action ethdev: add encap level to RSS flow API action ethdev: refine TPID handling in flow API ethdev: add transfer attribute to flow API ethdev: update behavior of VF/PF in flow API ethdev: rename physical port item in flow API ethdev: add physical port action to flow API ethdev: add port ID item and action to flow API app/test-pmd/cmdline_flow.c | 405 ++++++++++----- app/test-pmd/config.c | 78 +-- doc/guides/nics/tap.rst | 2 +- doc/guides/prog_guide/rte_flow.rst | 601 ++++++++--------------- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 54 +- drivers/net/bnxt/bnxt_filter.c | 52 +- drivers/net/e1000/e1000_ethdev.h | 13 +- drivers/net/e1000/igb_ethdev.c | 4 +- drivers/net/e1000/igb_flow.c | 83 +++- drivers/net/e1000/igb_rxtx.c | 55 ++- drivers/net/enic/enic_flow.c | 52 +- drivers/net/i40e/i40e_ethdev.c | 57 ++- drivers/net/i40e/i40e_ethdev.h | 15 +- drivers/net/i40e/i40e_flow.c | 144 ++++-- drivers/net/ixgbe/ixgbe_ethdev.c | 4 +- drivers/net/ixgbe/ixgbe_ethdev.h | 13 +- drivers/net/ixgbe/ixgbe_flow.c | 91 +++- drivers/net/ixgbe/ixgbe_rxtx.c | 55 ++- drivers/net/mlx4/mlx4.c | 2 +- drivers/net/mlx4/mlx4_flow.c | 117 +++-- drivers/net/mlx4/mlx4_flow.h | 2 +- drivers/net/mlx4/mlx4_rxq.c | 2 +- drivers/net/mlx4/mlx4_rxtx.h | 2 +- drivers/net/mlx5/mlx5_flow.c | 317 ++++++------ drivers/net/mlx5/mlx5_rxq.c | 22 +- drivers/net/mlx5/mlx5_rxtx.h | 26 +- drivers/net/mvpp2/mrvl_flow.c | 33 +- drivers/net/sfc/sfc_flow.c | 82 +++- drivers/net/tap/tap_flow.c | 51 +- examples/ipsec-secgw/ipsec.c | 21 +- lib/librte_ether/rte_ethdev_version.map | 10 + lib/librte_ether/rte_flow.c | 68 +-- lib/librte_ether/rte_flow.h | 328 ++++++++----- 33 files changed, 1747 insertions(+), 1114 deletions(-) -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v1 01/16] ethdev: update ABI for flow API functions 2018-04-04 15:56 [dpdk-dev] [PATCH v1 00/16] Flow API overhaul for switch offloads Adrien Mazarguil @ 2018-04-04 15:56 ` Adrien Mazarguil 2018-04-05 10:06 ` Thomas Monjalon 2018-04-04 15:56 ` [dpdk-dev] [PATCH v1 02/16] ethdev: add error types to flow API Adrien Mazarguil ` (15 subsequent siblings) 16 siblings, 1 reply; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-04 15:56 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev Subsequent patches will modify existing types and slightly alter the behavior of the flow API. This warrants a major ABI breakage. While it is already taken care of for 18.05 (LIBABIVER was updated to version 9 by a prior commit), this patch explicitly adds the affected flow API functions as a safety measure. Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> --- lib/librte_ether/rte_ethdev_version.map | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/librte_ether/rte_ethdev_version.map b/lib/librte_ether/rte_ethdev_version.map index 34df6c8b5..78a6f5afb 100644 --- a/lib/librte_ether/rte_ethdev_version.map +++ b/lib/librte_ether/rte_ethdev_version.map @@ -203,6 +203,16 @@ DPDK_18.02 { } DPDK_17.11; +DPDK_18.05 { + global: + + rte_flow_validate; + rte_flow_create; + rte_flow_query; + rte_flow_copy; + +} DPDK_18.02; + EXPERIMENTAL { global: -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [dpdk-dev] [PATCH v1 01/16] ethdev: update ABI for flow API functions 2018-04-04 15:56 ` [dpdk-dev] [PATCH v1 01/16] ethdev: update ABI for flow API functions Adrien Mazarguil @ 2018-04-05 10:06 ` Thomas Monjalon 2018-04-05 12:44 ` Adrien Mazarguil 0 siblings, 1 reply; 157+ messages in thread From: Thomas Monjalon @ 2018-04-05 10:06 UTC (permalink / raw) To: Adrien Mazarguil; +Cc: dev, Ferruh Yigit 04/04/2018 17:56, Adrien Mazarguil: > Subsequent patches will modify existing types and slightly alter the > behavior of the flow API. This warrants a major ABI breakage. > > While it is already taken care of for 18.05 (LIBABIVER was updated to > version 9 by a prior commit), this patch explicitly adds the affected flow > API functions as a safety measure. I don't understand this patch. If the API is broken, you must move the function from old block to the new one. And it must be done in the patch modifying the function. > --- a/lib/librte_ether/rte_ethdev_version.map > +++ b/lib/librte_ether/rte_ethdev_version.map > +DPDK_18.05 { > + global: > + > + rte_flow_validate; > + rte_flow_create; > + rte_flow_query; > + rte_flow_copy; > + > +} DPDK_18.02; ^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [dpdk-dev] [PATCH v1 01/16] ethdev: update ABI for flow API functions 2018-04-05 10:06 ` Thomas Monjalon @ 2018-04-05 12:44 ` Adrien Mazarguil 2018-04-05 13:36 ` Thomas Monjalon 0 siblings, 1 reply; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-05 12:44 UTC (permalink / raw) To: Thomas Monjalon; +Cc: dev, Ferruh Yigit On Thu, Apr 05, 2018 at 12:06:10PM +0200, Thomas Monjalon wrote: > 04/04/2018 17:56, Adrien Mazarguil: > > Subsequent patches will modify existing types and slightly alter the > > behavior of the flow API. This warrants a major ABI breakage. > > > > While it is already taken care of for 18.05 (LIBABIVER was updated to > > version 9 by a prior commit), this patch explicitly adds the affected flow > > API functions as a safety measure. > > I don't understand this patch. > > If the API is broken, you must move the function from old block to > the new one. Missed that part, I'll update it. > And it must be done in the patch modifying the function. About that, almost each patch in this series breaks the ABI in its own way. This left me with two options: either updating these functions once and for all and explaining why in a dedicated patch, or updating them in the first patch with an ABI impact, with subsequent patches piggybacking on that change. Unless there's a way to update the map file for each patch that breaks ABI, I think the former is more consistent, but I don't mind if you prefer the latter. What do you suggest? -- Adrien Mazarguil 6WIND ^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [dpdk-dev] [PATCH v1 01/16] ethdev: update ABI for flow API functions 2018-04-05 12:44 ` Adrien Mazarguil @ 2018-04-05 13:36 ` Thomas Monjalon 0 siblings, 0 replies; 157+ messages in thread From: Thomas Monjalon @ 2018-04-05 13:36 UTC (permalink / raw) To: Adrien Mazarguil; +Cc: dev, Ferruh Yigit 05/04/2018 14:44, Adrien Mazarguil: > On Thu, Apr 05, 2018 at 12:06:10PM +0200, Thomas Monjalon wrote: > > 04/04/2018 17:56, Adrien Mazarguil: > > > Subsequent patches will modify existing types and slightly alter the > > > behavior of the flow API. This warrants a major ABI breakage. > > > > > > While it is already taken care of for 18.05 (LIBABIVER was updated to > > > version 9 by a prior commit), this patch explicitly adds the affected flow > > > API functions as a safety measure. > > > > I don't understand this patch. > > > > If the API is broken, you must move the function from old block to > > the new one. > > Missed that part, I'll update it. > > > And it must be done in the patch modifying the function. > > About that, almost each patch in this series breaks the ABI in its own > way. This left me with two options: either updating these functions once and > for all and explaining why in a dedicated patch, or updating them in the > first patch with an ABI impact, with subsequent patches piggybacking on that > change. > > Unless there's a way to update the map file for each patch that breaks ABI, > I think the former is more consistent, but I don't mind if you prefer the > latter. What do you suggest? The ABI information must be updated when breaking (2nd solution). ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v1 02/16] ethdev: add error types to flow API 2018-04-04 15:56 [dpdk-dev] [PATCH v1 00/16] Flow API overhaul for switch offloads Adrien Mazarguil 2018-04-04 15:56 ` [dpdk-dev] [PATCH v1 01/16] ethdev: update ABI for flow API functions Adrien Mazarguil @ 2018-04-04 15:56 ` Adrien Mazarguil 2018-04-04 15:56 ` [dpdk-dev] [PATCH v1 03/16] ethdev: clarify flow API pattern items and actions Adrien Mazarguil ` (14 subsequent siblings) 16 siblings, 0 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-04 15:56 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev These enable more precise reporting of objects responsible for errors. Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> --- app/test-pmd/config.c | 4 ++++ lib/librte_ether/rte_flow.h | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 2058e6ec8..7ae0295f6 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -1228,8 +1228,12 @@ port_flow_complain(struct rte_flow_error *error) [RTE_FLOW_ERROR_TYPE_ATTR_EGRESS] = "egress field", [RTE_FLOW_ERROR_TYPE_ATTR] = "attributes structure", [RTE_FLOW_ERROR_TYPE_ITEM_NUM] = "pattern length", + [RTE_FLOW_ERROR_TYPE_ITEM_SPEC] = "item specification", + [RTE_FLOW_ERROR_TYPE_ITEM_LAST] = "item specification range", + [RTE_FLOW_ERROR_TYPE_ITEM_MASK] = "item specification mask", [RTE_FLOW_ERROR_TYPE_ITEM] = "specific pattern item", [RTE_FLOW_ERROR_TYPE_ACTION_NUM] = "number of actions", + [RTE_FLOW_ERROR_TYPE_ACTION_CONF] = "action configuration", [RTE_FLOW_ERROR_TYPE_ACTION] = "specific action", }; const char *errstr; diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index cdaaa3a5b..95799fd9c 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -1186,8 +1186,12 @@ enum rte_flow_error_type { RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, /**< Egress field. */ RTE_FLOW_ERROR_TYPE_ATTR, /**< Attributes structure. */ RTE_FLOW_ERROR_TYPE_ITEM_NUM, /**< Pattern length. */ + RTE_FLOW_ERROR_TYPE_ITEM_SPEC, /**< Item specification. */ + RTE_FLOW_ERROR_TYPE_ITEM_LAST, /**< Item specification range. */ + RTE_FLOW_ERROR_TYPE_ITEM_MASK, /**< Item specification mask. */ RTE_FLOW_ERROR_TYPE_ITEM, /**< Specific pattern item. */ RTE_FLOW_ERROR_TYPE_ACTION_NUM, /**< Number of actions. */ + RTE_FLOW_ERROR_TYPE_ACTION_CONF, /**< Action configuration. */ RTE_FLOW_ERROR_TYPE_ACTION, /**< Specific action. */ }; -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v1 03/16] ethdev: clarify flow API pattern items and actions 2018-04-04 15:56 [dpdk-dev] [PATCH v1 00/16] Flow API overhaul for switch offloads Adrien Mazarguil 2018-04-04 15:56 ` [dpdk-dev] [PATCH v1 01/16] ethdev: update ABI for flow API functions Adrien Mazarguil 2018-04-04 15:56 ` [dpdk-dev] [PATCH v1 02/16] ethdev: add error types to flow API Adrien Mazarguil @ 2018-04-04 15:56 ` Adrien Mazarguil 2018-04-04 15:56 ` [dpdk-dev] [PATCH v1 04/16] doc: remove flow API migration section Adrien Mazarguil ` (13 subsequent siblings) 16 siblings, 0 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-04 15:56 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev Although pattern items and actions examples end with "and so on", these lists include all existing definitions and as a result are updated almost every time new types are added. This is cumbersome and pointless. This patch also synchronizes Doxygen and external API documentation wording with a slight clarification regarding meta pattern items. No fundamental API change. Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> --- doc/guides/prog_guide/rte_flow.rst | 23 +++++++++++------------ lib/librte_ether/rte_flow.h | 23 ++++++++++------------- 2 files changed, 21 insertions(+), 25 deletions(-) diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 961943dda..a11ebd617 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -186,12 +186,13 @@ Pattern item Pattern items fall in two categories: -- Matching protocol headers and packet data (ANY, RAW, ETH, VLAN, IPV4, - IPV6, ICMP, UDP, TCP, SCTP, VXLAN, MPLS, GRE, ESP and so on), usually - associated with a specification structure. +- Matching protocol headers and packet data, usually associated with a + specification structure. These must be stacked in the same order as the + protocol layers to match inside packets, starting from the lowest. -- Matching meta-data or affecting pattern processing (END, VOID, INVERT, PF, - VF, PORT and so on), often without a specification structure. +- Matching meta-data or affecting pattern processing, often without a + specification structure. Since they do not match packet contents, their + position in the list is usually not relevant. Item specification structures are used to match specific values among protocol fields (or item properties). Documentation describes for each item @@ -1001,15 +1002,13 @@ to a flow rule. That list is not ordered. They fall in three categories: -- Terminating actions (such as QUEUE, DROP, RSS, PF, VF) that prevent - processing matched packets by subsequent flow rules, unless overridden - with PASSTHRU. +- Terminating actions that prevent processing matched packets by subsequent + flow rules, unless overridden with PASSTHRU. -- Non-terminating actions (PASSTHRU, DUP) that leave matched packets up for - additional processing by subsequent flow rules. +- Non-terminating actions that leave matched packets up for additional + processing by subsequent flow rules. -- Other non-terminating meta actions that do not affect the fate of packets - (END, VOID, MARK, FLAG, COUNT, SECURITY). +- Other non-terminating meta actions that do not affect the fate of packets. When several actions are combined in a flow rule, they should all have different types (e.g. dropping a packet twice is not possible). diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index 95799fd9c..36fd38ffa 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -78,15 +78,13 @@ struct rte_flow_attr { * * Pattern items fall in two categories: * - * - Matching protocol headers and packet data (ANY, RAW, ETH, VLAN, IPV4, - * IPV6, ICMP, UDP, TCP, SCTP, VXLAN and so on), usually associated with a + * - Matching protocol headers and packet data, usually associated with a * specification structure. These must be stacked in the same order as the - * protocol layers to match, starting from the lowest. + * protocol layers to match inside packets, starting from the lowest. * - * - Matching meta-data or affecting pattern processing (END, VOID, INVERT, - * PF, VF, PORT and so on), often without a specification structure. Since - * they do not match packet contents, these can be specified anywhere - * within item lists without affecting others. + * - Matching meta-data or affecting pattern processing, often without a + * specification structure. Since they do not match packet contents, their + * position in the list is usually not relevant. * * See the description of individual types for more information. Those * marked with [META] fall into the second category. @@ -865,15 +863,14 @@ struct rte_flow_item { * * They fall in three categories: * - * - Terminating actions (such as QUEUE, DROP, RSS, PF, VF) that prevent - * processing matched packets by subsequent flow rules, unless overridden - * with PASSTHRU. + * - Terminating actions that prevent processing matched packets by + * subsequent flow rules, unless overridden with PASSTHRU. * - * - Non terminating actions (PASSTHRU, DUP) that leave matched packets up - * for additional processing by subsequent flow rules. + * - Non terminating actions that leave matched packets up for additional + * processing by subsequent flow rules. * * - Other non terminating meta actions that do not affect the fate of - * packets (END, VOID, MARK, FLAG, COUNT). + * packets. * * When several actions are combined in a flow rule, they should all have * different types (e.g. dropping a packet twice is not possible). -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v1 04/16] doc: remove flow API migration section 2018-04-04 15:56 [dpdk-dev] [PATCH v1 00/16] Flow API overhaul for switch offloads Adrien Mazarguil ` (2 preceding siblings ...) 2018-04-04 15:56 ` [dpdk-dev] [PATCH v1 03/16] ethdev: clarify flow API pattern items and actions Adrien Mazarguil @ 2018-04-04 15:56 ` Adrien Mazarguil 2018-04-04 15:56 ` [dpdk-dev] [PATCH v1 05/16] ethdev: remove DUP action from flow API Adrien Mazarguil ` (12 subsequent siblings) 16 siblings, 0 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-04 15:56 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev This section has become less relevant since the flow API (rte_flow) is now a mature DPDK API with applications developed directly on top of it instead of an afterthought. This patch removes it for the following reasons: - It has never been updated to track the latest changes in the legacy filter types and never will. - Many provided examples are theoretical and misleading since PMDs do not implement them. Others are obvious. - Upcoming work on the flow API will alter the behavior of several pattern items, actions and in some cases, flow rules, which will in turn cause existing examples to be wrong. Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> --- doc/guides/prog_guide/rte_flow.rst | 298 -------------------------------- 1 file changed, 298 deletions(-) diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index a11ebd617..51826d04c 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -55,9 +55,6 @@ encompasses and supersedes (including all functions and filter types) in order to expose a single interface with an unambiguous behavior that is common to all poll-mode drivers (PMDs). -Several methods to migrate existing applications are described in `API -migration`_. - Flow rule --------- @@ -2068,298 +2065,3 @@ Future evolutions - Optional software fallback when PMDs are unable to handle requested flow rules so applications do not have to implement their own. - -API migration -------------- - -Exhaustive list of deprecated filter types (normally prefixed with -*RTE_ETH_FILTER_*) found in ``rte_eth_ctrl.h`` and methods to convert them -to *rte_flow* rules. - -``MACVLAN`` to ``ETH`` → ``VF``, ``PF`` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -*MACVLAN* can be translated to a basic `Item: ETH`_ flow rule with a -terminating `Action: VF`_ or `Action: PF`_. - -.. _table_rte_flow_migration_macvlan: - -.. table:: MACVLAN conversion - - +--------------------------+---------+ - | Pattern | Actions | - +===+=====+==========+=====+=========+ - | 0 | ETH | ``spec`` | any | VF, | - | | +----------+-----+ PF | - | | | ``last`` | N/A | | - | | +----------+-----+ | - | | | ``mask`` | any | | - +---+-----+----------+-----+---------+ - | 1 | END | END | - +---+----------------------+---------+ - -``ETHERTYPE`` to ``ETH`` → ``QUEUE``, ``DROP`` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -*ETHERTYPE* is basically an `Item: ETH`_ flow rule with a terminating -`Action: QUEUE`_ or `Action: DROP`_. - -.. _table_rte_flow_migration_ethertype: - -.. table:: ETHERTYPE conversion - - +--------------------------+---------+ - | Pattern | Actions | - +===+=====+==========+=====+=========+ - | 0 | ETH | ``spec`` | any | QUEUE, | - | | +----------+-----+ DROP | - | | | ``last`` | N/A | | - | | +----------+-----+ | - | | | ``mask`` | any | | - +---+-----+----------+-----+---------+ - | 1 | END | END | - +---+----------------------+---------+ - -``FLEXIBLE`` to ``RAW`` → ``QUEUE`` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -*FLEXIBLE* can be translated to one `Item: RAW`_ pattern with a terminating -`Action: QUEUE`_ and a defined priority level. - -.. _table_rte_flow_migration_flexible: - -.. table:: FLEXIBLE conversion - - +--------------------------+---------+ - | Pattern | Actions | - +===+=====+==========+=====+=========+ - | 0 | RAW | ``spec`` | any | QUEUE | - | | +----------+-----+ | - | | | ``last`` | N/A | | - | | +----------+-----+ | - | | | ``mask`` | any | | - +---+-----+----------+-----+---------+ - | 1 | END | END | - +---+----------------------+---------+ - -``SYN`` to ``TCP`` → ``QUEUE`` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -*SYN* is a `Item: TCP`_ rule with only the ``syn`` bit enabled and masked, -and a terminating `Action: QUEUE`_. - -Priority level can be set to simulate the high priority bit. - -.. _table_rte_flow_migration_syn: - -.. table:: SYN conversion - - +-----------------------------------+---------+ - | Pattern | Actions | - +===+======+==========+=============+=========+ - | 0 | ETH | ``spec`` | unset | QUEUE | - | | +----------+-------------+ | - | | | ``last`` | unset | | - | | +----------+-------------+ | - | | | ``mask`` | unset | | - +---+------+----------+-------------+---------+ - | 1 | IPV4 | ``spec`` | unset | END | - | | +----------+-------------+ | - | | | ``mask`` | unset | | - | | +----------+-------------+ | - | | | ``mask`` | unset | | - +---+------+----------+---------+---+ | - | 2 | TCP | ``spec`` | ``syn`` | 1 | | - | | +----------+---------+---+ | - | | | ``mask`` | ``syn`` | 1 | | - +---+------+----------+---------+---+ | - | 3 | END | | - +---+-------------------------------+---------+ - -``NTUPLE`` to ``IPV4``, ``TCP``, ``UDP`` → ``QUEUE`` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -*NTUPLE* is similar to specifying an empty L2, `Item: IPV4`_ as L3 with -`Item: TCP`_ or `Item: UDP`_ as L4 and a terminating `Action: QUEUE`_. - -A priority level can be specified as well. - -.. _table_rte_flow_migration_ntuple: - -.. table:: NTUPLE conversion - - +-----------------------------+---------+ - | Pattern | Actions | - +===+======+==========+=======+=========+ - | 0 | ETH | ``spec`` | unset | QUEUE | - | | +----------+-------+ | - | | | ``last`` | unset | | - | | +----------+-------+ | - | | | ``mask`` | unset | | - +---+------+----------+-------+---------+ - | 1 | IPV4 | ``spec`` | any | END | - | | +----------+-------+ | - | | | ``last`` | unset | | - | | +----------+-------+ | - | | | ``mask`` | any | | - +---+------+----------+-------+ | - | 2 | TCP, | ``spec`` | any | | - | | UDP +----------+-------+ | - | | | ``last`` | unset | | - | | +----------+-------+ | - | | | ``mask`` | any | | - +---+------+----------+-------+ | - | 3 | END | | - +---+-------------------------+---------+ - -``TUNNEL`` to ``ETH``, ``IPV4``, ``IPV6``, ``VXLAN`` (or other) → ``QUEUE`` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -*TUNNEL* matches common IPv4 and IPv6 L3/L4-based tunnel types. - -In the following table, `Item: ANY`_ is used to cover the optional L4. - -.. _table_rte_flow_migration_tunnel: - -.. table:: TUNNEL conversion - - +-------------------------------------------------------+---------+ - | Pattern | Actions | - +===+==========================+==========+=============+=========+ - | 0 | ETH | ``spec`` | any | QUEUE | - | | +----------+-------------+ | - | | | ``last`` | unset | | - | | +----------+-------------+ | - | | | ``mask`` | any | | - +---+--------------------------+----------+-------------+---------+ - | 1 | IPV4, IPV6 | ``spec`` | any | END | - | | +----------+-------------+ | - | | | ``last`` | unset | | - | | +----------+-------------+ | - | | | ``mask`` | any | | - +---+--------------------------+----------+-------------+ | - | 2 | ANY | ``spec`` | any | | - | | +----------+-------------+ | - | | | ``last`` | unset | | - | | +----------+---------+---+ | - | | | ``mask`` | ``num`` | 0 | | - +---+--------------------------+----------+---------+---+ | - | 3 | VXLAN, GENEVE, TEREDO, | ``spec`` | any | | - | | NVGRE, GRE, ... +----------+-------------+ | - | | | ``last`` | unset | | - | | +----------+-------------+ | - | | | ``mask`` | any | | - +---+--------------------------+----------+-------------+ | - | 4 | END | | - +---+---------------------------------------------------+---------+ - -``FDIR`` to most item types → ``QUEUE``, ``DROP``, ``PASSTHRU`` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -*FDIR* is more complex than any other type, there are several methods to -emulate its functionality. It is summarized for the most part in the table -below. - -A few features are intentionally not supported: - -- The ability to configure the matching input set and masks for the entire - device, PMDs should take care of it automatically according to the - requested flow rules. - - For example if a device supports only one bit-mask per protocol type, - source/address IPv4 bit-masks can be made immutable by the first created - rule. Subsequent IPv4 or TCPv4 rules can only be created if they are - compatible. - - Note that only protocol bit-masks affected by existing flow rules are - immutable, others can be changed later. They become mutable again after - the related flow rules are destroyed. - -- Returning four or eight bytes of matched data when using flex bytes - filtering. Although a specific action could implement it, it conflicts - with the much more useful 32 bits tagging on devices that support it. - -- Side effects on RSS processing of the entire device. Flow rules that - conflict with the current device configuration should not be - allowed. Similarly, device configuration should not be allowed when it - affects existing flow rules. - -- Device modes of operation. "none" is unsupported since filtering cannot be - disabled as long as a flow rule is present. - -- "MAC VLAN" or "tunnel" perfect matching modes should be automatically set - according to the created flow rules. - -- Signature mode of operation is not defined but could be handled through - "FUZZY" item. - -.. _table_rte_flow_migration_fdir: - -.. table:: FDIR conversion - - +----------------------------------------+-----------------------+ - | Pattern | Actions | - +===+===================+==========+=====+=======================+ - | 0 | ETH, RAW | ``spec`` | any | QUEUE, DROP, PASSTHRU | - | | +----------+-----+ | - | | | ``last`` | N/A | | - | | +----------+-----+ | - | | | ``mask`` | any | | - +---+-------------------+----------+-----+-----------------------+ - | 1 | IPV4, IPv6 | ``spec`` | any | MARK | - | | +----------+-----+ | - | | | ``last`` | N/A | | - | | +----------+-----+ | - | | | ``mask`` | any | | - +---+-------------------+----------+-----+-----------------------+ - | 2 | TCP, UDP, SCTP | ``spec`` | any | END | - | | +----------+-----+ | - | | | ``last`` | N/A | | - | | +----------+-----+ | - | | | ``mask`` | any | | - +---+-------------------+----------+-----+ | - | 3 | VF, PF, FUZZY | ``spec`` | any | | - | | (optional) +----------+-----+ | - | | | ``last`` | N/A | | - | | +----------+-----+ | - | | | ``mask`` | any | | - +---+-------------------+----------+-----+ | - | 4 | END | | - +---+------------------------------------+-----------------------+ - -``HASH`` -~~~~~~~~ - -There is no counterpart to this filter type because it translates to a -global device setting instead of a pattern item. Device settings are -automatically set according to the created flow rules. - -``L2_TUNNEL`` to ``VOID`` → ``VXLAN`` (or others) -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -All packets are matched. This type alters incoming packets to encapsulate -them in a chosen tunnel type, optionally redirect them to a VF as well. - -The destination pool for tag based forwarding can be emulated with other -flow rules using `Action: DUP`_. - -.. _table_rte_flow_migration_l2tunnel: - -.. table:: L2_TUNNEL conversion - - +---------------------------+--------------------+ - | Pattern | Actions | - +===+======+==========+=====+====================+ - | 0 | VOID | ``spec`` | N/A | VXLAN, GENEVE, ... | - | | | | | | - | | | | | | - | | +----------+-----+ | - | | | ``last`` | N/A | | - | | +----------+-----+ | - | | | ``mask`` | N/A | | - | | | | | | - +---+------+----------+-----+--------------------+ - | 1 | END | VF (optional) | - +---+ +--------------------+ - | 2 | | END | - +---+-----------------------+--------------------+ -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v1 05/16] ethdev: remove DUP action from flow API 2018-04-04 15:56 [dpdk-dev] [PATCH v1 00/16] Flow API overhaul for switch offloads Adrien Mazarguil ` (3 preceding siblings ...) 2018-04-04 15:56 ` [dpdk-dev] [PATCH v1 04/16] doc: remove flow API migration section Adrien Mazarguil @ 2018-04-04 15:56 ` Adrien Mazarguil 2018-04-04 15:56 ` [dpdk-dev] [PATCH v1 06/16] ethdev: alter behavior of flow API actions Adrien Mazarguil ` (11 subsequent siblings) 16 siblings, 0 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-04 15:56 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev Upcoming changes in relation to the handling of actions list will make the DUP action redundant as specifying several QUEUE actions will achieve the same behavior. Besides, no PMD implements this action. By removing an entry from enum rte_flow_action_type, this patch triggers a major ABI breakage. Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> --- app/test-pmd/cmdline_flow.c | 23 ----------------------- app/test-pmd/config.c | 1 - doc/guides/prog_guide/rte_flow.rst | 23 ----------------------- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 8 -------- lib/librte_ether/rte_flow.c | 1 - lib/librte_ether/rte_flow.h | 24 ------------------------ 6 files changed, 80 deletions(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 30450f1a4..9702b3ef3 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -164,8 +164,6 @@ enum index { ACTION_QUEUE_INDEX, ACTION_DROP, ACTION_COUNT, - ACTION_DUP, - ACTION_DUP_INDEX, ACTION_RSS, ACTION_RSS_TYPES, ACTION_RSS_TYPE, @@ -625,7 +623,6 @@ static const enum index next_action[] = { ACTION_QUEUE, ACTION_DROP, ACTION_COUNT, - ACTION_DUP, ACTION_RSS, ACTION_PF, ACTION_VF, @@ -645,12 +642,6 @@ static const enum index action_queue[] = { ZERO, }; -static const enum index action_dup[] = { - ACTION_DUP_INDEX, - ACTION_NEXT, - ZERO, -}; - static const enum index action_rss[] = { ACTION_RSS_TYPES, ACTION_RSS_KEY, @@ -1597,20 +1588,6 @@ static const struct token token_list[] = { .next = NEXT(NEXT_ENTRY(ACTION_NEXT)), .call = parse_vc, }, - [ACTION_DUP] = { - .name = "dup", - .help = "duplicate packets to a given queue index", - .priv = PRIV_ACTION(DUP, sizeof(struct rte_flow_action_dup)), - .next = NEXT(action_dup), - .call = parse_vc, - }, - [ACTION_DUP_INDEX] = { - .name = "index", - .help = "queue index to duplicate packets to", - .next = NEXT(action_dup, NEXT_ENTRY(UNSIGNED)), - .args = ARGS(ARGS_ENTRY(struct rte_flow_action_dup, index)), - .call = parse_vc_conf, - }, [ACTION_RSS] = { .name = "rss", .help = "spread packets among several queues", diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 7ae0295f6..8d42ea9a9 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -1049,7 +1049,6 @@ static const struct { MK_FLOW_ACTION(QUEUE, sizeof(struct rte_flow_action_queue)), MK_FLOW_ACTION(DROP, 0), MK_FLOW_ACTION(COUNT, 0), - MK_FLOW_ACTION(DUP, sizeof(struct rte_flow_action_dup)), MK_FLOW_ACTION(RSS, sizeof(struct rte_flow_action_rss)), /* +queue[] */ MK_FLOW_ACTION(PF, 0), MK_FLOW_ACTION(VF, sizeof(struct rte_flow_action_vf)), diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 51826d04c..a237e4fd2 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -1299,26 +1299,6 @@ Query structure to retrieve and reset flow rule counters: | ``bytes`` | out | number of bytes through this rule | +---------------+-----+-----------------------------------+ -Action: ``DUP`` -^^^^^^^^^^^^^^^ - -Duplicates packets to a given queue index. - -This is normally combined with QUEUE, however when used alone, it is -actually similar to QUEUE + PASSTHRU. - -- Non-terminating by default. - -.. _table_rte_flow_action_dup: - -.. table:: DUP - - +-----------+------------------------------------+ - | Field | Value | - +===========+====================================+ - | ``index`` | queue index to duplicate packet to | - +-----------+------------------------------------+ - Action: ``RSS`` ^^^^^^^^^^^^^^^ @@ -2010,9 +1990,6 @@ Unsupported actions and tagging (`Action: MARK`_ or `Action: FLAG`_) may be implemented in software as long as the target queue is used by a single rule. -- A rule specifying both `Action: DUP`_ + `Action: QUEUE`_ may be translated - to two hidden rules combining `Action: QUEUE`_ and `Action: PASSTHRU`_. - - When a single target queue is provided, `Action: RSS`_ can also be implemented through `Action: QUEUE`_. diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index cb6f201e1..a015d02a4 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3363,10 +3363,6 @@ actions can sometimes be combined when the end result is unambiguous:: :: - drop / dup index 6 / end # same as above - -:: - queue index 6 / rss queues 6 7 8 / end # queue has no effect :: @@ -3400,10 +3396,6 @@ This section lists supported actions and their attributes, if any. - ``count``: enable counters for this rule. -- ``dup``: duplicate packets to a given queue index. - - - ``index {unsigned}``: queue index to duplicate packets to. - - ``rss``: spread packets among several queues. - ``types [{RSS hash type} [...]] end``: RSS hash types, allowed tokens diff --git a/lib/librte_ether/rte_flow.c b/lib/librte_ether/rte_flow.c index ba6feddee..db04c4f94 100644 --- a/lib/librte_ether/rte_flow.c +++ b/lib/librte_ether/rte_flow.c @@ -73,7 +73,6 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = { MK_FLOW_ACTION(QUEUE, sizeof(struct rte_flow_action_queue)), MK_FLOW_ACTION(DROP, 0), MK_FLOW_ACTION(COUNT, 0), - MK_FLOW_ACTION(DUP, sizeof(struct rte_flow_action_dup)), MK_FLOW_ACTION(RSS, sizeof(struct rte_flow_action_rss)), /* +queue[] */ MK_FLOW_ACTION(PF, 0), MK_FLOW_ACTION(VF, sizeof(struct rte_flow_action_vf)), diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index 36fd38ffa..aab637a2c 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -961,16 +961,6 @@ enum rte_flow_action_type { RTE_FLOW_ACTION_TYPE_COUNT, /** - * Duplicates packets to a given queue index. - * - * This is normally combined with QUEUE, however when used alone, it - * is actually similar to QUEUE + PASSTHRU. - * - * See struct rte_flow_action_dup. - */ - RTE_FLOW_ACTION_TYPE_DUP, - - /** * Similar to QUEUE, except RSS is additionally performed on packets * to spread them among several queues according to the provided * parameters. @@ -1052,20 +1042,6 @@ struct rte_flow_query_count { }; /** - * RTE_FLOW_ACTION_TYPE_DUP - * - * Duplicates packets to a given queue index. - * - * This is normally combined with QUEUE, however when used alone, it is - * actually similar to QUEUE + PASSTHRU. - * - * Non-terminating by default. - */ -struct rte_flow_action_dup { - uint16_t index; /**< Queue index to duplicate packets to. */ -}; - -/** * RTE_FLOW_ACTION_TYPE_RSS * * Similar to QUEUE, except RSS is additionally performed on packets to -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v1 06/16] ethdev: alter behavior of flow API actions 2018-04-04 15:56 [dpdk-dev] [PATCH v1 00/16] Flow API overhaul for switch offloads Adrien Mazarguil ` (4 preceding siblings ...) 2018-04-04 15:56 ` [dpdk-dev] [PATCH v1 05/16] ethdev: remove DUP action from flow API Adrien Mazarguil @ 2018-04-04 15:56 ` Adrien Mazarguil 2018-04-04 15:56 ` [dpdk-dev] [PATCH v1 07/16] ethdev: remove C99 flexible arrays from flow API Adrien Mazarguil ` (10 subsequent siblings) 16 siblings, 0 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-04 15:56 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev Cc: Ajit Khaparde, Wenzhuo Lu, John Daley, Gaetan Rivet, Beilei Xing, Konstantin Ananyev, Nelio Laranjeiro, Andrew Rybchenko, Pascal Mazon This patch makes the following changes to flow rule actions: - List order now matters, they are redefined as performed first to last instead of "all simultaneously". - Repeated actions are now supported (e.g. specifying QUEUE multiple times now duplicates traffic among them). Previously only the last action of any given kind was taken into account. - No more distinction between terminating/non-terminating/meta actions. Flow rules themselves are now defined as always terminating unless a PASSTHRU action is specified. These changes alter the behavior of flow rules in corner cases in order to prepare the flow API for actions that modify traffic contents or properties (e.g. encapsulation, compression) and for which order matter when combined. Previously one would have to so through multiple flow rules by combining PASSTRHU with priority levels, however this proved overly complex to implement at the PMD level, hence this simpler approach. PMDs with rte_flow support are modified accordingly: - bnxt: no change, implementation already forbids multiple actions and does not support PASSTHRU. - e1000: no change, same as bnxt. - enic: modified to forbid redundant actions, no support for default drop. - failsafe: no change needed. - i40e: no change, implementation already forbids multiple actions. - ixgbe: same as i40e. - mlx4: modified to forbid multiple fate-deciding actions and drop when unspecified. - mlx5: same as mlx4, with other redundant actions also forbidden. - sfc: same as mlx4. - tap: implementation already complies with the new behavior except for the default pass-through modified as a default drop. Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Cc: Ajit Khaparde <ajit.khaparde@broadcom.com> Cc: Wenzhuo Lu <wenzhuo.lu@intel.com> Cc: John Daley <johndale@cisco.com> Cc: Gaetan Rivet <gaetan.rivet@6wind.com> Cc: Beilei Xing <beilei.xing@intel.com> Cc: Konstantin Ananyev <konstantin.ananyev@intel.com> Cc: Nelio Laranjeiro <nelio.laranjeiro@6wind.com> Cc: Andrew Rybchenko <arybchenko@solarflare.com> Cc: Pascal Mazon <pascal.mazon@6wind.com> --- doc/guides/prog_guide/rte_flow.rst | 66 +++++++++++++------------------ drivers/net/enic/enic_flow.c | 25 ++++++++++++ drivers/net/mlx4/mlx4_flow.c | 21 +++++++--- drivers/net/mlx5/mlx5_flow.c | 69 ++++++++++++++------------------- drivers/net/sfc/sfc_flow.c | 22 +++++++---- drivers/net/tap/tap_flow.c | 11 ++++++ lib/librte_ether/rte_flow.h | 53 +++++++------------------ 7 files changed, 136 insertions(+), 131 deletions(-) diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index a237e4fd2..8f3700cdb 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -995,28 +995,26 @@ Actions Each possible action is represented by a type. Some have associated configuration structures. Several actions combined in a list can be assigned -to a flow rule. That list is not ordered. +to a flow rule and are performed in order. They fall in three categories: -- Terminating actions that prevent processing matched packets by subsequent - flow rules, unless overridden with PASSTHRU. +- Actions that modify the fate of matching traffic, for instance by dropping + or assigning it a specific destination. -- Non-terminating actions that leave matched packets up for additional - processing by subsequent flow rules. +- Actions that modify matching traffic contents or its properties. This + includes adding/removing encapsulation, encryption, compression and marks. -- Other non-terminating meta actions that do not affect the fate of packets. +- Actions related to the flow rule itself, such as updating counters or + making it non-terminating. -When several actions are combined in a flow rule, they should all have -different types (e.g. dropping a packet twice is not possible). +Flow rules being terminating by default, not specifying any action of the +fate type implicitly drops matching traffic. -Only the last action of a given type is taken into account. PMDs still -perform error checking on the entire list. +PASSTHRU, when supported, makes a flow rule non-terminating. Like matching patterns, action lists are terminated by END items. -*Note that PASSTHRU is the only action able to override a terminating rule.* - Example of action that redirects packets to queue index 10: .. _table_rte_flow_action_example: @@ -1029,12 +1027,11 @@ Example of action that redirects packets to queue index 10: | ``index`` | 10 | +-----------+-------+ -Action lists examples, their order is not significant, applications must -consider all actions to be performed simultaneously: +Actions are performed in list order: -.. _table_rte_flow_count_and_drop: +.. _table_rte_flow_count_then_drop: -.. table:: Count and drop +.. table:: Count then drop +-------+--------+ | Index | Action | @@ -1050,7 +1047,7 @@ consider all actions to be performed simultaneously: .. _table_rte_flow_mark_count_redirect: -.. table:: Mark, count and redirect +.. table:: Mark, count then redirect +-------+--------+-----------+-------+ | Index | Action | Field | Value | @@ -1080,12 +1077,15 @@ consider all actions to be performed simultaneously: | 2 | END | +-------+----------------------------+ -In the above example, considering both actions are performed simultaneously, -the end result is that only QUEUE has any effect. +In the above example, while DROP and QUEUE must be performed in order, both +have to happen before reaching END. Only QUEUE has a visible effect. + +Note that such a list may be thought as ambiguous and rejected on that +basis. -.. _table_rte_flow_redirect_queue_3: +.. _table_rte_flow_redirect_queue_5_3: -.. table:: Redirect to queue 3 +.. table:: Redirect to queues 5 and 3 +-------+--------+-----------+-------+ | Index | Action | Field | Value | @@ -1099,9 +1099,9 @@ the end result is that only QUEUE has any effect. | 3 | END | +-------+----------------------------+ -As previously described, only the last action of a given type found in the -list is taken into account. The above example also shows that VOID is -ignored. +As previously described, all actions must be taken into account. This +effectively duplicates traffic to both queues. The above example also shows +that VOID is ignored. Action types ~~~~~~~~~~~~ @@ -1151,9 +1151,8 @@ PMDs. Action: ``PASSTHRU`` ^^^^^^^^^^^^^^^^^^^^ -Leaves packets up for additional processing by subsequent flow rules. This -is the default when a rule does not contain a terminating action, but can be -specified to force a rule to become non-terminating. +Leaves traffic up for additional processing by subsequent flow rules; makes +a flow rule non-terminating. - No configurable properties. @@ -1227,8 +1226,6 @@ Action: ``QUEUE`` Assigns packets to a given queue index. -- Terminating by default. - .. _table_rte_flow_action_queue: .. table:: QUEUE @@ -1245,8 +1242,6 @@ Action: ``DROP`` Drop packets. - No configurable properties. -- Terminating by default. -- PASSTHRU overrides this action if both are specified. .. _table_rte_flow_action_drop: @@ -1309,8 +1304,6 @@ Note: RSS hash result is stored in the ``hash.rss`` mbuf field which overlaps ``hash.fdir.lo``. Since `Action: MARK`_ sets the ``hash.fdir.hi`` field only, both can be requested simultaneously. -- Terminating by default. - .. _table_rte_flow_action_rss: .. table:: RSS @@ -1331,7 +1324,6 @@ Action: ``PF`` Redirects packets to the physical function (PF) of the current device. - No configurable properties. -- Terminating by default. .. _table_rte_flow_action_pf: @@ -1353,8 +1345,6 @@ ID instead of the specified one. This parameter may not be available and is not guaranteed to work properly if the VF part is matched by a prior flow rule or if packets are not addressed to a VF in the first place. -- Terminating by default. - .. _table_rte_flow_action_vf: .. table:: VF @@ -1378,8 +1368,6 @@ action parameter. More than one flow can use the same MTR object through the meter action. The MTR object can be further updated or queried using the rte_mtr* API. -- Non-terminating by default. - .. _table_rte_flow_action_meter: .. table:: METER @@ -1415,8 +1403,6 @@ direction. Multiple flows can be configured to use the same security session. -- Non-terminating by default. - .. _table_rte_flow_action_security: .. table:: SECURITY diff --git a/drivers/net/enic/enic_flow.c b/drivers/net/enic/enic_flow.c index 28923b0e2..c5c98b870 100644 --- a/drivers/net/enic/enic_flow.c +++ b/drivers/net/enic/enic_flow.c @@ -3,6 +3,7 @@ */ #include <errno.h> +#include <stdint.h> #include <rte_log.h> #include <rte_ethdev_driver.h> #include <rte_flow_driver.h> @@ -952,6 +953,9 @@ static int enic_copy_action_v1(const struct rte_flow_action actions[], struct filter_action_v2 *enic_action) { + enum { FATE = 1, }; + uint32_t overlap = 0; + FLOW_TRACE(); for (; actions->type != RTE_FLOW_ACTION_TYPE_END; actions++) { @@ -963,6 +967,10 @@ enic_copy_action_v1(const struct rte_flow_action actions[], const struct rte_flow_action_queue *queue = (const struct rte_flow_action_queue *) actions->conf; + + if (overlap & FATE) + return ENOTSUP; + overlap |= FATE; enic_action->rq_idx = enic_rte_rq_idx_to_sop_idx(queue->index); break; @@ -972,6 +980,8 @@ enic_copy_action_v1(const struct rte_flow_action actions[], break; } } + if (!overlap & FATE) + return ENOTSUP; enic_action->type = FILTER_ACTION_RQ_STEERING; return 0; } @@ -989,6 +999,9 @@ static int enic_copy_action_v2(const struct rte_flow_action actions[], struct filter_action_v2 *enic_action) { + enum { FATE = 1, MARK = 2, }; + uint32_t overlap = 0; + FLOW_TRACE(); for (; actions->type != RTE_FLOW_ACTION_TYPE_END; actions++) { @@ -997,6 +1010,10 @@ enic_copy_action_v2(const struct rte_flow_action actions[], const struct rte_flow_action_queue *queue = (const struct rte_flow_action_queue *) actions->conf; + + if (overlap & FATE) + return ENOTSUP; + overlap |= FATE; enic_action->rq_idx = enic_rte_rq_idx_to_sop_idx(queue->index); enic_action->flags |= FILTER_ACTION_RQ_STEERING_FLAG; @@ -1007,6 +1024,9 @@ enic_copy_action_v2(const struct rte_flow_action actions[], (const struct rte_flow_action_mark *) actions->conf; + if (overlap & MARK) + return ENOTSUP; + overlap |= MARK; /* ENIC_MAGIC_FILTER_ID is reserved and is the highest * in the range of allows mark ids. */ @@ -1017,6 +1037,9 @@ enic_copy_action_v2(const struct rte_flow_action actions[], break; } case RTE_FLOW_ACTION_TYPE_FLAG: { + if (overlap & MARK) + return ENOTSUP; + overlap |= MARK; enic_action->filter_id = ENIC_MAGIC_FILTER_ID; enic_action->flags |= FILTER_ACTION_FILTER_ID_FLAG; break; @@ -1028,6 +1051,8 @@ enic_copy_action_v2(const struct rte_flow_action actions[], break; } } + if (!overlap & FATE) + return ENOTSUP; enic_action->type = FILTER_ACTION_V2; return 0; } diff --git a/drivers/net/mlx4/mlx4_flow.c b/drivers/net/mlx4/mlx4_flow.c index 4d26df326..582483076 100644 --- a/drivers/net/mlx4/mlx4_flow.c +++ b/drivers/net/mlx4/mlx4_flow.c @@ -637,6 +637,7 @@ mlx4_flow_prepare(struct priv *priv, struct rte_flow temp = { .ibv_attr_size = sizeof(*temp.ibv_attr) }; struct rte_flow *flow = &temp; const char *msg = NULL; + int overlap; if (attr->group) return rte_flow_error_set @@ -656,6 +657,7 @@ mlx4_flow_prepare(struct priv *priv, (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, NULL, "only ingress is supported"); fill: + overlap = 0; proc = mlx4_flow_proc_item_list; /* Go over pattern. */ for (item = pattern; item->type; ++item) { @@ -702,6 +704,16 @@ mlx4_flow_prepare(struct priv *priv, } /* Go over actions list. */ for (action = actions; action->type; ++action) { + /* This one may appear anywhere multiple times. */ + if (action->type == RTE_FLOW_ACTION_TYPE_VOID) + continue; + /* Fate-deciding actions may appear exactly once. */ + if (overlap) { + msg = "cannot combine several fate-deciding actions," + " choose between DROP, QUEUE or RSS"; + goto exit_action_not_supported; + } + overlap = 1; switch (action->type) { const struct rte_flow_action_queue *queue; const struct rte_flow_action_rss *rss; @@ -709,8 +721,6 @@ mlx4_flow_prepare(struct priv *priv, uint64_t fields; unsigned int i; - case RTE_FLOW_ACTION_TYPE_VOID: - continue; case RTE_FLOW_ACTION_TYPE_DROP: flow->drop = 1; break; @@ -801,10 +811,9 @@ mlx4_flow_prepare(struct priv *priv, goto exit_action_not_supported; } } - if (!flow->rss && !flow->drop) - return rte_flow_error_set - (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, - NULL, "no valid action"); + /* When fate is unknown, drop traffic. */ + if (!overlap) + flow->drop = 1; /* Validation ends here. */ if (!addr) { if (flow->rss) diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index f051fbef5..84d6f9b92 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -4,6 +4,7 @@ */ #include <sys/queue.h> +#include <stdint.h> #include <string.h> /* Verbs header. */ @@ -638,6 +639,8 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, struct rte_flow_error *error, struct mlx5_flow_parse *parser) { + enum { FATE = 1, MARK = 2, COUNT = 4, }; + uint32_t overlap = 0; struct priv *priv = dev->data->dev_private; int ret; @@ -654,39 +657,31 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, if (actions->type == RTE_FLOW_ACTION_TYPE_VOID) { continue; } else if (actions->type == RTE_FLOW_ACTION_TYPE_DROP) { + if (overlap & FATE) + goto exit_action_overlap; + overlap |= FATE; parser->drop = 1; } else if (actions->type == RTE_FLOW_ACTION_TYPE_QUEUE) { const struct rte_flow_action_queue *queue = (const struct rte_flow_action_queue *) actions->conf; - uint16_t n; - uint16_t found = 0; + if (overlap & FATE) + goto exit_action_overlap; + overlap |= FATE; if (!queue || (queue->index > (priv->rxqs_n - 1))) goto exit_action_not_supported; - for (n = 0; n < parser->queues_n; ++n) { - if (parser->queues[n] == queue->index) { - found = 1; - break; - } - } - if (parser->queues_n > 1 && !found) { - rte_flow_error_set(error, ENOTSUP, - RTE_FLOW_ERROR_TYPE_ACTION, - actions, - "queue action not in RSS queues"); - return -rte_errno; - } - if (!found) { - parser->queues_n = 1; - parser->queues[0] = queue->index; - } + parser->queues_n = 1; + parser->queues[0] = queue->index; } else if (actions->type == RTE_FLOW_ACTION_TYPE_RSS) { const struct rte_flow_action_rss *rss = (const struct rte_flow_action_rss *) actions->conf; uint16_t n; + if (overlap & FATE) + goto exit_action_overlap; + overlap |= FATE; if (!rss || !rss->num) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, @@ -694,26 +689,6 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, "no valid queues"); return -rte_errno; } - if (parser->queues_n == 1) { - uint16_t found = 0; - - assert(parser->queues_n); - for (n = 0; n < rss->num; ++n) { - if (parser->queues[0] == - rss->queue[n]) { - found = 1; - break; - } - } - if (!found) { - rte_flow_error_set(error, ENOTSUP, - RTE_FLOW_ERROR_TYPE_ACTION, - actions, - "queue action not in RSS" - " queues"); - return -rte_errno; - } - } if (rss->num > RTE_DIM(parser->queues)) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, @@ -747,6 +722,9 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, (const struct rte_flow_action_mark *) actions->conf; + if (overlap & MARK) + goto exit_action_overlap; + overlap |= MARK; if (!mark) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, @@ -764,14 +742,23 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, parser->mark = 1; parser->mark_id = mark->id; } else if (actions->type == RTE_FLOW_ACTION_TYPE_FLAG) { + if (overlap & MARK) + goto exit_action_overlap; + overlap |= MARK; parser->mark = 1; } else if (actions->type == RTE_FLOW_ACTION_TYPE_COUNT && priv->config.flow_counter_en) { + if (overlap & COUNT) + goto exit_action_overlap; + overlap |= COUNT; parser->count = 1; } else { goto exit_action_not_supported; } } + /* When fate is unknown, drop traffic. */ + if (!overlap & FATE) + parser->drop = 1; if (parser->drop && parser->mark) parser->mark = 0; if (!parser->queues_n && !parser->drop) { @@ -784,6 +771,10 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, actions, "action not supported"); return -rte_errno; +exit_action_overlap: + rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, + actions, "overlapping actions are not supported"); + return -rte_errno; } /** diff --git a/drivers/net/sfc/sfc_flow.c b/drivers/net/sfc/sfc_flow.c index 9060fdc2f..fb61ec73a 100644 --- a/drivers/net/sfc/sfc_flow.c +++ b/drivers/net/sfc/sfc_flow.c @@ -1468,10 +1468,19 @@ sfc_flow_parse_actions(struct sfc_adapter *sa, } for (; actions->type != RTE_FLOW_ACTION_TYPE_END; actions++) { + /* This one may appear anywhere multiple times. */ + if (actions->type == RTE_FLOW_ACTION_TYPE_VOID) + continue; + /* Fate-deciding actions may appear exactly once. */ + if (is_specified) { + rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, + actions, + "Cannot combine several fate-deciding actions," + "choose between QUEUE, RSS or DROP"); + return -rte_errno; + } switch (actions->type) { - case RTE_FLOW_ACTION_TYPE_VOID: - break; - case RTE_FLOW_ACTION_TYPE_QUEUE: rc = sfc_flow_parse_queue(sa, actions->conf, flow); if (rc != 0) { @@ -1513,11 +1522,10 @@ sfc_flow_parse_actions(struct sfc_adapter *sa, } } + /* When fate is unknown, drop traffic. */ if (!is_specified) { - rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ACTION_NUM, actions, - "Action is unspecified"); - return -rte_errno; + flow->spec.template.efs_dmaq_id = + EFX_FILTER_SPEC_RX_DMAQ_ID_DROP; } return 0; diff --git a/drivers/net/tap/tap_flow.c b/drivers/net/tap/tap_flow.c index 551b2d83d..aea3462a6 100644 --- a/drivers/net/tap/tap_flow.c +++ b/drivers/net/tap/tap_flow.c @@ -1140,6 +1140,7 @@ priv_flow_process(struct pmd_internals *pmd, else goto end; } +actions: for (; actions->type != RTE_FLOW_ACTION_TYPE_END; ++actions) { int err = 0; @@ -1222,6 +1223,16 @@ priv_flow_process(struct pmd_internals *pmd, if (err) goto exit_action_not_supported; } + /* When fate is unknown, drop traffic. */ + if (!action) { + static const struct rte_flow_action drop[] = { + { .type = RTE_FLOW_ACTION_TYPE_DROP, }, + { .type = RTE_FLOW_ACTION_TYPE_END, }, + }; + + actions = drop; + goto actions; + } end: if (flow) tap_nlattr_nested_finish(&flow->msg); /* nested TCA_OPTIONS */ diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index aab637a2c..db34049ff 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -859,32 +859,27 @@ struct rte_flow_item { * * Each possible action is represented by a type. Some have associated * configuration structures. Several actions combined in a list can be - * affected to a flow rule. That list is not ordered. + * assigned to a flow rule and are performed in order. * * They fall in three categories: * - * - Terminating actions that prevent processing matched packets by - * subsequent flow rules, unless overridden with PASSTHRU. + * - Actions that modify the fate of matching traffic, for instance by + * dropping or assigning it a specific destination. * - * - Non terminating actions that leave matched packets up for additional - * processing by subsequent flow rules. + * - Actions that modify matching traffic contents or its properties. This + * includes adding/removing encapsulation, encryption, compression and + * marks. * - * - Other non terminating meta actions that do not affect the fate of - * packets. + * - Actions related to the flow rule itself, such as updating counters or + * making it non-terminating. * - * When several actions are combined in a flow rule, they should all have - * different types (e.g. dropping a packet twice is not possible). + * Flow rules being terminating by default, not specifying any action of the + * fate type implicitly drops matching traffic. * - * Only the last action of a given type is taken into account. PMDs still - * perform error checking on the entire list. - * - * Note that PASSTHRU is the only action able to override a terminating - * rule. + * PASSTHRU, when supported, makes a flow rule non-terminating. */ enum rte_flow_action_type { /** - * [META] - * * End marker for action lists. Prevents further processing of * actions, thereby ending the list. * @@ -893,8 +888,6 @@ enum rte_flow_action_type { RTE_FLOW_ACTION_TYPE_END, /** - * [META] - * * Used as a placeholder for convenience. It is ignored and simply * discarded by PMDs. * @@ -903,18 +896,14 @@ enum rte_flow_action_type { RTE_FLOW_ACTION_TYPE_VOID, /** - * Leaves packets up for additional processing by subsequent flow - * rules. This is the default when a rule does not contain a - * terminating action, but can be specified to force a rule to - * become non-terminating. + * Leaves traffic up for additional processing by subsequent flow + * rules; makes a flow rule non-terminating. * * No associated configuration structure. */ RTE_FLOW_ACTION_TYPE_PASSTHRU, /** - * [META] - * * Attaches an integer value to packets and sets PKT_RX_FDIR and * PKT_RX_FDIR_ID mbuf flags. * @@ -923,8 +912,6 @@ enum rte_flow_action_type { RTE_FLOW_ACTION_TYPE_MARK, /** - * [META] - * * Flags packets. Similar to MARK without a specific value; only * sets the PKT_RX_FDIR mbuf flag. * @@ -949,9 +936,7 @@ enum rte_flow_action_type { RTE_FLOW_ACTION_TYPE_DROP, /** - * [META] - * - * Enables counters for this rule. + * Enables counters for this flow rule. * * These counters can be retrieved and reset through rte_flow_query(), * see struct rte_flow_query_count. @@ -1020,8 +1005,6 @@ struct rte_flow_action_mark { * RTE_FLOW_ACTION_TYPE_QUEUE * * Assign packets to a given queue index. - * - * Terminating by default. */ struct rte_flow_action_queue { uint16_t index; /**< Queue index to use. */ @@ -1050,8 +1033,6 @@ struct rte_flow_query_count { * Note: RSS hash result is stored in the hash.rss mbuf field which overlaps * hash.fdir.lo. Since the MARK action sets the hash.fdir.hi field only, * both can be requested simultaneously. - * - * Terminating by default. */ struct rte_flow_action_rss { const struct rte_eth_rss_conf *rss_conf; /**< RSS parameters. */ @@ -1069,8 +1050,6 @@ struct rte_flow_action_rss { * and is not guaranteed to work properly if the VF part is matched by a * prior flow rule or if packets are not addressed to a VF in the first * place. - * - * Terminating by default. */ struct rte_flow_action_vf { uint32_t original:1; /**< Use original VF ID if possible. */ @@ -1085,8 +1064,6 @@ struct rte_flow_action_vf { * * Packets matched by items of this type can be either dropped or passed to the * next item with their color set by the MTR object. - * - * Non-terminating by default. */ struct rte_flow_action_meter { uint32_t mtr_id; /**< MTR object ID created with rte_mtr_create(). */ @@ -1116,8 +1093,6 @@ struct rte_flow_action_meter { * direction. * * Multiple flows can be configured to use the same security session. - * - * Non-terminating by default. */ struct rte_flow_action_security { void *security_session; /**< Pointer to security session structure. */ -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v1 07/16] ethdev: remove C99 flexible arrays from flow API 2018-04-04 15:56 [dpdk-dev] [PATCH v1 00/16] Flow API overhaul for switch offloads Adrien Mazarguil ` (5 preceding siblings ...) 2018-04-04 15:56 ` [dpdk-dev] [PATCH v1 06/16] ethdev: alter behavior of flow API actions Adrien Mazarguil @ 2018-04-04 15:56 ` Adrien Mazarguil 2018-04-04 15:56 ` [dpdk-dev] [PATCH v1 08/16] ethdev: flatten RSS configuration in " Adrien Mazarguil ` (9 subsequent siblings) 16 siblings, 0 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-04 15:56 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev This patch replaces C99-style flexible arrays in struct rte_flow_action_rss and struct rte_flow_item_raw with standard pointers to the same data. They proved difficult to use in the field (e.g. no possibility of static initialization) and unsuitable for C++ applications. Affected PMDs and examples are updated accordingly. Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> --- app/test-pmd/cmdline_flow.c | 119 +++++++++++++++++--------------- app/test-pmd/config.c | 25 ++++--- doc/guides/prog_guide/rte_flow.rst | 18 ++--- drivers/net/mlx4/mlx4_flow.c | 22 +++--- drivers/net/mlx5/mlx5_flow.c | 20 +++--- examples/ipsec-secgw/ipsec.c | 17 ++--- lib/librte_ether/rte_flow.c | 25 ++++--- lib/librte_ether/rte_flow.h | 8 ++- 8 files changed, 136 insertions(+), 118 deletions(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 9702b3ef3..16227e752 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -179,25 +179,22 @@ enum index { ACTION_METER_ID, }; -/** Size of pattern[] field in struct rte_flow_item_raw. */ -#define ITEM_RAW_PATTERN_SIZE 36 +/** Maximum size for pattern in struct rte_flow_item_raw. */ +#define ITEM_RAW_PATTERN_SIZE 40 /** Storage size for struct rte_flow_item_raw including pattern. */ #define ITEM_RAW_SIZE \ - (offsetof(struct rte_flow_item_raw, pattern) + ITEM_RAW_PATTERN_SIZE) + (sizeof(struct rte_flow_item_raw) + ITEM_RAW_PATTERN_SIZE) /** Maximum number of queue indices in struct rte_flow_action_rss. */ #define ACTION_RSS_QUEUE_NUM 32 /** Storage for struct rte_flow_action_rss including external data. */ -union action_rss_data { +struct action_rss_data { struct rte_flow_action_rss conf; - struct { - uint8_t conf_data[offsetof(struct rte_flow_action_rss, queue)]; - uint16_t queue[ACTION_RSS_QUEUE_NUM]; - struct rte_eth_rss_conf rss_conf; - uint8_t rss_key[RSS_HASH_KEY_LENGTH]; - } s; + uint16_t queue[ACTION_RSS_QUEUE_NUM]; + struct rte_eth_rss_conf rss_conf; + uint8_t rss_key[RSS_HASH_KEY_LENGTH]; }; /** Maximum number of subsequent tokens and arguments on the stack. */ @@ -320,13 +317,6 @@ struct token { .size = sizeof(*((s *)0)->f), \ }) -/** Static initializer for ARGS() with arbitrary size. */ -#define ARGS_ENTRY_USZ(s, f, sz) \ - (&(const struct arg){ \ - .offset = offsetof(s, f), \ - .size = (sz), \ - }) - /** Static initializer for ARGS() with arbitrary offset and size. */ #define ARGS_ENTRY_ARB(o, s) \ (&(const struct arg){ \ @@ -1105,9 +1095,9 @@ static const struct token token_list[] = { NEXT_ENTRY(ITEM_PARAM_IS, ITEM_PARAM_SPEC, ITEM_PARAM_MASK)), - .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, length), - ARGS_ENTRY_USZ(struct rte_flow_item_raw, - pattern, + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, pattern), + ARGS_ENTRY(struct rte_flow_item_raw, length), + ARGS_ENTRY_ARB(sizeof(struct rte_flow_item_raw), ITEM_RAW_PATTERN_SIZE)), }, [ITEM_ETH] = { @@ -1591,7 +1581,7 @@ static const struct token token_list[] = { [ACTION_RSS] = { .name = "rss", .help = "spread packets among several queues", - .priv = PRIV_ACTION(RSS, sizeof(union action_rss_data)), + .priv = PRIV_ACTION(RSS, sizeof(struct action_rss_data)), .next = NEXT(action_rss), .call = parse_vc_action_rss, }, @@ -1610,23 +1600,21 @@ static const struct token token_list[] = { .name = "key", .help = "RSS hash key", .next = NEXT(action_rss, NEXT_ENTRY(STRING)), - .args = ARGS(ARGS_ENTRY_ARB - (((uintptr_t)&((union action_rss_data *)0)-> - s.rss_conf.rss_key_len), + .args = ARGS(ARGS_ENTRY_ARB(0, 0), + ARGS_ENTRY_ARB + (offsetof(struct action_rss_data, rss_conf) + + offsetof(struct rte_eth_rss_conf, rss_key_len), sizeof(((struct rte_eth_rss_conf *)0)-> rss_key_len)), - ARGS_ENTRY_ARB - (((uintptr_t)((union action_rss_data *)0)-> - s.rss_key), - RSS_HASH_KEY_LENGTH)), + ARGS_ENTRY(struct action_rss_data, rss_key)), }, [ACTION_RSS_KEY_LEN] = { .name = "key_len", .help = "RSS hash key length in bytes", .next = NEXT(action_rss, NEXT_ENTRY(UNSIGNED)), .args = ARGS(ARGS_ENTRY_ARB_BOUNDED - (((uintptr_t)&((union action_rss_data *)0)-> - s.rss_conf.rss_key_len), + (offsetof(struct action_rss_data, rss_conf) + + offsetof(struct rte_eth_rss_conf, rss_key_len), sizeof(((struct rte_eth_rss_conf *)0)-> rss_key_len), 0, @@ -2067,7 +2055,7 @@ parse_vc_action_rss(struct context *ctx, const struct token *token, { struct buffer *out = buf; struct rte_flow_action *action; - union action_rss_data *action_rss_data; + struct action_rss_data *action_rss_data; unsigned int i; int ret; @@ -2085,31 +2073,31 @@ parse_vc_action_rss(struct context *ctx, const struct token *token, ctx->objmask = NULL; /* Set up default configuration. */ action_rss_data = ctx->object; - *action_rss_data = (union action_rss_data){ + *action_rss_data = (struct action_rss_data){ .conf = (struct rte_flow_action_rss){ - .rss_conf = &action_rss_data->s.rss_conf, + .rss_conf = &action_rss_data->rss_conf, .num = RTE_MIN(nb_rxq, ACTION_RSS_QUEUE_NUM), + .queue = action_rss_data->queue, }, + .queue = { 0 }, + .rss_conf = (struct rte_eth_rss_conf){ + .rss_key = action_rss_data->rss_key, + .rss_key_len = sizeof(action_rss_data->rss_key), + .rss_hf = rss_hf, + }, + .rss_key = "testpmd's default RSS hash key", }; - action_rss_data->s.rss_conf = (struct rte_eth_rss_conf){ - .rss_key = action_rss_data->s.rss_key, - .rss_key_len = sizeof(action_rss_data->s.rss_key), - .rss_hf = rss_hf, - }; - strncpy((void *)action_rss_data->s.rss_key, - "testpmd's default RSS hash key", - sizeof(action_rss_data->s.rss_key)); for (i = 0; i < action_rss_data->conf.num; ++i) - action_rss_data->conf.queue[i] = i; + action_rss_data->queue[i] = i; if (!port_id_is_invalid(ctx->port, DISABLED_WARN) && ctx->port != (portid_t)RTE_PORT_ALL) { if (rte_eth_dev_rss_hash_conf_get - (ctx->port, &action_rss_data->s.rss_conf) < 0) { + (ctx->port, &action_rss_data->rss_conf) < 0) { struct rte_eth_dev_info info; rte_eth_dev_info_get(ctx->port, &info); - action_rss_data->s.rss_conf.rss_key_len = - RTE_MIN(sizeof(action_rss_data->s.rss_key), + action_rss_data->rss_conf.rss_key_len = + RTE_MIN(sizeof(action_rss_data->rss_key), info.hash_key_size); } } @@ -2128,7 +2116,7 @@ parse_vc_action_rss_type(struct context *ctx, const struct token *token, void *buf, unsigned int size) { static const enum index next[] = NEXT_ENTRY(ACTION_RSS_TYPE); - union action_rss_data *action_rss_data; + struct action_rss_data *action_rss_data; unsigned int i; (void)token; @@ -2138,7 +2126,7 @@ parse_vc_action_rss_type(struct context *ctx, const struct token *token, return -1; if (!(ctx->objdata >> 16) && ctx->object) { action_rss_data = ctx->object; - action_rss_data->s.rss_conf.rss_hf = 0; + action_rss_data->rss_conf.rss_hf = 0; } if (!strcmp_partial("end", str, len)) { ctx->objdata &= 0xffff; @@ -2157,7 +2145,7 @@ parse_vc_action_rss_type(struct context *ctx, const struct token *token, if (!ctx->object) return len; action_rss_data = ctx->object; - action_rss_data->s.rss_conf.rss_hf |= rss_type_table[i].rss_type; + action_rss_data->rss_conf.rss_hf |= rss_type_table[i].rss_type; return len; } @@ -2172,7 +2160,7 @@ parse_vc_action_rss_queue(struct context *ctx, const struct token *token, void *buf, unsigned int size) { static const enum index next[] = NEXT_ENTRY(ACTION_RSS_QUEUE); - union action_rss_data *action_rss_data; + struct action_rss_data *action_rss_data; int ret; int i; @@ -2189,10 +2177,9 @@ parse_vc_action_rss_queue(struct context *ctx, const struct token *token, if (i >= ACTION_RSS_QUEUE_NUM) return -1; if (push_args(ctx, - ARGS_ENTRY_ARB(offsetof(struct rte_flow_action_rss, - queue) + - i * sizeof(action_rss_data->s.queue[i]), - sizeof(action_rss_data->s.queue[i])))) + ARGS_ENTRY_ARB(offsetof(struct action_rss_data, queue) + + i * sizeof(action_rss_data->queue[i]), + sizeof(action_rss_data->queue[i])))) return -1; ret = parse_int(ctx, token, str, len, NULL, 0); if (ret < 0) { @@ -2209,6 +2196,7 @@ parse_vc_action_rss_queue(struct context *ctx, const struct token *token, return len; action_rss_data = ctx->object; action_rss_data->conf.num = i; + action_rss_data->conf.queue = i ? action_rss_data->queue : NULL; return len; } @@ -2486,8 +2474,8 @@ parse_int(struct context *ctx, const struct token *token, /** * Parse a string. * - * Two arguments (ctx->args) are retrieved from the stack to store data and - * its length (in that order). + * Three arguments (ctx->args) are retrieved from the stack to store data, + * its actual length and address (in that order). */ static int parse_string(struct context *ctx, const struct token *token, @@ -2496,6 +2484,7 @@ parse_string(struct context *ctx, const struct token *token, { const struct arg *arg_data = pop_args(ctx); const struct arg *arg_len = pop_args(ctx); + const struct arg *arg_addr = pop_args(ctx); char tmp[16]; /* Ought to be enough. */ int ret; @@ -2506,6 +2495,11 @@ parse_string(struct context *ctx, const struct token *token, push_args(ctx, arg_data); return -1; } + if (!arg_addr) { + push_args(ctx, arg_len); + push_args(ctx, arg_data); + return -1; + } size = arg_data->size; /* Bit-mask fill is not supported. */ if (arg_data->mask || size < len) @@ -2528,8 +2522,23 @@ parse_string(struct context *ctx, const struct token *token, memset((uint8_t *)buf + len, 0x00, size - len); if (ctx->objmask) memset((uint8_t *)ctx->objmask + arg_data->offset, 0xff, len); + /* Save address if requested. */ + if (arg_addr->size) { + memcpy((uint8_t *)ctx->object + arg_addr->offset, + (void *[]){ + (uint8_t *)ctx->object + arg_data->offset + }, + arg_addr->size); + if (ctx->objmask) + memcpy((uint8_t *)ctx->objmask + arg_addr->offset, + (void *[]){ + (uint8_t *)ctx->objmask + arg_data->offset + }, + arg_addr->size); + } return len; error: + push_args(ctx, arg_addr); push_args(ctx, arg_len); push_args(ctx, arg_data); return -1; diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 8d42ea9a9..052163357 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -961,7 +961,7 @@ static const struct { MK_FLOW_ITEM(PF, 0), MK_FLOW_ITEM(VF, sizeof(struct rte_flow_item_vf)), MK_FLOW_ITEM(PORT, sizeof(struct rte_flow_item_port)), - MK_FLOW_ITEM(RAW, sizeof(struct rte_flow_item_raw)), /* +pattern[] */ + MK_FLOW_ITEM(RAW, sizeof(struct rte_flow_item_raw)), MK_FLOW_ITEM(ETH, sizeof(struct rte_flow_item_eth)), MK_FLOW_ITEM(VLAN, sizeof(struct rte_flow_item_vlan)), MK_FLOW_ITEM(IPV4, sizeof(struct rte_flow_item_ipv4)), @@ -1010,14 +1010,20 @@ flow_item_spec_copy(void *buf, const struct rte_flow_item *item, union { struct rte_flow_item_raw *raw; } dst; + size_t off; case RTE_FLOW_ITEM_TYPE_RAW: src.raw = item_spec; dst.raw = buf; - size = offsetof(struct rte_flow_item_raw, pattern) + - src.raw->length * sizeof(*src.raw->pattern); - if (dst.raw) - memcpy(dst.raw, src.raw, size); + off = RTE_ALIGN_CEIL(sizeof(struct rte_flow_item_raw), + sizeof(*src.raw->pattern)); + size = off + src.raw->length * sizeof(*src.raw->pattern); + if (dst.raw) { + memcpy(dst.raw, src.raw, sizeof(*src.raw)); + dst.raw->pattern = memcpy((uint8_t *)dst.raw + off, + src.raw->pattern, + size - off); + } break; default: size = flow_item[item->type].size; @@ -1049,7 +1055,7 @@ static const struct { MK_FLOW_ACTION(QUEUE, sizeof(struct rte_flow_action_queue)), MK_FLOW_ACTION(DROP, 0), MK_FLOW_ACTION(COUNT, 0), - MK_FLOW_ACTION(RSS, sizeof(struct rte_flow_action_rss)), /* +queue[] */ + MK_FLOW_ACTION(RSS, sizeof(struct rte_flow_action_rss)), MK_FLOW_ACTION(PF, 0), MK_FLOW_ACTION(VF, sizeof(struct rte_flow_action_vf)), MK_FLOW_ACTION(METER, sizeof(struct rte_flow_action_meter)), @@ -1080,11 +1086,14 @@ flow_action_conf_copy(void *buf, const struct rte_flow_action *action) *dst.rss = (struct rte_flow_action_rss){ .num = src.rss->num, }; - off += offsetof(struct rte_flow_action_rss, queue); + off += sizeof(*src.rss); if (src.rss->num) { + off = RTE_ALIGN_CEIL(off, sizeof(double)); size = sizeof(*src.rss->queue) * src.rss->num; if (dst.rss) - memcpy(dst.rss->queue, src.rss->queue, size); + dst.rss->queue = memcpy + ((void *)((uintptr_t)dst.rss + off), + src.rss->queue, size); off += size; } off = RTE_ALIGN_CEIL(off, sizeof(double)); diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 8f3700cdb..f00fd1a71 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -1308,15 +1308,15 @@ field only, both can be requested simultaneously. .. table:: RSS - +--------------+------------------------------+ - | Field | Value | - +==============+==============================+ - | ``rss_conf`` | RSS parameters | - +--------------+------------------------------+ - | ``num`` | number of entries in queue[] | - +--------------+------------------------------+ - | ``queue[]`` | queue indices to use | - +--------------+------------------------------+ + +--------------+--------------------------------+ + | Field | Value | + +==============+================================+ + | ``rss_conf`` | RSS parameters | + +--------------+--------------------------------+ + | ``num`` | number of entries in ``queue`` | + +--------------+--------------------------------+ + | ``queue`` | queue indices to use | + +--------------+--------------------------------+ Action: ``PF`` ^^^^^^^^^^^^^^ diff --git a/drivers/net/mlx4/mlx4_flow.c b/drivers/net/mlx4/mlx4_flow.c index 582483076..5a1b7dedd 100644 --- a/drivers/net/mlx4/mlx4_flow.c +++ b/drivers/net/mlx4/mlx4_flow.c @@ -1282,14 +1282,16 @@ mlx4_flow_internal(struct priv *priv, struct rte_flow_error *error) */ uint32_t queues = rte_align32pow2(priv->dev->data->nb_rx_queues + 1) >> 1; - alignas(struct rte_flow_action_rss) uint8_t rss_conf_data - [offsetof(struct rte_flow_action_rss, queue) + - sizeof(((struct rte_flow_action_rss *)0)->queue[0]) * queues]; - struct rte_flow_action_rss *rss_conf = (void *)rss_conf_data; + uint16_t queue[queues]; + struct rte_flow_action_rss action_rss = { + .rss_conf = NULL, /* Rely on default fallback settings. */ + .num = queues, + .queue = queue, + }; struct rte_flow_action actions[] = { { .type = RTE_FLOW_ACTION_TYPE_RSS, - .conf = rss_conf, + .conf = &action_rss, }, { .type = RTE_FLOW_ACTION_TYPE_END, @@ -1311,12 +1313,8 @@ mlx4_flow_internal(struct priv *priv, struct rte_flow_error *error) if (!queues) goto error; /* Prepare default RSS configuration. */ - *rss_conf = (struct rte_flow_action_rss){ - .rss_conf = NULL, /* Rely on default fallback settings. */ - .num = queues, - }; for (i = 0; i != queues; ++i) - rss_conf->queue[i] = i; + queue[i] = i; /* * Set up VLAN item if filtering is enabled and at least one VLAN * filter is configured. @@ -1375,7 +1373,7 @@ mlx4_flow_internal(struct priv *priv, struct rte_flow_error *error) if (j != sizeof(mac->addr_bytes)) continue; if (flow->rss->queues != queues || - memcmp(flow->rss->queue_id, rss_conf->queue, + memcmp(flow->rss->queue_id, action_rss.queue, queues * sizeof(flow->rss->queue_id[0]))) continue; break; @@ -1415,7 +1413,7 @@ mlx4_flow_internal(struct priv *priv, struct rte_flow_error *error) if (flow && flow->internal) { assert(flow->rss); if (flow->rss->queues != queues || - memcmp(flow->rss->queue_id, rss_conf->queue, + memcmp(flow->rss->queue_id, action_rss.queue, queues * sizeof(flow->rss->queue_id[0]))) flow = NULL; } diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 84d6f9b92..a52dcf263 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -2446,9 +2446,16 @@ mlx5_ctrl_flow_vlan(struct rte_eth_dev *dev, .type = RTE_FLOW_ITEM_TYPE_END, }, }; + uint16_t queue[priv->reta_idx_n]; + struct rte_flow_action_rss action_rss = { + .rss_conf = &priv->rss_conf, + .num = priv->reta_idx_n, + .queue = queue, + }; struct rte_flow_action actions[] = { { .type = RTE_FLOW_ACTION_TYPE_RSS, + .conf = &action_rss, }, { .type = RTE_FLOW_ACTION_TYPE_END, @@ -2457,24 +2464,13 @@ mlx5_ctrl_flow_vlan(struct rte_eth_dev *dev, struct rte_flow *flow; struct rte_flow_error error; unsigned int i; - union { - struct rte_flow_action_rss rss; - struct { - const struct rte_eth_rss_conf *rss_conf; - uint16_t num; - uint16_t queue[RTE_MAX_QUEUES_PER_PORT]; - } local; - } action_rss; if (!priv->reta_idx_n) { rte_errno = EINVAL; return -rte_errno; } for (i = 0; i != priv->reta_idx_n; ++i) - action_rss.local.queue[i] = (*priv->reta_idx)[i]; - action_rss.local.rss_conf = &priv->rss_conf; - action_rss.local.num = priv->reta_idx_n; - actions[0].conf = (const void *)&action_rss.rss; + queue[i] = (*priv->reta_idx)[i]; flow = mlx5_flow_list_create(dev, &priv->ctrl_flows, &attr, items, actions, &error); if (!flow) diff --git a/examples/ipsec-secgw/ipsec.c b/examples/ipsec-secgw/ipsec.c index 5fb5bc16e..8b2047adb 100644 --- a/examples/ipsec-secgw/ipsec.c +++ b/examples/ipsec-secgw/ipsec.c @@ -186,14 +186,8 @@ create_session(struct ipsec_ctx *ipsec_ctx, struct ipsec_sa *sa) .rss_key_len = 40, }; struct rte_eth_dev *eth_dev; - union { - struct rte_flow_action_rss rss; - struct { - const struct rte_eth_rss_conf *rss_conf; - uint16_t num; - uint16_t queue[RTE_MAX_QUEUES_PER_PORT]; - } local; - } action_rss; + uint16_t queue[RTE_MAX_QUEUES_PER_PORT]; + struct rte_flow_action_rss action_rss; unsigned int i; unsigned int j; @@ -207,9 +201,10 @@ create_session(struct ipsec_ctx *ipsec_ctx, struct ipsec_sa *sa) for (i = 0, j = 0; i < eth_dev->data->nb_rx_queues; ++i) if (eth_dev->data->rx_queues[i]) - action_rss.local.queue[j++] = i; - action_rss.local.num = j; - action_rss.local.rss_conf = &rss_conf; + queue[j++] = i; + action_rss.rss_conf = &rss_conf; + action_rss.num = j; + action_rss.queue = queue; ret = rte_flow_validate(sa->portid, &sa->attr, sa->pattern, sa->action, &err); diff --git a/lib/librte_ether/rte_flow.c b/lib/librte_ether/rte_flow.c index db04c4f94..550086411 100644 --- a/lib/librte_ether/rte_flow.c +++ b/lib/librte_ether/rte_flow.c @@ -39,7 +39,7 @@ static const struct rte_flow_desc_data rte_flow_desc_item[] = { MK_FLOW_ITEM(PF, 0), MK_FLOW_ITEM(VF, sizeof(struct rte_flow_item_vf)), MK_FLOW_ITEM(PORT, sizeof(struct rte_flow_item_port)), - MK_FLOW_ITEM(RAW, sizeof(struct rte_flow_item_raw)), /* +pattern[] */ + MK_FLOW_ITEM(RAW, sizeof(struct rte_flow_item_raw)), MK_FLOW_ITEM(ETH, sizeof(struct rte_flow_item_eth)), MK_FLOW_ITEM(VLAN, sizeof(struct rte_flow_item_vlan)), MK_FLOW_ITEM(IPV4, sizeof(struct rte_flow_item_ipv4)), @@ -73,7 +73,7 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = { MK_FLOW_ACTION(QUEUE, sizeof(struct rte_flow_action_queue)), MK_FLOW_ACTION(DROP, 0), MK_FLOW_ACTION(COUNT, 0), - MK_FLOW_ACTION(RSS, sizeof(struct rte_flow_action_rss)), /* +queue[] */ + MK_FLOW_ACTION(RSS, sizeof(struct rte_flow_action_rss)), MK_FLOW_ACTION(PF, 0), MK_FLOW_ACTION(VF, sizeof(struct rte_flow_action_vf)), }; @@ -282,14 +282,20 @@ flow_item_spec_copy(void *buf, const struct rte_flow_item *item, union { struct rte_flow_item_raw *raw; } dst; + size_t off; case RTE_FLOW_ITEM_TYPE_RAW: src.raw = item_spec; dst.raw = buf; - size = offsetof(struct rte_flow_item_raw, pattern) + - src.raw->length * sizeof(*src.raw->pattern); - if (dst.raw) - memcpy(dst.raw, src.raw, size); + off = RTE_ALIGN_CEIL(sizeof(struct rte_flow_item_raw), + sizeof(*src.raw->pattern)); + size = off + src.raw->length * sizeof(*src.raw->pattern); + if (dst.raw) { + memcpy(dst.raw, src.raw, sizeof(*src.raw)); + dst.raw->pattern = memcpy((uint8_t *)dst.raw + off, + src.raw->pattern, + size - off); + } break; default: size = rte_flow_desc_item[item->type].size; @@ -326,11 +332,14 @@ flow_action_conf_copy(void *buf, const struct rte_flow_action *action) *dst.rss = (struct rte_flow_action_rss){ .num = src.rss->num, }; - off += offsetof(struct rte_flow_action_rss, queue); + off += sizeof(*src.rss); if (src.rss->num) { + off = RTE_ALIGN_CEIL(off, sizeof(double)); size = sizeof(*src.rss->queue) * src.rss->num; if (dst.rss) - memcpy(dst.rss->queue, src.rss->queue, size); + dst.rss->queue = memcpy + ((void *)((uintptr_t)dst.rss + off), + src.rss->queue, size); off += size; } off = RTE_ALIGN_CEIL(off, sizeof(double)); diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index db34049ff..532a9edab 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -14,6 +14,7 @@ * associated actions in hardware through flow rules. */ +#include <stddef.h> #include <stdint.h> #include <rte_arp.h> @@ -432,7 +433,7 @@ struct rte_flow_item_raw { int32_t offset; /**< Absolute or relative offset for pattern. */ uint16_t limit; /**< Search area limit for start of pattern. */ uint16_t length; /**< Pattern length. */ - uint8_t pattern[]; /**< Byte string to look for. */ + const uint8_t *pattern; /**< Byte string to look for. */ }; /** Default mask for RTE_FLOW_ITEM_TYPE_RAW. */ @@ -444,6 +445,7 @@ static const struct rte_flow_item_raw rte_flow_item_raw_mask = { .offset = 0xffffffff, .limit = 0xffff, .length = 0xffff, + .pattern = NULL, }; #endif @@ -1036,8 +1038,8 @@ struct rte_flow_query_count { */ struct rte_flow_action_rss { const struct rte_eth_rss_conf *rss_conf; /**< RSS parameters. */ - uint16_t num; /**< Number of entries in queue[]. */ - uint16_t queue[]; /**< Queues indices to use. */ + uint16_t num; /**< Number of entries in @p queue. */ + const uint16_t *queue; /**< Queue indices to use. */ }; /** -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v1 08/16] ethdev: flatten RSS configuration in flow API 2018-04-04 15:56 [dpdk-dev] [PATCH v1 00/16] Flow API overhaul for switch offloads Adrien Mazarguil ` (6 preceding siblings ...) 2018-04-04 15:56 ` [dpdk-dev] [PATCH v1 07/16] ethdev: remove C99 flexible arrays from flow API Adrien Mazarguil @ 2018-04-04 15:56 ` Adrien Mazarguil 2018-04-04 15:56 ` [dpdk-dev] [PATCH v1 09/16] ethdev: add hash function to RSS flow API action Adrien Mazarguil ` (8 subsequent siblings) 16 siblings, 0 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-04 15:56 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev Cc: Xueming Li, Wenzhuo Lu, Jingjing Wu, Beilei Xing, Qi Zhang, Konstantin Ananyev, Nelio Laranjeiro, Yongseok Koh, Andrew Rybchenko, Pascal Mazon, Radu Nicolau, Akhil Goyal Since its inception, the rte_flow RSS action has been relying in part on external struct rte_eth_rss_conf for compatibility with the legacy RSS API. This structure lacks parameters such as the hash algorithm to use, and more recently, a method to tell which layer RSS should be performed on [1]. Given struct rte_eth_rss_conf will never be flexible enough to represent a complete RSS configuration (e.g. RETA table), this patch supersedes it by extending the rte_flow RSS action directly. A subsequent patch will add a field to use a non-default RSS hash algorithm. To that end, a field named "types" replaces the field formerly known as "rss_hf" and standing for "RSS hash functions" as it was confusing. Actual RSS hash function types are defined by enum rte_eth_hash_function. This patch updates all PMDs and example applications accordingly. [1] commit 676b605182a5 ("doc: announce ethdev API change for RSS configuration") Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Cc: Xueming Li <xuemingl@mellanox.com> Cc: Ferruh Yigit <ferruh.yigit@intel.com> Cc: Thomas Monjalon <thomas@monjalon.net> Cc: Wenzhuo Lu <wenzhuo.lu@intel.com> Cc: Jingjing Wu <jingjing.wu@intel.com> Cc: Beilei Xing <beilei.xing@intel.com> Cc: Qi Zhang <qi.z.zhang@intel.com> Cc: Konstantin Ananyev <konstantin.ananyev@intel.com> Cc: Nelio Laranjeiro <nelio.laranjeiro@6wind.com> Cc: Yongseok Koh <yskoh@mellanox.com> Cc: Andrew Rybchenko <arybchenko@solarflare.com> Cc: Pascal Mazon <pascal.mazon@6wind.com> Cc: Radu Nicolau <radu.nicolau@intel.com> Cc: Akhil Goyal <akhil.goyal@nxp.com> --- app/test-pmd/cmdline_flow.c | 59 +++++----- app/test-pmd/config.c | 39 +++---- doc/guides/prog_guide/rte_flow.rst | 22 ++-- drivers/net/e1000/e1000_ethdev.h | 13 ++- drivers/net/e1000/igb_ethdev.c | 4 +- drivers/net/e1000/igb_flow.c | 31 ++--- drivers/net/e1000/igb_rxtx.c | 51 +++++++-- drivers/net/i40e/i40e_ethdev.c | 53 +++++++-- drivers/net/i40e/i40e_ethdev.h | 15 ++- drivers/net/i40e/i40e_flow.c | 47 ++++---- drivers/net/ixgbe/ixgbe_ethdev.c | 4 +- drivers/net/ixgbe/ixgbe_ethdev.h | 13 ++- drivers/net/ixgbe/ixgbe_flow.c | 30 ++--- drivers/net/ixgbe/ixgbe_rxtx.c | 51 +++++++-- drivers/net/mlx4/mlx4.c | 2 +- drivers/net/mlx4/mlx4_flow.c | 61 +++++----- drivers/net/mlx4/mlx4_flow.h | 2 +- drivers/net/mlx4/mlx4_rxq.c | 2 +- drivers/net/mlx4/mlx4_rxtx.h | 2 +- drivers/net/mlx5/mlx5_flow.c | 193 +++++++++++++++----------------- drivers/net/mlx5/mlx5_rxq.c | 22 ++-- drivers/net/mlx5/mlx5_rxtx.h | 26 +++-- drivers/net/sfc/sfc_flow.c | 21 ++-- drivers/net/tap/tap_flow.c | 8 +- examples/ipsec-secgw/ipsec.c | 10 +- lib/librte_ether/rte_flow.c | 39 +++---- lib/librte_ether/rte_flow.h | 6 +- 27 files changed, 473 insertions(+), 353 deletions(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 16227e752..0322f36c4 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -192,9 +192,8 @@ enum index { /** Storage for struct rte_flow_action_rss including external data. */ struct action_rss_data { struct rte_flow_action_rss conf; + uint8_t key[RSS_HASH_KEY_LENGTH]; uint16_t queue[ACTION_RSS_QUEUE_NUM]; - struct rte_eth_rss_conf rss_conf; - uint8_t rss_key[RSS_HASH_KEY_LENGTH]; }; /** Maximum number of subsequent tokens and arguments on the stack. */ @@ -1602,21 +1601,21 @@ static const struct token token_list[] = { .next = NEXT(action_rss, NEXT_ENTRY(STRING)), .args = ARGS(ARGS_ENTRY_ARB(0, 0), ARGS_ENTRY_ARB - (offsetof(struct action_rss_data, rss_conf) + - offsetof(struct rte_eth_rss_conf, rss_key_len), - sizeof(((struct rte_eth_rss_conf *)0)-> - rss_key_len)), - ARGS_ENTRY(struct action_rss_data, rss_key)), + (offsetof(struct action_rss_data, conf) + + offsetof(struct rte_flow_action_rss, key_len), + sizeof(((struct rte_flow_action_rss *)0)-> + key_len)), + ARGS_ENTRY(struct action_rss_data, key)), }, [ACTION_RSS_KEY_LEN] = { .name = "key_len", .help = "RSS hash key length in bytes", .next = NEXT(action_rss, NEXT_ENTRY(UNSIGNED)), .args = ARGS(ARGS_ENTRY_ARB_BOUNDED - (offsetof(struct action_rss_data, rss_conf) + - offsetof(struct rte_eth_rss_conf, rss_key_len), - sizeof(((struct rte_eth_rss_conf *)0)-> - rss_key_len), + (offsetof(struct action_rss_data, conf) + + offsetof(struct rte_flow_action_rss, key_len), + sizeof(((struct rte_flow_action_rss *)0)-> + key_len), 0, RSS_HASH_KEY_LENGTH)), }, @@ -2075,30 +2074,36 @@ parse_vc_action_rss(struct context *ctx, const struct token *token, action_rss_data = ctx->object; *action_rss_data = (struct action_rss_data){ .conf = (struct rte_flow_action_rss){ - .rss_conf = &action_rss_data->rss_conf, - .num = RTE_MIN(nb_rxq, ACTION_RSS_QUEUE_NUM), + .types = rss_hf, + .key_len = sizeof(action_rss_data->key), + .queue_num = RTE_MIN(nb_rxq, ACTION_RSS_QUEUE_NUM), + .key = action_rss_data->key, .queue = action_rss_data->queue, }, + .key = "testpmd's default RSS hash key", .queue = { 0 }, - .rss_conf = (struct rte_eth_rss_conf){ - .rss_key = action_rss_data->rss_key, - .rss_key_len = sizeof(action_rss_data->rss_key), - .rss_hf = rss_hf, - }, - .rss_key = "testpmd's default RSS hash key", }; - for (i = 0; i < action_rss_data->conf.num; ++i) + for (i = 0; i < action_rss_data->conf.queue_num; ++i) action_rss_data->queue[i] = i; if (!port_id_is_invalid(ctx->port, DISABLED_WARN) && ctx->port != (portid_t)RTE_PORT_ALL) { - if (rte_eth_dev_rss_hash_conf_get - (ctx->port, &action_rss_data->rss_conf) < 0) { + struct rte_eth_rss_conf rss_conf = { + .rss_key = action_rss_data->key, + .rss_key_len = sizeof(action_rss_data->key), + }; + + if (rte_eth_dev_rss_hash_conf_get(ctx->port, &rss_conf) < 0) { struct rte_eth_dev_info info; rte_eth_dev_info_get(ctx->port, &info); - action_rss_data->rss_conf.rss_key_len = - RTE_MIN(sizeof(action_rss_data->rss_key), + action_rss_data->conf.key_len = + RTE_MIN(sizeof(action_rss_data->key), info.hash_key_size); + } else { + action_rss_data->conf.types = rss_conf.rss_hf; + action_rss_data->conf.key_len = + RTE_MIN(sizeof(action_rss_data->key), + rss_conf.rss_key_len); } } action->conf = &action_rss_data->conf; @@ -2126,7 +2131,7 @@ parse_vc_action_rss_type(struct context *ctx, const struct token *token, return -1; if (!(ctx->objdata >> 16) && ctx->object) { action_rss_data = ctx->object; - action_rss_data->rss_conf.rss_hf = 0; + action_rss_data->conf.types = 0; } if (!strcmp_partial("end", str, len)) { ctx->objdata &= 0xffff; @@ -2145,7 +2150,7 @@ parse_vc_action_rss_type(struct context *ctx, const struct token *token, if (!ctx->object) return len; action_rss_data = ctx->object; - action_rss_data->rss_conf.rss_hf |= rss_type_table[i].rss_type; + action_rss_data->conf.types |= rss_type_table[i].rss_type; return len; } @@ -2195,7 +2200,7 @@ parse_vc_action_rss_queue(struct context *ctx, const struct token *token, if (!ctx->object) return len; action_rss_data = ctx->object; - action_rss_data->conf.num = i; + action_rss_data->conf.queue_num = i; action_rss_data->conf.queue = i ? action_rss_data->queue : NULL; return len; } diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 052163357..717f31774 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -1084,40 +1084,27 @@ flow_action_conf_copy(void *buf, const struct rte_flow_action *action) off = 0; if (dst.rss) *dst.rss = (struct rte_flow_action_rss){ - .num = src.rss->num, + .types = src.rss->types, + .key_len = src.rss->key_len, + .queue_num = src.rss->queue_num, }; off += sizeof(*src.rss); - if (src.rss->num) { + if (src.rss->key_len) { off = RTE_ALIGN_CEIL(off, sizeof(double)); - size = sizeof(*src.rss->queue) * src.rss->num; + size = sizeof(*src.rss->key) * src.rss->key_len; if (dst.rss) - dst.rss->queue = memcpy + dst.rss->key = memcpy ((void *)((uintptr_t)dst.rss + off), - src.rss->queue, size); + src.rss->key, size); off += size; } - off = RTE_ALIGN_CEIL(off, sizeof(double)); - if (dst.rss) { - dst.rss->rss_conf = (void *)((uintptr_t)dst.rss + off); - *(struct rte_eth_rss_conf *)(uintptr_t) - dst.rss->rss_conf = (struct rte_eth_rss_conf){ - .rss_key_len = src.rss->rss_conf->rss_key_len, - .rss_hf = src.rss->rss_conf->rss_hf, - }; - } - off += sizeof(*src.rss->rss_conf); - if (src.rss->rss_conf->rss_key_len) { + if (src.rss->queue_num) { off = RTE_ALIGN_CEIL(off, sizeof(double)); - size = sizeof(*src.rss->rss_conf->rss_key) * - src.rss->rss_conf->rss_key_len; - if (dst.rss) { - ((struct rte_eth_rss_conf *)(uintptr_t) - dst.rss->rss_conf)->rss_key = - (void *)((uintptr_t)dst.rss + off); - memcpy(dst.rss->rss_conf->rss_key, - src.rss->rss_conf->rss_key, - size); - } + size = sizeof(*src.rss->queue) * src.rss->queue_num; + if (dst.rss) + dst.rss->queue = memcpy + ((void *)((uintptr_t)dst.rss + off), + src.rss->queue, size); off += size; } size = off; diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index f00fd1a71..a7c3d6ccc 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -1308,15 +1308,19 @@ field only, both can be requested simultaneously. .. table:: RSS - +--------------+--------------------------------+ - | Field | Value | - +==============+================================+ - | ``rss_conf`` | RSS parameters | - +--------------+--------------------------------+ - | ``num`` | number of entries in ``queue`` | - +--------------+--------------------------------+ - | ``queue`` | queue indices to use | - +--------------+--------------------------------+ + +---------------+------------------------------------+ + | Field | Value | + +===============+====================================+ + | ``types`` | RSS hash types (see ``ETH_RSS_*``) | + +---------------+------------------------------------+ + | ``key_len`` | hash key length in bytes | + +---------------+------------------------------------+ + | ``queue_num`` | number of entries in ``queue`` | + +---------------+------------------------------------+ + | ``key`` | hash key | + +---------------+------------------------------------+ + | ``queue`` | queue indices to use | + +---------------+------------------------------------+ Action: ``PF`` ^^^^^^^^^^^^^^ diff --git a/drivers/net/e1000/e1000_ethdev.h b/drivers/net/e1000/e1000_ethdev.h index 23b089c8d..960045a10 100644 --- a/drivers/net/e1000/e1000_ethdev.h +++ b/drivers/net/e1000/e1000_ethdev.h @@ -4,6 +4,10 @@ #ifndef _E1000_ETHDEV_H_ #define _E1000_ETHDEV_H_ + +#include <stdint.h> + +#include <rte_flow.h> #include <rte_time.h> #include <rte_pci.h> @@ -27,6 +31,7 @@ #define E1000_CTRL_EXT_EXTEND_VLAN (1<<26) /* EXTENDED VLAN */ #define IGB_VFTA_SIZE 128 +#define IGB_HKEY_MAX_INDEX 10 #define IGB_MAX_RX_QUEUE_NUM 8 #define IGB_MAX_RX_QUEUE_NUM_82576 16 @@ -229,8 +234,8 @@ struct igb_ethertype_filter { }; struct igb_rte_flow_rss_conf { - struct rte_eth_rss_conf rss_conf; /**< RSS parameters. */ - uint16_t num; /**< Number of entries in queue[]. */ + struct rte_flow_action_rss conf; /**< RSS parameters. */ + uint8_t key[IGB_HKEY_MAX_INDEX * sizeof(uint32_t)]; /* Hash key. */ uint16_t queue[IGB_MAX_RX_QUEUE_NUM]; /**< Queues indices to use. */ }; @@ -487,6 +492,10 @@ int eth_igb_syn_filter_set(struct rte_eth_dev *dev, int eth_igb_add_del_flex_filter(struct rte_eth_dev *dev, struct rte_eth_flex_filter *filter, bool add); +int igb_rss_conf_init(struct igb_rte_flow_rss_conf *out, + const struct rte_flow_action_rss *in); +int igb_action_rss_same(const struct rte_flow_action_rss *comp, + const struct rte_flow_action_rss *with); int igb_config_rss_filter(struct rte_eth_dev *dev, struct igb_rte_flow_rss_conf *conf, bool add); diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c index d7eef9a6c..3d1d4a170 100644 --- a/drivers/net/e1000/igb_ethdev.c +++ b/drivers/net/e1000/igb_ethdev.c @@ -41,8 +41,6 @@ #define IGB_DEFAULT_TX_HTHRESH 1 #define IGB_DEFAULT_TX_WTHRESH ((hw->mac.type == e1000_82576) ? 1 : 16) -#define IGB_HKEY_MAX_INDEX 10 - /* Bit shift and mask */ #define IGB_4_BIT_WIDTH (CHAR_BIT / 2) #define IGB_4_BIT_MASK RTE_LEN2MASK(IGB_4_BIT_WIDTH, uint8_t) @@ -5570,7 +5568,7 @@ igb_rss_filter_restore(struct rte_eth_dev *dev) struct e1000_filter_info *filter_info = E1000_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private); - if (filter_info->rss_info.num) + if (filter_info->rss_info.conf.queue_num) igb_config_rss_filter(dev, &filter_info->rss_info, TRUE); } diff --git a/drivers/net/e1000/igb_flow.c b/drivers/net/e1000/igb_flow.c index c0f5b5190..8dc5f75f2 100644 --- a/drivers/net/e1000/igb_flow.c +++ b/drivers/net/e1000/igb_flow.c @@ -1292,7 +1292,7 @@ igb_parse_rss_filter(struct rte_eth_dev *dev, rss = (const struct rte_flow_action_rss *)act->conf; - if (!rss || !rss->num) { + if (!rss || !rss->queue_num) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, act, @@ -1300,7 +1300,7 @@ igb_parse_rss_filter(struct rte_eth_dev *dev, return -rte_errno; } - for (n = 0; n < rss->num; n++) { + for (n = 0; n < rss->queue_num; n++) { if (rss->queue[n] >= dev->data->nb_rx_queues) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, @@ -1310,14 +1310,18 @@ igb_parse_rss_filter(struct rte_eth_dev *dev, } } - if (rss->rss_conf) - rss_conf->rss_conf = *rss->rss_conf; - else - rss_conf->rss_conf.rss_hf = IGB_RSS_OFFLOAD_ALL; - - for (n = 0; n < rss->num; ++n) - rss_conf->queue[n] = rss->queue[n]; - rss_conf->num = rss->num; + if (rss->key_len && rss->key_len != RTE_DIM(rss_conf->key)) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, + "RSS hash key must be exactly 40 bytes"); + if (rss->queue_num > RTE_DIM(rss_conf->queue)) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, + "too many queues for RSS context"); + if (igb_rss_conf_init(rss_conf, rss)) + return rte_flow_error_set + (error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, act, + "RSS context initialization failure"); /* check if the next not void item is END */ index++; @@ -1518,9 +1522,8 @@ igb_flow_create(struct rte_eth_dev *dev, PMD_DRV_LOG(ERR, "failed to allocate memory"); goto out; } - rte_memcpy(&rss_filter_ptr->filter_info, - &rss_conf, - sizeof(struct igb_rte_flow_rss_conf)); + igb_rss_conf_init(&rss_filter_ptr->filter_info, + &rss_conf.conf); TAILQ_INSERT_TAIL(&igb_filter_rss_list, rss_filter_ptr, entries); flow->rule = rss_filter_ptr; @@ -1757,7 +1760,7 @@ igb_clear_rss_filter(struct rte_eth_dev *dev) struct e1000_filter_info *filter = E1000_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private); - if (filter->rss_info.num) + if (filter->rss_info.conf.queue_num) igb_config_rss_filter(dev, &filter->rss_info, FALSE); } diff --git a/drivers/net/e1000/igb_rxtx.c b/drivers/net/e1000/igb_rxtx.c index 009f0ea79..292b16ab2 100644 --- a/drivers/net/e1000/igb_rxtx.c +++ b/drivers/net/e1000/igb_rxtx.c @@ -2759,12 +2759,47 @@ igb_txq_info_get(struct rte_eth_dev *dev, uint16_t queue_id, } int +igb_rss_conf_init(struct igb_rte_flow_rss_conf *out, + const struct rte_flow_action_rss *in) +{ + if (in->key_len > RTE_DIM(out->key) || + in->queue_num > RTE_DIM(out->queue)) + return -EINVAL; + out->conf = (struct rte_flow_action_rss){ + .types = in->types, + .key_len = in->key_len, + .queue_num = in->queue_num, + .key = memcpy(out->key, in->key, in->key_len), + .queue = memcpy(out->queue, in->queue, + sizeof(*in->queue) * in->queue_num), + }; + return 0; +} + +int +igb_action_rss_same(const struct rte_flow_action_rss *comp, + const struct rte_flow_action_rss *with) +{ + return (comp->types == with->types && + comp->key_len == with->key_len && + comp->queue_num == with->queue_num && + !memcmp(comp->key, with->key, with->key_len) && + !memcmp(comp->queue, with->queue, + sizeof(*with->queue) * with->queue_num)); +} + +int igb_config_rss_filter(struct rte_eth_dev *dev, struct igb_rte_flow_rss_conf *conf, bool add) { uint32_t shift; uint16_t i, j; - struct rte_eth_rss_conf rss_conf = conf->rss_conf; + struct rte_eth_rss_conf rss_conf = { + .rss_key = conf->conf.key_len ? + (void *)(uintptr_t)conf->conf.key : NULL, + .rss_key_len = conf->conf.key_len, + .rss_hf = conf->conf.types, + }; struct e1000_filter_info *filter_info = E1000_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private); struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private); @@ -2772,8 +2807,8 @@ igb_config_rss_filter(struct rte_eth_dev *dev, hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private); if (!add) { - if (memcmp(conf, &filter_info->rss_info, - sizeof(struct igb_rte_flow_rss_conf)) == 0) { + if (igb_action_rss_same(&filter_info->rss_info.conf, + &conf->conf)) { igb_rss_disable(dev); memset(&filter_info->rss_info, 0, sizeof(struct igb_rte_flow_rss_conf)); @@ -2782,7 +2817,7 @@ igb_config_rss_filter(struct rte_eth_dev *dev, return -EINVAL; } - if (filter_info->rss_info.num) + if (filter_info->rss_info.conf.queue_num) return -EINVAL; /* Fill in redirection table. */ @@ -2794,9 +2829,9 @@ igb_config_rss_filter(struct rte_eth_dev *dev, } reta; uint8_t q_idx; - if (j == conf->num) + if (j == conf->conf.queue_num) j = 0; - q_idx = conf->queue[j]; + q_idx = conf->conf.queue[j]; reta.bytes[i & 3] = (uint8_t)(q_idx << shift); if ((i & 3) == 3) E1000_WRITE_REG(hw, E1000_RETA(i >> 2), reta.dword); @@ -2813,8 +2848,8 @@ igb_config_rss_filter(struct rte_eth_dev *dev, rss_conf.rss_key = rss_intel_key; /* Default hash key */ igb_hw_rss_hash_set(hw, &rss_conf); - rte_memcpy(&filter_info->rss_info, - conf, sizeof(struct igb_rte_flow_rss_conf)); + if (igb_rss_conf_init(&filter_info->rss_info, &conf->conf)) + return -EINVAL; return 0; } diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index d0bf4e349..a10799cb7 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c @@ -11,6 +11,7 @@ #include <inttypes.h> #include <assert.h> +#include <rte_common.h> #include <rte_eal.h> #include <rte_string_fns.h> #include <rte_pci.h> @@ -11455,7 +11456,7 @@ i40e_rss_filter_restore(struct i40e_pf *pf) { struct i40e_rte_flow_rss_conf *conf = &pf->rss_info; - if (conf->num) + if (conf->conf.queue_num) i40e_config_rss_filter(pf, conf, TRUE); } @@ -11954,18 +11955,52 @@ i40e_cloud_filter_qinq_create(struct i40e_pf *pf) } int +i40e_rss_conf_init(struct i40e_rte_flow_rss_conf *out, + const struct rte_flow_action_rss *in) +{ + if (in->key_len > RTE_DIM(out->key) || + in->queue_num > RTE_DIM(out->queue)) + return -EINVAL; + out->conf = (struct rte_flow_action_rss){ + .types = in->types, + .key_len = in->key_len, + .queue_num = in->queue_num, + .key = memcpy(out->key, in->key, in->key_len), + .queue = memcpy(out->queue, in->queue, + sizeof(*in->queue) * in->queue_num), + }; + return 0; +} + +int +i40e_action_rss_same(const struct rte_flow_action_rss *comp, + const struct rte_flow_action_rss *with) +{ + return (comp->types == with->types && + comp->key_len == with->key_len && + comp->queue_num == with->queue_num && + !memcmp(comp->key, with->key, with->key_len) && + !memcmp(comp->queue, with->queue, + sizeof(*with->queue) * with->queue_num)); +} + +int i40e_config_rss_filter(struct i40e_pf *pf, struct i40e_rte_flow_rss_conf *conf, bool add) { struct i40e_hw *hw = I40E_PF_TO_HW(pf); uint32_t i, lut = 0; uint16_t j, num; - struct rte_eth_rss_conf rss_conf = conf->rss_conf; + struct rte_eth_rss_conf rss_conf = { + .rss_key = conf->conf.key_len ? + (void *)(uintptr_t)conf->conf.key : NULL, + .rss_key_len = conf->conf.key_len, + .rss_hf = conf->conf.types, + }; struct i40e_rte_flow_rss_conf *rss_info = &pf->rss_info; if (!add) { - if (memcmp(conf, rss_info, - sizeof(struct i40e_rte_flow_rss_conf)) == 0) { + if (i40e_action_rss_same(&rss_info->conf, &conf->conf)) { i40e_pf_disable_rss(pf); memset(rss_info, 0, sizeof(struct i40e_rte_flow_rss_conf)); @@ -11974,7 +12009,7 @@ i40e_config_rss_filter(struct i40e_pf *pf, return -EINVAL; } - if (rss_info->num) + if (rss_info->conf.queue_num) return -EINVAL; /* If both VMDQ and RSS enabled, not all of PF queues are configured. @@ -11985,7 +12020,7 @@ i40e_config_rss_filter(struct i40e_pf *pf, else num = pf->dev_data->nb_rx_queues; - num = RTE_MIN(num, conf->num); + num = RTE_MIN(num, conf->conf.queue_num); PMD_DRV_LOG(INFO, "Max of contiguous %u PF queues are configured", num); @@ -11998,7 +12033,7 @@ i40e_config_rss_filter(struct i40e_pf *pf, for (i = 0, j = 0; i < hw->func_caps.rss_table_size; i++, j++) { if (j == num) j = 0; - lut = (lut << 8) | (conf->queue[j] & ((0x1 << + lut = (lut << 8) | (conf->conf.queue[j] & ((0x1 << hw->func_caps.rss_table_entry_width) - 1)); if ((i & 3) == 3) I40E_WRITE_REG(hw, I40E_PFQF_HLUT(i >> 2), lut); @@ -12023,8 +12058,8 @@ i40e_config_rss_filter(struct i40e_pf *pf, i40e_hw_rss_hash_set(pf, &rss_conf); - rte_memcpy(rss_info, - conf, sizeof(struct i40e_rte_flow_rss_conf)); + if (i40e_rss_conf_init(rss_info, &conf->conf)) + return -EINVAL; return 0; } diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h index 151ed1a8c..5c02b37a0 100644 --- a/drivers/net/i40e/i40e_ethdev.h +++ b/drivers/net/i40e/i40e_ethdev.h @@ -5,13 +5,18 @@ #ifndef _I40E_ETHDEV_H_ #define _I40E_ETHDEV_H_ +#include <stdint.h> + #include <rte_eth_ctrl.h> #include <rte_time.h> #include <rte_kvargs.h> #include <rte_hash.h> +#include <rte_flow.h> #include <rte_flow_driver.h> #include <rte_tm_driver.h> +#include "base/i40e_register.h" + #define I40E_VLAN_TAG_SIZE 4 #define I40E_AQ_LEN 32 @@ -877,9 +882,11 @@ struct i40e_customized_pctype { }; struct i40e_rte_flow_rss_conf { - struct rte_eth_rss_conf rss_conf; /**< RSS parameters. */ + struct rte_flow_action_rss conf; /**< RSS parameters. */ uint16_t queue_region_conf; /**< Queue region config flag */ - uint16_t num; /**< Number of entries in queue[]. */ + uint8_t key[(I40E_VFQF_HKEY_MAX_INDEX > I40E_PFQF_HKEY_MAX_INDEX ? + I40E_VFQF_HKEY_MAX_INDEX : I40E_PFQF_HKEY_MAX_INDEX) + 1 * + sizeof(uint32_t)]; /* Hash key. */ uint16_t queue[I40E_MAX_Q_PER_TC]; /**< Queues indices to use. */ }; @@ -1217,6 +1224,10 @@ void i40e_init_queue_region_conf(struct rte_eth_dev *dev); void i40e_flex_payload_reg_set_default(struct i40e_hw *hw); int i40e_set_rss_key(struct i40e_vsi *vsi, uint8_t *key, uint8_t key_len); int i40e_set_rss_lut(struct i40e_vsi *vsi, uint8_t *lut, uint16_t lut_size); +int i40e_rss_conf_init(struct i40e_rte_flow_rss_conf *out, + const struct rte_flow_action_rss *in); +int i40e_action_rss_same(const struct rte_flow_action_rss *comp, + const struct rte_flow_action_rss *with); int i40e_config_rss_filter(struct i40e_pf *pf, struct i40e_rte_flow_rss_conf *conf, bool add); diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c index 69d1ba55e..072cebb16 100644 --- a/drivers/net/i40e/i40e_flow.c +++ b/drivers/net/i40e/i40e_flow.c @@ -4205,7 +4205,7 @@ i40e_flow_parse_rss_action(struct rte_eth_dev *dev, if (action_flag) { for (n = 0; n < 64; n++) { - if (rss->rss_conf->rss_hf & (hf_bit << n)) { + if (rss->types & (hf_bit << n)) { conf_info->region[0].hw_flowtype[0] = n; conf_info->region[0].flowtype_num = 1; conf_info->queue_region_number = 1; @@ -4217,8 +4217,8 @@ i40e_flow_parse_rss_action(struct rte_eth_dev *dev, for (n = 0; n < conf_info->queue_region_number; n++) { if (conf_info->region[n].user_priority_num || conf_info->region[n].flowtype_num) { - if (!((rte_is_power_of_2(rss->num)) && - rss->num <= 64)) { + if (!((rte_is_power_of_2(rss->queue_num)) && + rss->queue_num <= 64)) { PMD_DRV_LOG(ERR, "The region sizes should be any of the following values: 1, 2, 4, 8, 16, 32, 64 as long as the " "total number of queues do not exceed the VSI allocation"); return -rte_errno; @@ -4236,10 +4236,11 @@ i40e_flow_parse_rss_action(struct rte_eth_dev *dev, return -rte_errno; } - if (rss_info->num < rss->num || - rss_info->queue[0] < rss->queue[0] || - (rss->queue[0] + rss->num > - rss_info->num + rss_info->queue[0])) { + if (rss_info->conf.queue_num < rss->queue_num || + rss_info->conf.queue[0] < rss->queue[0] || + (rss->queue[0] + rss->queue_num > + rss_info->conf.queue_num + + rss_info->queue[0])) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, act, @@ -4248,7 +4249,8 @@ i40e_flow_parse_rss_action(struct rte_eth_dev *dev, } for (i = 0; i < info->queue_region_number; i++) { - if (info->region[i].queue_num == rss->num && + if (info->region[i].queue_num == + rss->queue_num && info->region[i].queue_start_index == rss->queue[0]) break; @@ -4261,7 +4263,7 @@ i40e_flow_parse_rss_action(struct rte_eth_dev *dev, } info->region[i].queue_num = - rss->num; + rss->queue_num; info->region[i].queue_start_index = rss->queue[0]; info->region[i].region_id = @@ -4304,7 +4306,7 @@ i40e_flow_parse_rss_action(struct rte_eth_dev *dev, if (rss_config->queue_region_conf) return 0; - if (!rss || !rss->num) { + if (!rss || !rss->queue_num) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, act, @@ -4312,7 +4314,7 @@ i40e_flow_parse_rss_action(struct rte_eth_dev *dev, return -rte_errno; } - for (n = 0; n < rss->num; n++) { + for (n = 0; n < rss->queue_num; n++) { if (rss->queue[n] >= dev->data->nb_rx_queues) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, @@ -4321,15 +4323,20 @@ i40e_flow_parse_rss_action(struct rte_eth_dev *dev, return -rte_errno; } } - if (rss->rss_conf) - rss_config->rss_conf = *rss->rss_conf; - else - rss_config->rss_conf.rss_hf = - pf->adapter->flow_types_mask; - for (n = 0; n < rss->num; ++n) - rss_config->queue[n] = rss->queue[n]; - rss_config->num = rss->num; + if (rss->key_len && rss->key_len > RTE_DIM(rss_config->key)) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, + "RSS hash key too large"); + if (rss->queue_num > RTE_DIM(rss_config->queue)) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, + "too many queues for RSS context"); + if (i40e_rss_conf_init(rss_config, rss)) + return rte_flow_error_set + (error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, act, + "RSS context initialization failure"); + index++; /* check if the next not void action is END */ @@ -4849,7 +4856,7 @@ i40e_flow_flush_rss_filter(struct rte_eth_dev *dev) ret = i40e_flush_queue_region_all_conf(dev, hw, pf, 0); - if (rss_info->num) + if (rss_info->conf.queue_num) ret = i40e_config_rss_filter(pf, rss_info, FALSE); return ret; } diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c index 4df5c75c3..d48ce6969 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.c +++ b/drivers/net/ixgbe/ixgbe_ethdev.c @@ -100,8 +100,6 @@ #define IXGBE_QUEUE_STAT_COUNTERS (sizeof(hw_stats->qprc) / sizeof(hw_stats->qprc[0])) -#define IXGBE_HKEY_MAX_INDEX 10 - /* Additional timesync values. */ #define NSEC_PER_SEC 1000000000L #define IXGBE_INCVAL_10GB 0x66666666 @@ -8284,7 +8282,7 @@ ixgbe_rss_filter_restore(struct rte_eth_dev *dev) struct ixgbe_filter_info *filter_info = IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private); - if (filter_info->rss_info.num) + if (filter_info->rss_info.conf.queue_num) ixgbe_config_rss_filter(dev, &filter_info->rss_info, TRUE); } diff --git a/drivers/net/ixgbe/ixgbe_ethdev.h b/drivers/net/ixgbe/ixgbe_ethdev.h index c56d65244..1b38b09f7 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.h +++ b/drivers/net/ixgbe/ixgbe_ethdev.h @@ -4,6 +4,9 @@ #ifndef _IXGBE_ETHDEV_H_ #define _IXGBE_ETHDEV_H_ + +#include <stdint.h> + #include "base/ixgbe_type.h" #include "base/ixgbe_dcb.h" #include "base/ixgbe_dcb_82599.h" @@ -12,6 +15,7 @@ #ifdef RTE_LIBRTE_SECURITY #include "ixgbe_ipsec.h" #endif +#include <rte_flow.h> #include <rte_time.h> #include <rte_hash.h> #include <rte_pci.h> @@ -39,6 +43,7 @@ #define IXGBE_EXTENDED_VLAN (uint32_t)(1 << 26) /* EXTENDED VLAN ENABLE */ #define IXGBE_VFTA_SIZE 128 #define IXGBE_VLAN_TAG_SIZE 4 +#define IXGBE_HKEY_MAX_INDEX 10 #define IXGBE_MAX_RX_QUEUE_NUM 128 #define IXGBE_MAX_INTR_QUEUE_NUM 15 #define IXGBE_VMDQ_DCB_NB_QUEUES IXGBE_MAX_RX_QUEUE_NUM @@ -196,8 +201,8 @@ struct ixgbe_hw_fdir_info { }; struct ixgbe_rte_flow_rss_conf { - struct rte_eth_rss_conf rss_conf; /**< RSS parameters. */ - uint16_t num; /**< Number of entries in queue[]. */ + struct rte_flow_action_rss conf; /**< RSS parameters. */ + uint8_t key[IXGBE_HKEY_MAX_INDEX * sizeof(uint32_t)]; /* Hash key. */ uint16_t queue[IXGBE_MAX_RX_QUEUE_NUM]; /**< Queues indices to use. */ }; @@ -698,6 +703,10 @@ void ixgbe_tm_conf_init(struct rte_eth_dev *dev); void ixgbe_tm_conf_uninit(struct rte_eth_dev *dev); int ixgbe_set_queue_rate_limit(struct rte_eth_dev *dev, uint16_t queue_idx, uint16_t tx_rate); +int ixgbe_rss_conf_init(struct ixgbe_rte_flow_rss_conf *out, + const struct rte_flow_action_rss *in); +int ixgbe_action_rss_same(const struct rte_flow_action_rss *comp, + const struct rte_flow_action_rss *with); int ixgbe_config_rss_filter(struct rte_eth_dev *dev, struct ixgbe_rte_flow_rss_conf *conf, bool add); diff --git a/drivers/net/ixgbe/ixgbe_flow.c b/drivers/net/ixgbe/ixgbe_flow.c index abdeac28b..4e31c7c56 100644 --- a/drivers/net/ixgbe/ixgbe_flow.c +++ b/drivers/net/ixgbe/ixgbe_flow.c @@ -2761,7 +2761,7 @@ ixgbe_parse_rss_filter(struct rte_eth_dev *dev, rss = (const struct rte_flow_action_rss *)act->conf; - if (!rss || !rss->num) { + if (!rss || !rss->queue_num) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, act, @@ -2769,7 +2769,7 @@ ixgbe_parse_rss_filter(struct rte_eth_dev *dev, return -rte_errno; } - for (n = 0; n < rss->num; n++) { + for (n = 0; n < rss->queue_num; n++) { if (rss->queue[n] >= dev->data->nb_rx_queues) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, @@ -2778,14 +2778,19 @@ ixgbe_parse_rss_filter(struct rte_eth_dev *dev, return -rte_errno; } } - if (rss->rss_conf) - rss_conf->rss_conf = *rss->rss_conf; - else - rss_conf->rss_conf.rss_hf = IXGBE_RSS_OFFLOAD_ALL; - for (n = 0; n < rss->num; ++n) - rss_conf->queue[n] = rss->queue[n]; - rss_conf->num = rss->num; + if (rss->key_len && rss->key_len != RTE_DIM(rss_conf->key)) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, + "RSS hash key must be exactly 40 bytes"); + if (rss->queue_num > RTE_DIM(rss_conf->queue)) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, + "too many queues for RSS context"); + if (ixgbe_rss_conf_init(rss_conf, rss)) + return rte_flow_error_set + (error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, act, + "RSS context initialization failure"); /* check if the next not void item is END */ act = next_no_void_action(actions, act); @@ -2834,7 +2839,7 @@ ixgbe_clear_rss_filter(struct rte_eth_dev *dev) struct ixgbe_filter_info *filter_info = IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private); - if (filter_info->rss_info.num) + if (filter_info->rss_info.conf.queue_num) ixgbe_config_rss_filter(dev, &filter_info->rss_info, FALSE); } @@ -3153,9 +3158,8 @@ ixgbe_flow_create(struct rte_eth_dev *dev, PMD_DRV_LOG(ERR, "failed to allocate memory"); goto out; } - rte_memcpy(&rss_filter_ptr->filter_info, - &rss_conf, - sizeof(struct ixgbe_rte_flow_rss_conf)); + ixgbe_rss_conf_init(&rss_filter_ptr->filter_info, + &rss_conf.conf); TAILQ_INSERT_TAIL(&filter_rss_list, rss_filter_ptr, entries); flow->rule = rss_filter_ptr; diff --git a/drivers/net/ixgbe/ixgbe_rxtx.c b/drivers/net/ixgbe/ixgbe_rxtx.c index 6c582b4be..e86b108d3 100644 --- a/drivers/net/ixgbe/ixgbe_rxtx.c +++ b/drivers/net/ixgbe/ixgbe_rxtx.c @@ -5522,6 +5522,36 @@ ixgbevf_dev_rxtx_start(struct rte_eth_dev *dev) } int +ixgbe_rss_conf_init(struct ixgbe_rte_flow_rss_conf *out, + const struct rte_flow_action_rss *in) +{ + if (in->key_len > RTE_DIM(out->key) || + in->queue_num > RTE_DIM(out->queue)) + return -EINVAL; + out->conf = (struct rte_flow_action_rss){ + .types = in->types, + .key_len = in->key_len, + .queue_num = in->queue_num, + .key = memcpy(out->key, in->key, in->key_len), + .queue = memcpy(out->queue, in->queue, + sizeof(*in->queue) * in->queue_num), + }; + return 0; +} + +int +ixgbe_action_rss_same(const struct rte_flow_action_rss *comp, + const struct rte_flow_action_rss *with) +{ + return (comp->types == with->types && + comp->key_len == with->key_len && + comp->queue_num == with->queue_num && + !memcmp(comp->key, with->key, with->key_len) && + !memcmp(comp->queue, with->queue, + sizeof(*with->queue) * with->queue_num)); +} + +int ixgbe_config_rss_filter(struct rte_eth_dev *dev, struct ixgbe_rte_flow_rss_conf *conf, bool add) { @@ -5531,7 +5561,12 @@ ixgbe_config_rss_filter(struct rte_eth_dev *dev, uint16_t j; uint16_t sp_reta_size; uint32_t reta_reg; - struct rte_eth_rss_conf rss_conf = conf->rss_conf; + struct rte_eth_rss_conf rss_conf = { + .rss_key = conf->conf.key_len ? + (void *)(uintptr_t)conf->conf.key : NULL, + .rss_key_len = conf->conf.key_len, + .rss_hf = conf->conf.types, + }; struct ixgbe_filter_info *filter_info = IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private); @@ -5541,8 +5576,8 @@ ixgbe_config_rss_filter(struct rte_eth_dev *dev, sp_reta_size = ixgbe_reta_size_get(hw->mac.type); if (!add) { - if (memcmp(conf, &filter_info->rss_info, - sizeof(struct ixgbe_rte_flow_rss_conf)) == 0) { + if (ixgbe_action_rss_same(&filter_info->rss_info.conf, + &conf->conf)) { ixgbe_rss_disable(dev); memset(&filter_info->rss_info, 0, sizeof(struct ixgbe_rte_flow_rss_conf)); @@ -5551,7 +5586,7 @@ ixgbe_config_rss_filter(struct rte_eth_dev *dev, return -EINVAL; } - if (filter_info->rss_info.num) + if (filter_info->rss_info.conf.queue_num) return -EINVAL; /* Fill in redirection table * The byte-swap is needed because NIC registers are in @@ -5561,9 +5596,9 @@ ixgbe_config_rss_filter(struct rte_eth_dev *dev, for (i = 0, j = 0; i < sp_reta_size; i++, j++) { reta_reg = ixgbe_reta_reg_get(hw->mac.type, i); - if (j == conf->num) + if (j == conf->conf.queue_num) j = 0; - reta = (reta << 8) | conf->queue[j]; + reta = (reta << 8) | conf->conf.queue[j]; if ((i & 3) == 3) IXGBE_WRITE_REG(hw, reta_reg, rte_bswap32(reta)); @@ -5580,8 +5615,8 @@ ixgbe_config_rss_filter(struct rte_eth_dev *dev, rss_conf.rss_key = rss_intel_key; /* Default hash key */ ixgbe_hw_rss_hash_set(hw, &rss_conf); - rte_memcpy(&filter_info->rss_info, - conf, sizeof(struct ixgbe_rte_flow_rss_conf)); + if (ixgbe_rss_conf_init(&filter_info->rss_info, &conf->conf)) + return -EINVAL; return 0; } diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c index fb8a8b848..c7854bead 100644 --- a/drivers/net/mlx4/mlx4.c +++ b/drivers/net/mlx4/mlx4.c @@ -569,7 +569,7 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev) " for UDP RSS and inner VXLAN RSS"); /* Fake support for all possible RSS hash fields. */ priv->hw_rss_sup = ~UINT64_C(0); - priv->hw_rss_sup = mlx4_conv_rss_hf(priv, -1); + priv->hw_rss_sup = mlx4_conv_rss_types(priv, -1); /* Filter out known unsupported fields. */ priv->hw_rss_sup &= ~(uint64_t)(IBV_RX_HASH_SRC_PORT_UDP | diff --git a/drivers/net/mlx4/mlx4_flow.c b/drivers/net/mlx4/mlx4_flow.c index 5a1b7dedd..4dbcaa39c 100644 --- a/drivers/net/mlx4/mlx4_flow.c +++ b/drivers/net/mlx4/mlx4_flow.c @@ -76,22 +76,22 @@ struct mlx4_drop { }; /** - * Convert DPDK RSS hash fields to their Verbs equivalent. + * Convert DPDK RSS hash types to their Verbs equivalent. * - * This function returns the supported (default) set when @p rss_hf has + * This function returns the supported (default) set when @p types has * special value (uint64_t)-1. * * @param priv * Pointer to private structure. - * @param rss_hf - * Hash fields in DPDK format (see struct rte_eth_rss_conf). + * @param types + * Hash types in DPDK format (see struct rte_eth_rss_conf). * * @return * A valid Verbs RSS hash fields mask for mlx4 on success, (uint64_t)-1 * otherwise and rte_errno is set. */ uint64_t -mlx4_conv_rss_hf(struct priv *priv, uint64_t rss_hf) +mlx4_conv_rss_types(struct priv *priv, uint64_t types) { enum { IPV4, IPV6, TCP, UDP, }; const uint64_t in[] = { @@ -126,17 +126,17 @@ mlx4_conv_rss_hf(struct priv *priv, uint64_t rss_hf) unsigned int i; for (i = 0; i != RTE_DIM(in); ++i) - if (rss_hf & in[i]) { - seen |= rss_hf & in[i]; + if (types & in[i]) { + seen |= types & in[i]; conv |= out[i]; } if ((conv & priv->hw_rss_sup) == conv) { - if (rss_hf == (uint64_t)-1) { + if (types == (uint64_t)-1) { /* Include inner RSS by default if supported. */ conv |= priv->hw_rss_sup & IBV_RX_HASH_INNER; return conv; } - if (!(rss_hf & ~seen)) + if (!(types & ~seen)) return conv; } rte_errno = ENOTSUP; @@ -717,7 +717,8 @@ mlx4_flow_prepare(struct priv *priv, switch (action->type) { const struct rte_flow_action_queue *queue; const struct rte_flow_action_rss *rss; - const struct rte_eth_rss_conf *rss_conf; + const uint8_t *rss_key; + uint32_t rss_key_len; uint64_t fields; unsigned int i; @@ -747,58 +748,56 @@ mlx4_flow_prepare(struct priv *priv, break; rss = action->conf; /* Default RSS configuration if none is provided. */ - rss_conf = - rss->rss_conf ? - rss->rss_conf : - &(struct rte_eth_rss_conf){ - .rss_key = mlx4_rss_hash_key_default, - .rss_key_len = MLX4_RSS_HASH_KEY_SIZE, - .rss_hf = -1, - }; + if (rss->key_len) { + rss_key = rss->key; + rss_key_len = rss->key_len; + } else { + rss_key = mlx4_rss_hash_key_default; + rss_key_len = MLX4_RSS_HASH_KEY_SIZE; + } /* Sanity checks. */ - for (i = 0; i < rss->num; ++i) + for (i = 0; i < rss->queue_num; ++i) if (rss->queue[i] >= priv->dev->data->nb_rx_queues) break; - if (i != rss->num) { + if (i != rss->queue_num) { msg = "queue index target beyond number of" " configured Rx queues"; goto exit_action_not_supported; } - if (!rte_is_power_of_2(rss->num)) { + if (!rte_is_power_of_2(rss->queue_num)) { msg = "for RSS, mlx4 requires the number of" " queues to be a power of two"; goto exit_action_not_supported; } - if (rss_conf->rss_key_len != - sizeof(flow->rss->key)) { + if (rss_key_len != sizeof(flow->rss->key)) { msg = "mlx4 supports exactly one RSS hash key" " length: " MLX4_STR_EXPAND(MLX4_RSS_HASH_KEY_SIZE); goto exit_action_not_supported; } - for (i = 1; i < rss->num; ++i) + for (i = 1; i < rss->queue_num; ++i) if (rss->queue[i] - rss->queue[i - 1] != 1) break; - if (i != rss->num) { + if (i != rss->queue_num) { msg = "mlx4 requires RSS contexts to use" " consecutive queue indices only"; goto exit_action_not_supported; } - if (rss->queue[0] % rss->num) { + if (rss->queue[0] % rss->queue_num) { msg = "mlx4 requires the first queue of a RSS" " context to be aligned on a multiple" " of the context size"; goto exit_action_not_supported; } rte_errno = 0; - fields = mlx4_conv_rss_hf(priv, rss_conf->rss_hf); + fields = mlx4_conv_rss_types(priv, rss->types); if (fields == (uint64_t)-1 && rte_errno) { msg = "unsupported RSS hash type requested"; goto exit_action_not_supported; } flow->rss = mlx4_rss_get - (priv, fields, rss_conf->rss_key, rss->num, + (priv, fields, rss_key, rss->queue_num, rss->queue); if (!flow->rss) { msg = "either invalid parameters or not enough" @@ -1284,8 +1283,10 @@ mlx4_flow_internal(struct priv *priv, struct rte_flow_error *error) rte_align32pow2(priv->dev->data->nb_rx_queues + 1) >> 1; uint16_t queue[queues]; struct rte_flow_action_rss action_rss = { - .rss_conf = NULL, /* Rely on default fallback settings. */ - .num = queues, + .types = -1, + .key_len = MLX4_RSS_HASH_KEY_SIZE, + .queue_num = queues, + .key = mlx4_rss_hash_key_default, .queue = queue, }; struct rte_flow_action actions[] = { diff --git a/drivers/net/mlx4/mlx4_flow.h b/drivers/net/mlx4/mlx4_flow.h index 00188a65c..f71078ecc 100644 --- a/drivers/net/mlx4/mlx4_flow.h +++ b/drivers/net/mlx4/mlx4_flow.h @@ -47,7 +47,7 @@ struct rte_flow { /* mlx4_flow.c */ -uint64_t mlx4_conv_rss_hf(struct priv *priv, uint64_t rss_hf); +uint64_t mlx4_conv_rss_types(struct priv *priv, uint64_t rss_hf); int mlx4_flow_sync(struct priv *priv, struct rte_flow_error *error); void mlx4_flow_clean(struct priv *priv); int mlx4_filter_ctrl(struct rte_eth_dev *dev, diff --git a/drivers/net/mlx4/mlx4_rxq.c b/drivers/net/mlx4/mlx4_rxq.c index 7a036ed83..474614e4d 100644 --- a/drivers/net/mlx4/mlx4_rxq.c +++ b/drivers/net/mlx4/mlx4_rxq.c @@ -88,7 +88,7 @@ mlx4_rss_hash_key_default[MLX4_RSS_HASH_KEY_SIZE] = { */ struct mlx4_rss * mlx4_rss_get(struct priv *priv, uint64_t fields, - uint8_t key[MLX4_RSS_HASH_KEY_SIZE], + const uint8_t key[MLX4_RSS_HASH_KEY_SIZE], uint16_t queues, const uint16_t queue_id[]) { struct mlx4_rss *rss; diff --git a/drivers/net/mlx4/mlx4_rxtx.h b/drivers/net/mlx4/mlx4_rxtx.h index c12bd39a9..89558ac07 100644 --- a/drivers/net/mlx4/mlx4_rxtx.h +++ b/drivers/net/mlx4/mlx4_rxtx.h @@ -126,7 +126,7 @@ uint8_t mlx4_rss_hash_key_default[MLX4_RSS_HASH_KEY_SIZE]; int mlx4_rss_init(struct priv *priv); void mlx4_rss_deinit(struct priv *priv); struct mlx4_rss *mlx4_rss_get(struct priv *priv, uint64_t fields, - uint8_t key[MLX4_RSS_HASH_KEY_SIZE], + const uint8_t key[MLX4_RSS_HASH_KEY_SIZE], uint16_t queues, const uint16_t queue_id[]); void mlx4_rss_put(struct mlx4_rss *rss); int mlx4_rss_attach(struct mlx4_rss *rss); diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index a52dcf263..7798052f9 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -214,9 +214,8 @@ struct rte_flow { TAILQ_ENTRY(rte_flow) next; /**< Pointer to the next flow structure. */ uint32_t mark:1; /**< Set if the flow is marked. */ uint32_t drop:1; /**< Drop queue. */ - uint16_t queues_n; /**< Number of entries in queue[]. */ + struct rte_flow_action_rss rss_conf; /**< RSS configuration */ uint16_t (*queues)[]; /**< Queues indexes to use. */ - struct rte_eth_rss_conf rss_conf; /**< RSS configuration */ uint8_t rss_key[40]; /**< copy of the RSS key. */ struct ibv_counter_set *cs; /**< Holds the counters for the rule. */ struct mlx5_flow_counter_stats counter_stats;/**<The counter stats. */ @@ -406,9 +405,8 @@ struct mlx5_flow_parse { uint32_t mark:1; /**< Mark is present in the flow. */ uint32_t count:1; /**< Count is present in the flow. */ uint32_t mark_id; /**< Mark identifier. */ + struct rte_flow_action_rss rss_conf; /**< RSS configuration */ uint16_t queues[RTE_MAX_QUEUES_PER_PORT]; /**< Queues indexes to use. */ - uint16_t queues_n; /**< Number of entries in queue[]. */ - struct rte_eth_rss_conf rss_conf; /**< RSS configuration */ uint8_t rss_key[40]; /**< copy of the RSS key. */ enum hash_rxq_type layer; /**< Last pattern layer detected. */ struct ibv_counter_set *cs; /**< Holds the counter set for the rule */ @@ -532,47 +530,6 @@ mlx5_flow_item_validate(const struct rte_flow_item *item, } /** - * Copy the RSS configuration from the user ones, of the rss_conf is null, - * uses the driver one. - * - * @param parser - * Internal parser structure. - * @param rss_conf - * User RSS configuration to save. - * - * @return - * 0 on success, a negative errno value otherwise and rte_errno is set. - */ -static int -mlx5_flow_convert_rss_conf(struct mlx5_flow_parse *parser, - const struct rte_eth_rss_conf *rss_conf) -{ - /* - * This function is also called at the beginning of - * mlx5_flow_convert_actions() to initialize the parser with the - * device default RSS configuration. - */ - if (rss_conf) { - if (rss_conf->rss_hf & MLX5_RSS_HF_MASK) { - rte_errno = EINVAL; - return -rte_errno; - } - if (rss_conf->rss_key_len != 40) { - rte_errno = EINVAL; - return -rte_errno; - } - if (rss_conf->rss_key_len && rss_conf->rss_key) { - parser->rss_conf.rss_key_len = rss_conf->rss_key_len; - memcpy(parser->rss_key, rss_conf->rss_key, - rss_conf->rss_key_len); - parser->rss_conf.rss_key = parser->rss_key; - } - parser->rss_conf.rss_hf = rss_conf->rss_hf; - } - return 0; -} - -/** * Extract attribute to the parser. * * @param[in] attr @@ -642,17 +599,7 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, enum { FATE = 1, MARK = 2, COUNT = 4, }; uint32_t overlap = 0; struct priv *priv = dev->data->dev_private; - int ret; - /* - * Add default RSS configuration necessary for Verbs to create QP even - * if no RSS is necessary. - */ - ret = mlx5_flow_convert_rss_conf(parser, - (const struct rte_eth_rss_conf *) - &priv->rss_conf); - if (ret) - return ret; for (; actions->type != RTE_FLOW_ACTION_TYPE_END; ++actions) { if (actions->type == RTE_FLOW_ACTION_TYPE_VOID) { continue; @@ -671,25 +618,53 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, overlap |= FATE; if (!queue || (queue->index > (priv->rxqs_n - 1))) goto exit_action_not_supported; - parser->queues_n = 1; parser->queues[0] = queue->index; + parser->rss_conf = (struct rte_flow_action_rss){ + .queue_num = 1, + .queue = parser->queues, + }; } else if (actions->type == RTE_FLOW_ACTION_TYPE_RSS) { const struct rte_flow_action_rss *rss = (const struct rte_flow_action_rss *) actions->conf; + const uint8_t *rss_key; + uint32_t rss_key_len; uint16_t n; if (overlap & FATE) goto exit_action_overlap; overlap |= FATE; - if (!rss || !rss->num) { + if (rss->types & MLX5_RSS_HF_MASK) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION, + actions, + "unsupported RSS type" + " requested"); + return -rte_errno; + } + if (rss->key_len) { + rss_key_len = rss->key_len; + rss_key = rss->key; + } else { + rss_key_len = rss_hash_default_key_len; + rss_key = rss_hash_default_key; + } + if (rss_key_len != RTE_DIM(parser->rss_key)) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION, + actions, + "RSS hash key must be" + " exactly 40 bytes long"); + return -rte_errno; + } + if (!rss->queue_num) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, actions, "no valid queues"); return -rte_errno; } - if (rss->num > RTE_DIM(parser->queues)) { + if (rss->queue_num > RTE_DIM(parser->queues)) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, actions, @@ -697,7 +672,7 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, " context"); return -rte_errno; } - for (n = 0; n < rss->num; ++n) { + for (n = 0; n < rss->queue_num; ++n) { if (rss->queue[n] >= priv->rxqs_n) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, @@ -707,16 +682,16 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, return -rte_errno; } } - for (n = 0; n < rss->num; ++n) - parser->queues[n] = rss->queue[n]; - parser->queues_n = rss->num; - if (mlx5_flow_convert_rss_conf(parser, rss->rss_conf)) { - rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ACTION, - actions, - "wrong RSS configuration"); - return -rte_errno; - } + parser->rss_conf = (struct rte_flow_action_rss){ + .types = rss->types, + .key_len = rss_key_len, + .queue_num = rss->queue_num, + .key = memcpy(parser->rss_key, rss_key, + sizeof(*rss_key) * rss_key_len), + .queue = memcpy(parser->queues, rss->queue, + sizeof(*rss->queue) * + rss->queue_num), + }; } else if (actions->type == RTE_FLOW_ACTION_TYPE_MARK) { const struct rte_flow_action_mark *mark = (const struct rte_flow_action_mark *) @@ -761,7 +736,7 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, parser->drop = 1; if (parser->drop && parser->mark) parser->mark = 0; - if (!parser->queues_n && !parser->drop) { + if (!parser->rss_conf.queue_num && !parser->drop) { rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_HANDLE, NULL, "no valid action"); return -rte_errno; @@ -941,7 +916,7 @@ mlx5_flow_convert_finalise(struct mlx5_flow_parse *parser) unsigned int i; /* Remove any other flow not matching the pattern. */ - if (parser->queues_n == 1 && !parser->rss_conf.rss_hf) { + if (parser->rss_conf.queue_num == 1 && !parser->rss_conf.types) { for (i = 0; i != hash_rxq_init_n; ++i) { if (i == HASH_RXQ_ETH) continue; @@ -969,7 +944,7 @@ mlx5_flow_convert_finalise(struct mlx5_flow_parse *parser) } /* Remove impossible flow according to the RSS configuration. */ if (hash_rxq_init[parser->layer].dpdk_rss_hf & - parser->rss_conf.rss_hf) { + parser->rss_conf.types) { /* Remove any other flow. */ for (i = hmin; i != (hmax + 1); ++i) { if ((i == parser->layer) || @@ -980,7 +955,7 @@ mlx5_flow_convert_finalise(struct mlx5_flow_parse *parser) } } else if (!parser->queue[ip].ibv_attr) { /* no RSS possible with the current configuration. */ - parser->queues_n = 1; + parser->rss_conf.queue_num = 1; return; } fill: @@ -1109,7 +1084,7 @@ mlx5_flow_convert(struct rte_eth_dev *dev, for (i = 0; i != hash_rxq_init_n; ++i) { unsigned int offset; - if (!(parser->rss_conf.rss_hf & + if (!(parser->rss_conf.types & hash_rxq_init[i].dpdk_rss_hf) && (i != HASH_RXQ_ETH)) continue; @@ -1777,20 +1752,20 @@ mlx5_flow_create_action_queue_rss(struct rte_eth_dev *dev, continue; flow->frxq[i].hrxq = mlx5_hrxq_get(dev, - parser->rss_conf.rss_key, - parser->rss_conf.rss_key_len, + parser->rss_conf.key, + parser->rss_conf.key_len, hash_fields, - parser->queues, - parser->queues_n); + parser->rss_conf.queue, + parser->rss_conf.queue_num); if (flow->frxq[i].hrxq) continue; flow->frxq[i].hrxq = mlx5_hrxq_new(dev, - parser->rss_conf.rss_key, - parser->rss_conf.rss_key_len, + parser->rss_conf.key, + parser->rss_conf.key_len, hash_fields, - parser->queues, - parser->queues_n); + parser->rss_conf.queue, + parser->rss_conf.queue_num); if (!flow->frxq[i].hrxq) { return rte_flow_error_set(error, ENOMEM, RTE_FLOW_ERROR_TYPE_HANDLE, @@ -1861,9 +1836,9 @@ mlx5_flow_create_action_queue(struct rte_eth_dev *dev, NULL, "internal error in flow creation"); goto error; } - for (i = 0; i != parser->queues_n; ++i) { + for (i = 0; i != parser->rss_conf.queue_num; ++i) { struct mlx5_rxq_data *q = - (*priv->rxqs)[parser->queues[i]]; + (*priv->rxqs)[parser->rss_conf.queue[i]]; q->mark |= parser->mark; } @@ -1927,7 +1902,8 @@ mlx5_flow_list_create(struct rte_eth_dev *dev, if (ret) goto exit; flow = rte_calloc(__func__, 1, - sizeof(*flow) + parser.queues_n * sizeof(uint16_t), + sizeof(*flow) + + parser.rss_conf.queue_num * sizeof(uint16_t), 0); if (!flow) { rte_flow_error_set(error, ENOMEM, @@ -1936,15 +1912,20 @@ mlx5_flow_list_create(struct rte_eth_dev *dev, "cannot allocate flow memory"); return NULL; } - /* Copy queues configuration. */ + /* Copy configuration. */ flow->queues = (uint16_t (*)[])(flow + 1); - memcpy(flow->queues, parser.queues, parser.queues_n * sizeof(uint16_t)); - flow->queues_n = parser.queues_n; + flow->rss_conf = (struct rte_flow_action_rss){ + .types = parser.rss_conf.types, + .key_len = parser.rss_conf.key_len, + .queue_num = parser.rss_conf.queue_num, + .key = memcpy(flow->rss_key, parser.rss_conf.key, + sizeof(*parser.rss_conf.key) * + parser.rss_conf.key_len), + .queue = memcpy(flow->queues, parser.rss_conf.queue, + sizeof(*parser.rss_conf.queue) * + parser.rss_conf.queue_num), + }; flow->mark = parser.mark; - /* Copy RSS configuration. */ - flow->rss_conf = parser.rss_conf; - flow->rss_conf.rss_key = flow->rss_key; - memcpy(flow->rss_key, parser.rss_key, parser.rss_conf.rss_key_len); /* finalise the flow. */ if (parser.drop) ret = mlx5_flow_create_action_queue_drop(dev, &parser, flow, @@ -2024,7 +2005,7 @@ mlx5_flow_list_destroy(struct rte_eth_dev *dev, struct mlx5_flows *list, if (flow->drop || !flow->mark) goto free; - for (i = 0; i != flow->queues_n; ++i) { + for (i = 0; i != flow->rss_conf.queue_num; ++i) { struct rte_flow *tmp; int mark = 0; @@ -2334,19 +2315,19 @@ mlx5_flow_start(struct rte_eth_dev *dev, struct mlx5_flows *list) if (!flow->frxq[i].ibv_attr) continue; flow->frxq[i].hrxq = - mlx5_hrxq_get(dev, flow->rss_conf.rss_key, - flow->rss_conf.rss_key_len, + mlx5_hrxq_get(dev, flow->rss_conf.key, + flow->rss_conf.key_len, hash_rxq_init[i].hash_fields, - (*flow->queues), - flow->queues_n); + flow->rss_conf.queue, + flow->rss_conf.queue_num); if (flow->frxq[i].hrxq) goto flow_create; flow->frxq[i].hrxq = - mlx5_hrxq_new(dev, flow->rss_conf.rss_key, - flow->rss_conf.rss_key_len, + mlx5_hrxq_new(dev, flow->rss_conf.key, + flow->rss_conf.key_len, hash_rxq_init[i].hash_fields, - (*flow->queues), - flow->queues_n); + flow->rss_conf.queue, + flow->rss_conf.queue_num); if (!flow->frxq[i].hrxq) { DRV_LOG(DEBUG, "port %u flow %p cannot be applied", @@ -2370,8 +2351,8 @@ mlx5_flow_start(struct rte_eth_dev *dev, struct mlx5_flows *list) } if (!flow->mark) continue; - for (i = 0; i != flow->queues_n; ++i) - (*priv->rxqs)[(*flow->queues)[i]]->mark = 1; + for (i = 0; i != flow->rss_conf.queue_num; ++i) + (*priv->rxqs)[flow->rss_conf.queue[i]]->mark = 1; } return 0; } @@ -2448,8 +2429,10 @@ mlx5_ctrl_flow_vlan(struct rte_eth_dev *dev, }; uint16_t queue[priv->reta_idx_n]; struct rte_flow_action_rss action_rss = { - .rss_conf = &priv->rss_conf, - .num = priv->reta_idx_n, + .types = priv->rss_conf.rss_hf, + .key_len = priv->rss_conf.rss_key_len, + .queue_num = priv->reta_idx_n, + .key = priv->rss_conf.rss_key, .queue = queue, }; struct rte_flow_action actions[] = { diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c index 1b4570586..1e4354ab3 100644 --- a/drivers/net/mlx5/mlx5_rxq.c +++ b/drivers/net/mlx5/mlx5_rxq.c @@ -1218,8 +1218,8 @@ mlx5_rxq_verify(struct rte_eth_dev *dev) * The Verbs object initialised, NULL otherwise and rte_errno is set. */ struct mlx5_ind_table_ibv * -mlx5_ind_table_ibv_new(struct rte_eth_dev *dev, uint16_t queues[], - uint16_t queues_n) +mlx5_ind_table_ibv_new(struct rte_eth_dev *dev, const uint16_t *queues, + uint32_t queues_n) { struct priv *priv = dev->data->dev_private; struct mlx5_ind_table_ibv *ind_tbl; @@ -1286,8 +1286,8 @@ mlx5_ind_table_ibv_new(struct rte_eth_dev *dev, uint16_t queues[], * An indirection table if found. */ struct mlx5_ind_table_ibv * -mlx5_ind_table_ibv_get(struct rte_eth_dev *dev, uint16_t queues[], - uint16_t queues_n) +mlx5_ind_table_ibv_get(struct rte_eth_dev *dev, const uint16_t *queues, + uint32_t queues_n) { struct priv *priv = dev->data->dev_private; struct mlx5_ind_table_ibv *ind_tbl; @@ -1391,8 +1391,10 @@ mlx5_ind_table_ibv_verify(struct rte_eth_dev *dev) * The Verbs object initialised, NULL otherwise and rte_errno is set. */ struct mlx5_hrxq * -mlx5_hrxq_new(struct rte_eth_dev *dev, uint8_t *rss_key, uint8_t rss_key_len, - uint64_t hash_fields, uint16_t queues[], uint16_t queues_n) +mlx5_hrxq_new(struct rte_eth_dev *dev, + const uint8_t *rss_key, uint32_t rss_key_len, + uint64_t hash_fields, + const uint16_t *queues, uint32_t queues_n) { struct priv *priv = dev->data->dev_private; struct mlx5_hrxq *hrxq; @@ -1419,7 +1421,7 @@ mlx5_hrxq_new(struct rte_eth_dev *dev, uint8_t *rss_key, uint8_t rss_key_len, .rx_hash_conf = (struct ibv_rx_hash_conf){ .rx_hash_function = IBV_RX_HASH_FUNC_TOEPLITZ, .rx_hash_key_len = rss_key_len, - .rx_hash_key = rss_key, + .rx_hash_key = (void *)(uintptr_t)rss_key, .rx_hash_fields_mask = hash_fields, }, .rwq_ind_tbl = ind_tbl->ind_table, @@ -1469,8 +1471,10 @@ mlx5_hrxq_new(struct rte_eth_dev *dev, uint8_t *rss_key, uint8_t rss_key_len, * An hash Rx queue on success. */ struct mlx5_hrxq * -mlx5_hrxq_get(struct rte_eth_dev *dev, uint8_t *rss_key, uint8_t rss_key_len, - uint64_t hash_fields, uint16_t queues[], uint16_t queues_n) +mlx5_hrxq_get(struct rte_eth_dev *dev, + const uint8_t *rss_key, uint32_t rss_key_len, + uint64_t hash_fields, + const uint16_t *queues, uint32_t queues_n) { struct priv *priv = dev->data->dev_private; struct mlx5_hrxq *hrxq; diff --git a/drivers/net/mlx5/mlx5_rxtx.h b/drivers/net/mlx5/mlx5_rxtx.h index f5af43735..a702cb603 100644 --- a/drivers/net/mlx5/mlx5_rxtx.h +++ b/drivers/net/mlx5/mlx5_rxtx.h @@ -134,7 +134,7 @@ struct mlx5_ind_table_ibv { LIST_ENTRY(mlx5_ind_table_ibv) next; /* Pointer to the next element. */ rte_atomic32_t refcnt; /* Reference counter. */ struct ibv_rwq_ind_table *ind_table; /**< Indirection table. */ - uint16_t queues_n; /**< Number of queues in the list. */ + uint32_t queues_n; /**< Number of queues in the list. */ uint16_t queues[]; /**< Queue list. */ }; @@ -145,7 +145,7 @@ struct mlx5_hrxq { struct mlx5_ind_table_ibv *ind_table; /* Indirection table. */ struct ibv_qp *qp; /* Verbs queue pair. */ uint64_t hash_fields; /* Verbs Hash fields. */ - uint8_t rss_key_len; /* Hash key length in bytes. */ + uint32_t rss_key_len; /* Hash key length in bytes. */ uint8_t rss_key[]; /* Hash key. */ }; @@ -237,20 +237,22 @@ int mlx5_rxq_releasable(struct rte_eth_dev *dev, uint16_t idx); int mlx5_rxq_verify(struct rte_eth_dev *dev); int rxq_alloc_elts(struct mlx5_rxq_ctrl *rxq_ctrl); struct mlx5_ind_table_ibv *mlx5_ind_table_ibv_new(struct rte_eth_dev *dev, - uint16_t queues[], - uint16_t queues_n); + const uint16_t *queues, + uint32_t queues_n); struct mlx5_ind_table_ibv *mlx5_ind_table_ibv_get(struct rte_eth_dev *dev, - uint16_t queues[], - uint16_t queues_n); + const uint16_t *queues, + uint32_t queues_n); int mlx5_ind_table_ibv_release(struct rte_eth_dev *dev, struct mlx5_ind_table_ibv *ind_tbl); int mlx5_ind_table_ibv_verify(struct rte_eth_dev *dev); -struct mlx5_hrxq *mlx5_hrxq_new(struct rte_eth_dev *dev, uint8_t *rss_key, - uint8_t rss_key_len, uint64_t hash_fields, - uint16_t queues[], uint16_t queues_n); -struct mlx5_hrxq *mlx5_hrxq_get(struct rte_eth_dev *dev, uint8_t *rss_key, - uint8_t rss_key_len, uint64_t hash_fields, - uint16_t queues[], uint16_t queues_n); +struct mlx5_hrxq *mlx5_hrxq_new(struct rte_eth_dev *dev, + const uint8_t *rss_key, uint32_t rss_key_len, + uint64_t hash_fields, + const uint16_t *queues, uint32_t queues_n); +struct mlx5_hrxq *mlx5_hrxq_get(struct rte_eth_dev *dev, + const uint8_t *rss_key, uint32_t rss_key_len, + uint64_t hash_fields, + const uint16_t *queues, uint32_t queues_n); int mlx5_hrxq_release(struct rte_eth_dev *dev, struct mlx5_hrxq *hxrq); int mlx5_hrxq_ibv_verify(struct rte_eth_dev *dev); uint64_t mlx5_get_rx_port_offloads(void); diff --git a/drivers/net/sfc/sfc_flow.c b/drivers/net/sfc/sfc_flow.c index fb61ec73a..2210f4297 100644 --- a/drivers/net/sfc/sfc_flow.c +++ b/drivers/net/sfc/sfc_flow.c @@ -1235,13 +1235,11 @@ sfc_flow_parse_rss(struct sfc_adapter *sa, struct sfc_rxq *rxq; unsigned int rxq_hw_index_min; unsigned int rxq_hw_index_max; - const struct rte_eth_rss_conf *rss_conf = rss->rss_conf; - uint64_t rss_hf; - uint8_t *rss_key = NULL; + const uint8_t *rss_key; struct sfc_flow_rss *sfc_rss_conf = &flow->rss_conf; unsigned int i; - if (rss->num == 0) + if (rss->queue_num == 0) return -EINVAL; rxq_sw_index = sa->rxq_count - 1; @@ -1249,7 +1247,7 @@ sfc_flow_parse_rss(struct sfc_adapter *sa, rxq_hw_index_min = rxq->hw_index; rxq_hw_index_max = 0; - for (i = 0; i < rss->num; ++i) { + for (i = 0; i < rss->queue_num; ++i) { rxq_sw_index = rss->queue[i]; if (rxq_sw_index >= sa->rxq_count) @@ -1264,15 +1262,14 @@ sfc_flow_parse_rss(struct sfc_adapter *sa, rxq_hw_index_max = rxq->hw_index; } - rss_hf = (rss_conf != NULL) ? rss_conf->rss_hf : SFC_RSS_OFFLOADS; - if ((rss_hf & ~SFC_RSS_OFFLOADS) != 0) + if ((rss->types & ~SFC_RSS_OFFLOADS) != 0) return -EINVAL; - if (rss_conf != NULL) { - if (rss_conf->rss_key_len != sizeof(sa->rss_key)) + if (rss->key_len) { + if (rss->key_len != sizeof(sa->rss_key)) return -EINVAL; - rss_key = rss_conf->rss_key; + rss_key = rss->key; } else { rss_key = sa->rss_key; } @@ -1281,11 +1278,11 @@ sfc_flow_parse_rss(struct sfc_adapter *sa, sfc_rss_conf->rxq_hw_index_min = rxq_hw_index_min; sfc_rss_conf->rxq_hw_index_max = rxq_hw_index_max; - sfc_rss_conf->rss_hash_types = sfc_rte_to_efx_hash_type(rss_hf); + sfc_rss_conf->rss_hash_types = sfc_rte_to_efx_hash_type(rss->types); rte_memcpy(sfc_rss_conf->rss_key, rss_key, sizeof(sa->rss_key)); for (i = 0; i < RTE_DIM(sfc_rss_conf->rss_tbl); ++i) { - unsigned int rxq_sw_index = rss->queue[i % rss->num]; + unsigned int rxq_sw_index = rss->queue[i % rss->queue_num]; struct sfc_rxq *rxq = sa->rxq_info[rxq_sw_index].rxq; sfc_rss_conf->rss_tbl[i] = rxq->hw_index - rxq_hw_index_min; diff --git a/drivers/net/tap/tap_flow.c b/drivers/net/tap/tap_flow.c index aea3462a6..78f20913f 100644 --- a/drivers/net/tap/tap_flow.c +++ b/drivers/net/tap/tap_flow.c @@ -1215,7 +1215,7 @@ priv_flow_process(struct pmd_internals *pmd, if (err) goto exit_action_not_supported; } - if (flow && rss) + if (flow) err = rss_add_actions(flow, pmd, rss, error); } else { goto exit_action_not_supported; @@ -2050,7 +2050,7 @@ static int rss_add_actions(struct rte_flow *flow, struct pmd_internals *pmd, struct rte_flow_error *error) { /* 4096 is the maximum number of instructions for a BPF program */ - int i; + unsigned int i; int err; struct rss_key rss_entry = { .hash_fields = 0, .key_size = 0 }; @@ -2066,8 +2066,8 @@ static int rss_add_actions(struct rte_flow *flow, struct pmd_internals *pmd, } /* Update RSS map entry with queues */ - rss_entry.nb_queues = rss->num; - for (i = 0; i < rss->num; i++) + rss_entry.nb_queues = rss->queue_num; + for (i = 0; i < rss->queue_num; i++) rss_entry.queues[i] = rss->queue[i]; rss_entry.hash_fields = (1 << HASH_FIELD_IPV4_L3_L4) | (1 << HASH_FIELD_IPV6_L3_L4); diff --git a/examples/ipsec-secgw/ipsec.c b/examples/ipsec-secgw/ipsec.c index 8b2047adb..3ce76c413 100644 --- a/examples/ipsec-secgw/ipsec.c +++ b/examples/ipsec-secgw/ipsec.c @@ -202,9 +202,13 @@ create_session(struct ipsec_ctx *ipsec_ctx, struct ipsec_sa *sa) i < eth_dev->data->nb_rx_queues; ++i) if (eth_dev->data->rx_queues[i]) queue[j++] = i; - action_rss.rss_conf = &rss_conf; - action_rss.num = j; - action_rss.queue = queue; + action_rss = (struct rte_flow_action_rss){ + .types = rss_conf.rss_hf, + .key_len = rss_conf.rss_key_len, + .queue_num = j, + .key = rss_key, + .queue = queue, + }; ret = rte_flow_validate(sa->portid, &sa->attr, sa->pattern, sa->action, &err); diff --git a/lib/librte_ether/rte_flow.c b/lib/librte_ether/rte_flow.c index 550086411..2fabc9a29 100644 --- a/lib/librte_ether/rte_flow.c +++ b/lib/librte_ether/rte_flow.c @@ -330,40 +330,27 @@ flow_action_conf_copy(void *buf, const struct rte_flow_action *action) off = 0; if (dst.rss) *dst.rss = (struct rte_flow_action_rss){ - .num = src.rss->num, + .types = src.rss->types, + .key_len = src.rss->key_len, + .queue_num = src.rss->queue_num, }; off += sizeof(*src.rss); - if (src.rss->num) { + if (src.rss->key_len) { off = RTE_ALIGN_CEIL(off, sizeof(double)); - size = sizeof(*src.rss->queue) * src.rss->num; + size = sizeof(*src.rss->key) * src.rss->key_len; if (dst.rss) - dst.rss->queue = memcpy + dst.rss->key = memcpy ((void *)((uintptr_t)dst.rss + off), - src.rss->queue, size); + src.rss->key, size); off += size; } - off = RTE_ALIGN_CEIL(off, sizeof(double)); - if (dst.rss) { - dst.rss->rss_conf = (void *)((uintptr_t)dst.rss + off); - *(struct rte_eth_rss_conf *)(uintptr_t) - dst.rss->rss_conf = (struct rte_eth_rss_conf){ - .rss_key_len = src.rss->rss_conf->rss_key_len, - .rss_hf = src.rss->rss_conf->rss_hf, - }; - } - off += sizeof(*src.rss->rss_conf); - if (src.rss->rss_conf->rss_key_len) { + if (src.rss->queue_num) { off = RTE_ALIGN_CEIL(off, sizeof(double)); - size = sizeof(*src.rss->rss_conf->rss_key) * - src.rss->rss_conf->rss_key_len; - if (dst.rss) { - ((struct rte_eth_rss_conf *)(uintptr_t) - dst.rss->rss_conf)->rss_key = - (void *)((uintptr_t)dst.rss + off); - memcpy(dst.rss->rss_conf->rss_key, - src.rss->rss_conf->rss_key, - size); - } + size = sizeof(*src.rss->queue) * src.rss->queue_num; + if (dst.rss) + dst.rss->queue = memcpy + ((void *)((uintptr_t)dst.rss + off), + src.rss->queue, size); off += size; } size = off; diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index 532a9edab..a71c4a1db 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -1037,8 +1037,10 @@ struct rte_flow_query_count { * both can be requested simultaneously. */ struct rte_flow_action_rss { - const struct rte_eth_rss_conf *rss_conf; /**< RSS parameters. */ - uint16_t num; /**< Number of entries in @p queue. */ + uint64_t types; /**< RSS hash types (see ETH_RSS_*). */ + uint32_t key_len; /**< Hash key length in bytes. */ + uint32_t queue_num; /**< Number of entries in @p queue. */ + const uint8_t *key; /**< Hash key. */ const uint16_t *queue; /**< Queue indices to use. */ }; -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v1 09/16] ethdev: add hash function to RSS flow API action 2018-04-04 15:56 [dpdk-dev] [PATCH v1 00/16] Flow API overhaul for switch offloads Adrien Mazarguil ` (7 preceding siblings ...) 2018-04-04 15:56 ` [dpdk-dev] [PATCH v1 08/16] ethdev: flatten RSS configuration in " Adrien Mazarguil @ 2018-04-04 15:56 ` Adrien Mazarguil 2018-04-04 15:56 ` [dpdk-dev] [PATCH v1 10/16] ethdev: add encap level " Adrien Mazarguil ` (7 subsequent siblings) 16 siblings, 0 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-04 15:56 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev Cc: Wenzhuo Lu, Jingjing Wu, Beilei Xing, Qi Zhang, Konstantin Ananyev, Nelio Laranjeiro, Yongseok Koh, Andrew Rybchenko, Pascal Mazon By definition, RSS involves some kind of hash algorithm, usually Toeplitz. Until now it could not be modified on a flow rule basis and PMDs had to always assume RTE_ETH_HASH_FUNCTION_DEFAULT, which remains the default behavior when unspecified (0). Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Cc: Ferruh Yigit <ferruh.yigit@intel.com> Cc: Thomas Monjalon <thomas@monjalon.net> Cc: Wenzhuo Lu <wenzhuo.lu@intel.com> Cc: Jingjing Wu <jingjing.wu@intel.com> Cc: Beilei Xing <beilei.xing@intel.com> Cc: Qi Zhang <qi.z.zhang@intel.com> Cc: Konstantin Ananyev <konstantin.ananyev@intel.com> Cc: Nelio Laranjeiro <nelio.laranjeiro@6wind.com> Cc: Yongseok Koh <yskoh@mellanox.com> Cc: Andrew Rybchenko <arybchenko@solarflare.com> Cc: Pascal Mazon <pascal.mazon@6wind.com> --- app/test-pmd/cmdline_flow.c | 72 ++++++++++++++++++++++++ app/test-pmd/config.c | 1 + doc/guides/prog_guide/rte_flow.rst | 2 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 3 + drivers/net/e1000/igb_flow.c | 4 ++ drivers/net/e1000/igb_rxtx.c | 4 +- drivers/net/i40e/i40e_ethdev.c | 4 +- drivers/net/i40e/i40e_flow.c | 4 ++ drivers/net/ixgbe/ixgbe_flow.c | 4 ++ drivers/net/ixgbe/ixgbe_rxtx.c | 4 +- drivers/net/mlx4/mlx4_flow.c | 7 +++ drivers/net/mlx5/mlx5_flow.c | 13 +++++ drivers/net/sfc/sfc_flow.c | 3 + drivers/net/tap/tap_flow.c | 6 ++ lib/librte_ether/rte_flow.c | 1 + lib/librte_ether/rte_flow.h | 2 + 16 files changed, 131 insertions(+), 3 deletions(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 0322f36c4..23e10d623 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -14,6 +14,7 @@ #include <sys/socket.h> #include <rte_common.h> +#include <rte_eth_ctrl.h> #include <rte_ethdev.h> #include <rte_byteorder.h> #include <cmdline_parse.h> @@ -165,6 +166,10 @@ enum index { ACTION_DROP, ACTION_COUNT, ACTION_RSS, + ACTION_RSS_FUNC, + ACTION_RSS_FUNC_DEFAULT, + ACTION_RSS_FUNC_TOEPLITZ, + ACTION_RSS_FUNC_SIMPLE_XOR, ACTION_RSS_TYPES, ACTION_RSS_TYPE, ACTION_RSS_KEY, @@ -632,6 +637,7 @@ static const enum index action_queue[] = { }; static const enum index action_rss[] = { + ACTION_RSS_FUNC, ACTION_RSS_TYPES, ACTION_RSS_KEY, ACTION_RSS_KEY_LEN, @@ -666,6 +672,9 @@ static int parse_vc_conf(struct context *, const struct token *, static int parse_vc_action_rss(struct context *, const struct token *, const char *, unsigned int, void *, unsigned int); +static int parse_vc_action_rss_func(struct context *, const struct token *, + const char *, unsigned int, void *, + unsigned int); static int parse_vc_action_rss_type(struct context *, const struct token *, const char *, unsigned int, void *, unsigned int); @@ -1584,6 +1593,29 @@ static const struct token token_list[] = { .next = NEXT(action_rss), .call = parse_vc_action_rss, }, + [ACTION_RSS_FUNC] = { + .name = "func", + .help = "RSS hash function to apply", + .next = NEXT(action_rss, + NEXT_ENTRY(ACTION_RSS_FUNC_DEFAULT, + ACTION_RSS_FUNC_TOEPLITZ, + ACTION_RSS_FUNC_SIMPLE_XOR)), + }, + [ACTION_RSS_FUNC_DEFAULT] = { + .name = "default", + .help = "default hash function", + .call = parse_vc_action_rss_func, + }, + [ACTION_RSS_FUNC_TOEPLITZ] = { + .name = "toeplitz", + .help = "Toeplitz hash function", + .call = parse_vc_action_rss_func, + }, + [ACTION_RSS_FUNC_SIMPLE_XOR] = { + .name = "simple_xor", + .help = "simple XOR hash function", + .call = parse_vc_action_rss_func, + }, [ACTION_RSS_TYPES] = { .name = "types", .help = "RSS hash types", @@ -2074,6 +2106,7 @@ parse_vc_action_rss(struct context *ctx, const struct token *token, action_rss_data = ctx->object; *action_rss_data = (struct action_rss_data){ .conf = (struct rte_flow_action_rss){ + .func = RTE_ETH_HASH_FUNCTION_DEFAULT, .types = rss_hf, .key_len = sizeof(action_rss_data->key), .queue_num = RTE_MIN(nb_rxq, ACTION_RSS_QUEUE_NUM), @@ -2111,6 +2144,45 @@ parse_vc_action_rss(struct context *ctx, const struct token *token, } /** + * Parse func field for RSS action. + * + * The RTE_ETH_HASH_FUNCTION_* value to assign is derived from the + * ACTION_RSS_FUNC_* index that called this function. + */ +static int +parse_vc_action_rss_func(struct context *ctx, const struct token *token, + const char *str, unsigned int len, + void *buf, unsigned int size) +{ + struct action_rss_data *action_rss_data; + enum rte_eth_hash_function func; + + (void)buf; + (void)size; + /* Token name must match. */ + if (parse_default(ctx, token, str, len, NULL, 0) < 0) + return -1; + switch (ctx->curr) { + case ACTION_RSS_FUNC_DEFAULT: + func = RTE_ETH_HASH_FUNCTION_DEFAULT; + break; + case ACTION_RSS_FUNC_TOEPLITZ: + func = RTE_ETH_HASH_FUNCTION_TOEPLITZ; + break; + case ACTION_RSS_FUNC_SIMPLE_XOR: + func = RTE_ETH_HASH_FUNCTION_SIMPLE_XOR; + break; + default: + return -1; + } + if (!ctx->object) + return len; + action_rss_data = ctx->object; + action_rss_data->conf.func = func; + return len; +} + +/** * Parse type field for RSS action. * * Valid tokens are type field names and the "end" token. diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 717f31774..b258c93e8 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -1084,6 +1084,7 @@ flow_action_conf_copy(void *buf, const struct rte_flow_action *action) off = 0; if (dst.rss) *dst.rss = (struct rte_flow_action_rss){ + .func = src.rss->func, .types = src.rss->types, .key_len = src.rss->key_len, .queue_num = src.rss->queue_num, diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index a7c3d6ccc..6261233bc 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -1311,6 +1311,8 @@ field only, both can be requested simultaneously. +---------------+------------------------------------+ | Field | Value | +===============+====================================+ + | ``func`` | RSS hash function to apply | + +---------------+------------------------------------+ | ``types`` | RSS hash types (see ``ETH_RSS_*``) | +---------------+------------------------------------+ | ``key_len`` | hash key length in bytes | diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index a015d02a4..d9d68ad9b 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3398,6 +3398,9 @@ This section lists supported actions and their attributes, if any. - ``rss``: spread packets among several queues. + - ``func {hash function}``: RSS hash function to apply, allowed tokens are + the same as `set_hash_global_config`_. + - ``types [{RSS hash type} [...]] end``: RSS hash types, allowed tokens are the same as `set_hash_input_set`_, an empty list means none (0). diff --git a/drivers/net/e1000/igb_flow.c b/drivers/net/e1000/igb_flow.c index 8dc5f75f2..747c524f5 100644 --- a/drivers/net/e1000/igb_flow.c +++ b/drivers/net/e1000/igb_flow.c @@ -1310,6 +1310,10 @@ igb_parse_rss_filter(struct rte_eth_dev *dev, } } + if (rss->func) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, + "non-default RSS hash functions are not supported"); if (rss->key_len && rss->key_len != RTE_DIM(rss_conf->key)) return rte_flow_error_set (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, diff --git a/drivers/net/e1000/igb_rxtx.c b/drivers/net/e1000/igb_rxtx.c index 292b16ab2..18367f443 100644 --- a/drivers/net/e1000/igb_rxtx.c +++ b/drivers/net/e1000/igb_rxtx.c @@ -2766,6 +2766,7 @@ igb_rss_conf_init(struct igb_rte_flow_rss_conf *out, in->queue_num > RTE_DIM(out->queue)) return -EINVAL; out->conf = (struct rte_flow_action_rss){ + .func = in->func, .types = in->types, .key_len = in->key_len, .queue_num = in->queue_num, @@ -2780,7 +2781,8 @@ int igb_action_rss_same(const struct rte_flow_action_rss *comp, const struct rte_flow_action_rss *with) { - return (comp->types == with->types && + return (comp->func == with->func && + comp->types == with->types && comp->key_len == with->key_len && comp->queue_num == with->queue_num && !memcmp(comp->key, with->key, with->key_len) && diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index a10799cb7..c503d7de2 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c @@ -11962,6 +11962,7 @@ i40e_rss_conf_init(struct i40e_rte_flow_rss_conf *out, in->queue_num > RTE_DIM(out->queue)) return -EINVAL; out->conf = (struct rte_flow_action_rss){ + .func = in->func, .types = in->types, .key_len = in->key_len, .queue_num = in->queue_num, @@ -11976,7 +11977,8 @@ int i40e_action_rss_same(const struct rte_flow_action_rss *comp, const struct rte_flow_action_rss *with) { - return (comp->types == with->types && + return (comp->func == with->func && + comp->types == with->types && comp->key_len == with->key_len && comp->queue_num == with->queue_num && !memcmp(comp->key, with->key, with->key_len) && diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c index 072cebb16..65ee27917 100644 --- a/drivers/net/i40e/i40e_flow.c +++ b/drivers/net/i40e/i40e_flow.c @@ -4324,6 +4324,10 @@ i40e_flow_parse_rss_action(struct rte_eth_dev *dev, } } + if (rss->func) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, + "non-default RSS hash functions are not supported"); if (rss->key_len && rss->key_len > RTE_DIM(rss_config->key)) return rte_flow_error_set (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, diff --git a/drivers/net/ixgbe/ixgbe_flow.c b/drivers/net/ixgbe/ixgbe_flow.c index 4e31c7c56..10056a0f7 100644 --- a/drivers/net/ixgbe/ixgbe_flow.c +++ b/drivers/net/ixgbe/ixgbe_flow.c @@ -2779,6 +2779,10 @@ ixgbe_parse_rss_filter(struct rte_eth_dev *dev, } } + if (rss->func) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, + "non-default RSS hash functions are not supported"); if (rss->key_len && rss->key_len != RTE_DIM(rss_conf->key)) return rte_flow_error_set (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, diff --git a/drivers/net/ixgbe/ixgbe_rxtx.c b/drivers/net/ixgbe/ixgbe_rxtx.c index e86b108d3..4f46eeb2b 100644 --- a/drivers/net/ixgbe/ixgbe_rxtx.c +++ b/drivers/net/ixgbe/ixgbe_rxtx.c @@ -5529,6 +5529,7 @@ ixgbe_rss_conf_init(struct ixgbe_rte_flow_rss_conf *out, in->queue_num > RTE_DIM(out->queue)) return -EINVAL; out->conf = (struct rte_flow_action_rss){ + .func = in->func, .types = in->types, .key_len = in->key_len, .queue_num = in->queue_num, @@ -5543,7 +5544,8 @@ int ixgbe_action_rss_same(const struct rte_flow_action_rss *comp, const struct rte_flow_action_rss *with) { - return (comp->types == with->types && + return (comp->func == with->func && + comp->types == with->types && comp->key_len == with->key_len && comp->queue_num == with->queue_num && !memcmp(comp->key, with->key, with->key_len) && diff --git a/drivers/net/mlx4/mlx4_flow.c b/drivers/net/mlx4/mlx4_flow.c index 4dbcaa39c..dcaf8df44 100644 --- a/drivers/net/mlx4/mlx4_flow.c +++ b/drivers/net/mlx4/mlx4_flow.c @@ -790,6 +790,12 @@ mlx4_flow_prepare(struct priv *priv, " of the context size"; goto exit_action_not_supported; } + if (rss->func && + rss->func != RTE_ETH_HASH_FUNCTION_TOEPLITZ) { + msg = "the only supported RSS hash function" + " is Toeplitz"; + goto exit_action_not_supported; + } rte_errno = 0; fields = mlx4_conv_rss_types(priv, rss->types); if (fields == (uint64_t)-1 && rte_errno) { @@ -1283,6 +1289,7 @@ mlx4_flow_internal(struct priv *priv, struct rte_flow_error *error) rte_align32pow2(priv->dev->data->nb_rx_queues + 1) >> 1; uint16_t queue[queues]; struct rte_flow_action_rss action_rss = { + .func = RTE_ETH_HASH_FUNCTION_DEFAULT, .types = -1, .key_len = MLX4_RSS_HASH_KEY_SIZE, .queue_num = queues, diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 7798052f9..0771ad339 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -18,6 +18,7 @@ #endif #include <rte_common.h> +#include <rte_eth_ctrl.h> #include <rte_ethdev_driver.h> #include <rte_flow.h> #include <rte_flow_driver.h> @@ -634,6 +635,15 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, if (overlap & FATE) goto exit_action_overlap; overlap |= FATE; + if (rss->func && + rss->func != RTE_ETH_HASH_FUNCTION_TOEPLITZ) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION, + actions, + "the only supported RSS hash" + " function is Toeplitz"); + return -rte_errno; + } if (rss->types & MLX5_RSS_HF_MASK) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, @@ -683,6 +693,7 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, } } parser->rss_conf = (struct rte_flow_action_rss){ + .func = RTE_ETH_HASH_FUNCTION_DEFAULT, .types = rss->types, .key_len = rss_key_len, .queue_num = rss->queue_num, @@ -1915,6 +1926,7 @@ mlx5_flow_list_create(struct rte_eth_dev *dev, /* Copy configuration. */ flow->queues = (uint16_t (*)[])(flow + 1); flow->rss_conf = (struct rte_flow_action_rss){ + .func = RTE_ETH_HASH_FUNCTION_DEFAULT, .types = parser.rss_conf.types, .key_len = parser.rss_conf.key_len, .queue_num = parser.rss_conf.queue_num, @@ -2429,6 +2441,7 @@ mlx5_ctrl_flow_vlan(struct rte_eth_dev *dev, }; uint16_t queue[priv->reta_idx_n]; struct rte_flow_action_rss action_rss = { + .func = RTE_ETH_HASH_FUNCTION_DEFAULT, .types = priv->rss_conf.rss_hf, .key_len = priv->rss_conf.rss_key_len, .queue_num = priv->reta_idx_n, diff --git a/drivers/net/sfc/sfc_flow.c b/drivers/net/sfc/sfc_flow.c index 2210f4297..d08ba326c 100644 --- a/drivers/net/sfc/sfc_flow.c +++ b/drivers/net/sfc/sfc_flow.c @@ -1262,6 +1262,9 @@ sfc_flow_parse_rss(struct sfc_adapter *sa, rxq_hw_index_max = rxq->hw_index; } + if (rss->func) + return -EINVAL; + if ((rss->types & ~SFC_RSS_OFFLOADS) != 0) return -EINVAL; diff --git a/drivers/net/tap/tap_flow.c b/drivers/net/tap/tap_flow.c index 78f20913f..3d91da216 100644 --- a/drivers/net/tap/tap_flow.c +++ b/drivers/net/tap/tap_flow.c @@ -2055,6 +2055,12 @@ static int rss_add_actions(struct rte_flow *flow, struct pmd_internals *pmd, struct rss_key rss_entry = { .hash_fields = 0, .key_size = 0 }; + /* Check supported hash functions */ + if (rss->func) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, + "non-default RSS hash functions are not supported"); + /* Get a new map key for a new RSS rule */ err = bpf_rss_key(KEY_CMD_GET, &flow->key_idx); if (err < 0) { diff --git a/lib/librte_ether/rte_flow.c b/lib/librte_ether/rte_flow.c index 2fabc9a29..0a2c0ac00 100644 --- a/lib/librte_ether/rte_flow.c +++ b/lib/librte_ether/rte_flow.c @@ -330,6 +330,7 @@ flow_action_conf_copy(void *buf, const struct rte_flow_action *action) off = 0; if (dst.rss) *dst.rss = (struct rte_flow_action_rss){ + .func = src.rss->func, .types = src.rss->types, .key_len = src.rss->key_len, .queue_num = src.rss->queue_num, diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index a71c4a1db..1fc1df9c3 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -19,6 +19,7 @@ #include <rte_arp.h> #include <rte_ether.h> +#include <rte_eth_ctrl.h> #include <rte_icmp.h> #include <rte_ip.h> #include <rte_sctp.h> @@ -1037,6 +1038,7 @@ struct rte_flow_query_count { * both can be requested simultaneously. */ struct rte_flow_action_rss { + enum rte_eth_hash_function func; /**< RSS hash function to apply. */ uint64_t types; /**< RSS hash types (see ETH_RSS_*). */ uint32_t key_len; /**< Hash key length in bytes. */ uint32_t queue_num; /**< Number of entries in @p queue. */ -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v1 10/16] ethdev: add encap level to RSS flow API action 2018-04-04 15:56 [dpdk-dev] [PATCH v1 00/16] Flow API overhaul for switch offloads Adrien Mazarguil ` (8 preceding siblings ...) 2018-04-04 15:56 ` [dpdk-dev] [PATCH v1 09/16] ethdev: add hash function to RSS flow API action Adrien Mazarguil @ 2018-04-04 15:56 ` Adrien Mazarguil 2018-04-04 15:56 ` [dpdk-dev] [PATCH v1 11/16] ethdev: refine TPID handling in flow API Adrien Mazarguil ` (6 subsequent siblings) 16 siblings, 0 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-04 15:56 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev Cc: Xueming Li, Wenzhuo Lu, Jingjing Wu, Beilei Xing, Qi Zhang, Konstantin Ananyev, Nelio Laranjeiro, Yongseok Koh, Andrew Rybchenko, Pascal Mazon RSS hash types (ETH_RSS_* macros defined in rte_ethdev.h) describe the protocol header fields of a packet that must be taken into account while computing RSS. When facing encapsulated (e.g. tunneled) packets, there is an ambiguity as to whether these should apply to inner or outer packets. Applications need the ability to tell exactly "where" RSS must be performed. This is addressed by adding encapsulation level information to the RSS flow action. Its default value is 0 and stands for the usual unspecified behavior. Other values provide a specific encapsulation level. Contrary to the change announced by commit 676b605182a5 ("doc: announce ethdev API change for RSS configuration"), this patch does not affect struct rte_eth_rss_conf but struct rte_flow_action_rss as the former is not used anymore by the RSS flow action. ABI impact is therefore limited to rte_flow. Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Cc: Xueming Li <xuemingl@mellanox.com> Cc: Ferruh Yigit <ferruh.yigit@intel.com> Cc: Thomas Monjalon <thomas@monjalon.net> Cc: Wenzhuo Lu <wenzhuo.lu@intel.com> Cc: Jingjing Wu <jingjing.wu@intel.com> Cc: Beilei Xing <beilei.xing@intel.com> Cc: Qi Zhang <qi.z.zhang@intel.com> Cc: Konstantin Ananyev <konstantin.ananyev@intel.com> Cc: Nelio Laranjeiro <nelio.laranjeiro@6wind.com> Cc: Yongseok Koh <yskoh@mellanox.com> Cc: Andrew Rybchenko <arybchenko@solarflare.com> Cc: Pascal Mazon <pascal.mazon@6wind.com> --- app/test-pmd/cmdline_flow.c | 13 ++++++++++++ app/test-pmd/config.c | 1 + doc/guides/prog_guide/rte_flow.rst | 24 ++++++++++++++++++++++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 2 ++ drivers/net/e1000/igb_flow.c | 4 ++++ drivers/net/e1000/igb_rxtx.c | 2 ++ drivers/net/i40e/i40e_ethdev.c | 2 ++ drivers/net/i40e/i40e_flow.c | 4 ++++ drivers/net/ixgbe/ixgbe_flow.c | 4 ++++ drivers/net/ixgbe/ixgbe_rxtx.c | 2 ++ drivers/net/mlx4/mlx4_flow.c | 6 ++++++ drivers/net/mlx5/mlx5_flow.c | 11 ++++++++++ drivers/net/sfc/sfc_flow.c | 3 +++ drivers/net/tap/tap_flow.c | 6 +++++- lib/librte_ether/rte_flow.c | 1 + lib/librte_ether/rte_flow.h | 26 ++++++++++++++++++++++++ 16 files changed, 110 insertions(+), 1 deletion(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 23e10d623..2fbd3d8ef 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -167,6 +167,7 @@ enum index { ACTION_COUNT, ACTION_RSS, ACTION_RSS_FUNC, + ACTION_RSS_LEVEL, ACTION_RSS_FUNC_DEFAULT, ACTION_RSS_FUNC_TOEPLITZ, ACTION_RSS_FUNC_SIMPLE_XOR, @@ -638,6 +639,7 @@ static const enum index action_queue[] = { static const enum index action_rss[] = { ACTION_RSS_FUNC, + ACTION_RSS_LEVEL, ACTION_RSS_TYPES, ACTION_RSS_KEY, ACTION_RSS_KEY_LEN, @@ -1616,6 +1618,16 @@ static const struct token token_list[] = { .help = "simple XOR hash function", .call = parse_vc_action_rss_func, }, + [ACTION_RSS_LEVEL] = { + .name = "level", + .help = "encapsulation level for \"types\"", + .next = NEXT(action_rss, NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY_ARB + (offsetof(struct action_rss_data, conf) + + offsetof(struct rte_flow_action_rss, level), + sizeof(((struct rte_flow_action_rss *)0)-> + level))), + }, [ACTION_RSS_TYPES] = { .name = "types", .help = "RSS hash types", @@ -2107,6 +2119,7 @@ parse_vc_action_rss(struct context *ctx, const struct token *token, *action_rss_data = (struct action_rss_data){ .conf = (struct rte_flow_action_rss){ .func = RTE_ETH_HASH_FUNCTION_DEFAULT, + .level = 0, .types = rss_hf, .key_len = sizeof(action_rss_data->key), .queue_num = RTE_MIN(nb_rxq, ACTION_RSS_QUEUE_NUM), diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index b258c93e8..c0fefe475 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -1085,6 +1085,7 @@ flow_action_conf_copy(void *buf, const struct rte_flow_action *action) if (dst.rss) *dst.rss = (struct rte_flow_action_rss){ .func = src.rss->func, + .level = src.rss->level, .types = src.rss->types, .key_len = src.rss->key_len, .queue_num = src.rss->queue_num, diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 6261233bc..c893d737a 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -1304,6 +1304,28 @@ Note: RSS hash result is stored in the ``hash.rss`` mbuf field which overlaps ``hash.fdir.lo``. Since `Action: MARK`_ sets the ``hash.fdir.hi`` field only, both can be requested simultaneously. +Also, regarding packet encapsulation ``level``: + +- ``0`` requests the default behavior. Depending on the packet type, it can + mean outermost, innermost, anything in between or even no RSS. + + It basically stands for the innermost encapsulation level RSS can be + performed on according to PMD and device capabilities. + +- ``1`` requests RSS to be performed on the outermost packet encapsulation + level. + +- ``2`` and subsequent values request RSS to be performed on the specified + inner packet encapsulation level, from outermost to innermost (lower to + higher values). + +Values other than ``0`` are not necessarily supported. + +Requesting a specific RSS level on unrecognized traffic results in undefined +behavior. For predictable results, it is recommended to make the flow rule +pattern match packet headers up to the requested encapsulation level so that +only matching traffic goes through. + .. _table_rte_flow_action_rss: .. table:: RSS @@ -1313,6 +1335,8 @@ field only, both can be requested simultaneously. +===============+====================================+ | ``func`` | RSS hash function to apply | +---------------+------------------------------------+ + | ``level`` | encapsulation level for ``types`` | + +---------------+------------------------------------+ | ``types`` | RSS hash types (see ``ETH_RSS_*``) | +---------------+------------------------------------+ | ``key_len`` | hash key length in bytes | diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index d9d68ad9b..738461f44 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3401,6 +3401,8 @@ This section lists supported actions and their attributes, if any. - ``func {hash function}``: RSS hash function to apply, allowed tokens are the same as `set_hash_global_config`_. + - ``level {unsigned}``: encapsulation level for ``types``. + - ``types [{RSS hash type} [...]] end``: RSS hash types, allowed tokens are the same as `set_hash_input_set`_, an empty list means none (0). diff --git a/drivers/net/e1000/igb_flow.c b/drivers/net/e1000/igb_flow.c index 747c524f5..13f6f2a28 100644 --- a/drivers/net/e1000/igb_flow.c +++ b/drivers/net/e1000/igb_flow.c @@ -1314,6 +1314,10 @@ igb_parse_rss_filter(struct rte_eth_dev *dev, return rte_flow_error_set (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, "non-default RSS hash functions are not supported"); + if (rss->level) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, + "a nonzero RSS encapsulation level is not supported"); if (rss->key_len && rss->key_len != RTE_DIM(rss_conf->key)) return rte_flow_error_set (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, diff --git a/drivers/net/e1000/igb_rxtx.c b/drivers/net/e1000/igb_rxtx.c index 18367f443..80407e6bb 100644 --- a/drivers/net/e1000/igb_rxtx.c +++ b/drivers/net/e1000/igb_rxtx.c @@ -2767,6 +2767,7 @@ igb_rss_conf_init(struct igb_rte_flow_rss_conf *out, return -EINVAL; out->conf = (struct rte_flow_action_rss){ .func = in->func, + .level = in->level, .types = in->types, .key_len = in->key_len, .queue_num = in->queue_num, @@ -2782,6 +2783,7 @@ igb_action_rss_same(const struct rte_flow_action_rss *comp, const struct rte_flow_action_rss *with) { return (comp->func == with->func && + comp->level == with->level && comp->types == with->types && comp->key_len == with->key_len && comp->queue_num == with->queue_num && diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index c503d7de2..8f47039a8 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c @@ -11963,6 +11963,7 @@ i40e_rss_conf_init(struct i40e_rte_flow_rss_conf *out, return -EINVAL; out->conf = (struct rte_flow_action_rss){ .func = in->func, + .level = in->level, .types = in->types, .key_len = in->key_len, .queue_num = in->queue_num, @@ -11978,6 +11979,7 @@ i40e_action_rss_same(const struct rte_flow_action_rss *comp, const struct rte_flow_action_rss *with) { return (comp->func == with->func && + comp->level == with->level && comp->types == with->types && comp->key_len == with->key_len && comp->queue_num == with->queue_num && diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c index 65ee27917..1b336df74 100644 --- a/drivers/net/i40e/i40e_flow.c +++ b/drivers/net/i40e/i40e_flow.c @@ -4328,6 +4328,10 @@ i40e_flow_parse_rss_action(struct rte_eth_dev *dev, return rte_flow_error_set (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, "non-default RSS hash functions are not supported"); + if (rss->level) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, + "a nonzero RSS encapsulation level is not supported"); if (rss->key_len && rss->key_len > RTE_DIM(rss_config->key)) return rte_flow_error_set (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, diff --git a/drivers/net/ixgbe/ixgbe_flow.c b/drivers/net/ixgbe/ixgbe_flow.c index 10056a0f7..67d22b382 100644 --- a/drivers/net/ixgbe/ixgbe_flow.c +++ b/drivers/net/ixgbe/ixgbe_flow.c @@ -2783,6 +2783,10 @@ ixgbe_parse_rss_filter(struct rte_eth_dev *dev, return rte_flow_error_set (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, "non-default RSS hash functions are not supported"); + if (rss->level) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, + "a nonzero RSS encapsulation level is not supported"); if (rss->key_len && rss->key_len != RTE_DIM(rss_conf->key)) return rte_flow_error_set (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, diff --git a/drivers/net/ixgbe/ixgbe_rxtx.c b/drivers/net/ixgbe/ixgbe_rxtx.c index 4f46eeb2b..4697ff0c0 100644 --- a/drivers/net/ixgbe/ixgbe_rxtx.c +++ b/drivers/net/ixgbe/ixgbe_rxtx.c @@ -5530,6 +5530,7 @@ ixgbe_rss_conf_init(struct ixgbe_rte_flow_rss_conf *out, return -EINVAL; out->conf = (struct rte_flow_action_rss){ .func = in->func, + .level = in->level, .types = in->types, .key_len = in->key_len, .queue_num = in->queue_num, @@ -5545,6 +5546,7 @@ ixgbe_action_rss_same(const struct rte_flow_action_rss *comp, const struct rte_flow_action_rss *with) { return (comp->func == with->func && + comp->level == with->level && comp->types == with->types && comp->key_len == with->key_len && comp->queue_num == with->queue_num && diff --git a/drivers/net/mlx4/mlx4_flow.c b/drivers/net/mlx4/mlx4_flow.c index dcaf8df44..779641e11 100644 --- a/drivers/net/mlx4/mlx4_flow.c +++ b/drivers/net/mlx4/mlx4_flow.c @@ -796,6 +796,11 @@ mlx4_flow_prepare(struct priv *priv, " is Toeplitz"; goto exit_action_not_supported; } + if (rss->level) { + msg = "a nonzero RSS encapsulation level is" + " not supported"; + goto exit_action_not_supported; + } rte_errno = 0; fields = mlx4_conv_rss_types(priv, rss->types); if (fields == (uint64_t)-1 && rte_errno) { @@ -1290,6 +1295,7 @@ mlx4_flow_internal(struct priv *priv, struct rte_flow_error *error) uint16_t queue[queues]; struct rte_flow_action_rss action_rss = { .func = RTE_ETH_HASH_FUNCTION_DEFAULT, + .level = 0, .types = -1, .key_len = MLX4_RSS_HASH_KEY_SIZE, .queue_num = queues, diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 0771ad339..bc1176819 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -644,6 +644,14 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, " function is Toeplitz"); return -rte_errno; } + if (rss->level) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION, + actions, + "a nonzero RSS encapsulation" + " level is not supported"); + return -rte_errno; + } if (rss->types & MLX5_RSS_HF_MASK) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, @@ -694,6 +702,7 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, } parser->rss_conf = (struct rte_flow_action_rss){ .func = RTE_ETH_HASH_FUNCTION_DEFAULT, + .level = 0, .types = rss->types, .key_len = rss_key_len, .queue_num = rss->queue_num, @@ -1927,6 +1936,7 @@ mlx5_flow_list_create(struct rte_eth_dev *dev, flow->queues = (uint16_t (*)[])(flow + 1); flow->rss_conf = (struct rte_flow_action_rss){ .func = RTE_ETH_HASH_FUNCTION_DEFAULT, + .level = 0, .types = parser.rss_conf.types, .key_len = parser.rss_conf.key_len, .queue_num = parser.rss_conf.queue_num, @@ -2442,6 +2452,7 @@ mlx5_ctrl_flow_vlan(struct rte_eth_dev *dev, uint16_t queue[priv->reta_idx_n]; struct rte_flow_action_rss action_rss = { .func = RTE_ETH_HASH_FUNCTION_DEFAULT, + .level = 0, .types = priv->rss_conf.rss_hf, .key_len = priv->rss_conf.rss_key_len, .queue_num = priv->reta_idx_n, diff --git a/drivers/net/sfc/sfc_flow.c b/drivers/net/sfc/sfc_flow.c index d08ba326c..bf9609735 100644 --- a/drivers/net/sfc/sfc_flow.c +++ b/drivers/net/sfc/sfc_flow.c @@ -1265,6 +1265,9 @@ sfc_flow_parse_rss(struct sfc_adapter *sa, if (rss->func) return -EINVAL; + if (rss->level) + return -EINVAL; + if ((rss->types & ~SFC_RSS_OFFLOADS) != 0) return -EINVAL; diff --git a/drivers/net/tap/tap_flow.c b/drivers/net/tap/tap_flow.c index 3d91da216..e5eb50fc5 100644 --- a/drivers/net/tap/tap_flow.c +++ b/drivers/net/tap/tap_flow.c @@ -2055,11 +2055,15 @@ static int rss_add_actions(struct rte_flow *flow, struct pmd_internals *pmd, struct rss_key rss_entry = { .hash_fields = 0, .key_size = 0 }; - /* Check supported hash functions */ + /* Check supported RSS features */ if (rss->func) return rte_flow_error_set (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, "non-default RSS hash functions are not supported"); + if (rss->level) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, + "a nonzero RSS encapsulation level is not supported"); /* Get a new map key for a new RSS rule */ err = bpf_rss_key(KEY_CMD_GET, &flow->key_idx); diff --git a/lib/librte_ether/rte_flow.c b/lib/librte_ether/rte_flow.c index 0a2c0ac00..1f247d656 100644 --- a/lib/librte_ether/rte_flow.c +++ b/lib/librte_ether/rte_flow.c @@ -331,6 +331,7 @@ flow_action_conf_copy(void *buf, const struct rte_flow_action *action) if (dst.rss) *dst.rss = (struct rte_flow_action_rss){ .func = src.rss->func, + .level = src.rss->level, .types = src.rss->types, .key_len = src.rss->key_len, .queue_num = src.rss->queue_num, diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index 1fc1df9c3..1b222ba60 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -1039,6 +1039,32 @@ struct rte_flow_query_count { */ struct rte_flow_action_rss { enum rte_eth_hash_function func; /**< RSS hash function to apply. */ + /** + * Packet encapsulation level RSS hash @p types apply to. + * + * - @p 0 requests the default behavior. Depending on the packet + * type, it can mean outermost, innermost, anything in between or + * even no RSS. + * + * It basically stands for the innermost encapsulation level RSS + * can be performed on according to PMD and device capabilities. + * + * - @p 1 requests RSS to be performed on the outermost packet + * encapsulation level. + * + * - @p 2 and subsequent values request RSS to be performed on the + * specified inner packet encapsulation level, from outermost to + * innermost (lower to higher values). + * + * Values other than @p 0 are not necessarily supported. + * + * Requesting a specific RSS level on unrecognized traffic results + * in undefined behavior. For predictable results, it is recommended + * to make the flow rule pattern match packet headers up to the + * requested encapsulation level so that only matching traffic goes + * through. + */ + uint32_t level; uint64_t types; /**< RSS hash types (see ETH_RSS_*). */ uint32_t key_len; /**< Hash key length in bytes. */ uint32_t queue_num; /**< Number of entries in @p queue. */ -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v1 11/16] ethdev: refine TPID handling in flow API 2018-04-04 15:56 [dpdk-dev] [PATCH v1 00/16] Flow API overhaul for switch offloads Adrien Mazarguil ` (9 preceding siblings ...) 2018-04-04 15:56 ` [dpdk-dev] [PATCH v1 10/16] ethdev: add encap level " Adrien Mazarguil @ 2018-04-04 15:56 ` Adrien Mazarguil 2018-04-05 9:55 ` Nélio Laranjeiro 2018-04-05 14:20 ` Zhang, Qi Z 2018-04-04 15:56 ` [dpdk-dev] [PATCH v1 12/16] ethdev: add transfer attribute to " Adrien Mazarguil ` (5 subsequent siblings) 16 siblings, 2 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-04 15:56 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev Cc: Wenzhuo Lu, Jingjing Wu, Ajit Khaparde, Somnath Kotur, John Daley, Hyong Youb Kim, Beilei Xing, Qi Zhang, Konstantin Ananyev, Nelio Laranjeiro, Yongseok Koh, Jacek Siuda, Tomasz Duszynski, Dmitri Epshtein, Natalie Samsonov, Jianbo Liu, Andrew Rybchenko, Pascal Mazon TPID handling in rte_flow VLAN and E_TAG pattern item definitions is not consistent with the normal stacking order of pattern items, which is confusing to applications. Problem is that when followed by one of these layers, the EtherType field of the preceding layer keeps its "inner" definition, and the "outer" TPID is provided by the subsequent layer, the reverse of how a packet looks like on the wire: Wire: [ ETH TPID = A | VLAN EtherType = B | B DATA ] rte_flow: [ ETH EtherType = B | VLAN TPID = A | B DATA ] Worse, when QinQ is involved, the stacking order of VLAN layers is unspecified. It is unclear whether it should be reversed (innermost to outermost) as well given TPID applies to the previous layer: Wire: [ ETH TPID = A | VLAN TPID = B | VLAN EtherType = C | C DATA ] rte_flow 1: [ ETH EtherType = C | VLAN TPID = B | VLAN TPID = A | C DATA ] rte_flow 2: [ ETH EtherType = C | VLAN TPID = A | VLAN TPID = B | C DATA ] While specifying EtherType/TPID is hopefully rarely necessary, the stacking order in case of QinQ and the lack of documentation remain an issue. This patch replaces TPID in the VLAN pattern item with an inner EtherType/TPID as is usually done everywhere else (e.g. struct vlan_hdr), clarifies documentation and updates all relevant code. Summary of changes for PMDs that implement ETH, VLAN or E_TAG pattern items: - bnxt: EtherType matching is supported, and vlan->inner_type overrides eth->type if the latter has standard TPID value 0x8100, otherwise an error is triggered. - e1000: EtherType matching is only supported with the ETHERTYPE filter, which does not support VLAN matching, therefore no impact. - enic: same as bnxt. - i40e: same as bnxt with a configurable TPID value for the FDIR filter, with existing limitations on allowed EtherType values. The remaining filter types (VXLAN, NVGRE, QINQ) do not support EtherType matching. - ixgbe: same as e1000. - mlx4: EtherType/TPID matching is not supported, no impact. - mlx5: same as bnxt. - mrvl: EtherType matching is supported but eth->type cannot be specified when a VLAN item is present. However vlan->inner_type is used if specified. - sfc: same as bnxt with QinQ TPID value 0x88a8 additionally supported. - tap: same as bnxt. Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Cc: Ferruh Yigit <ferruh.yigit@intel.com> Cc: Thomas Monjalon <thomas@monjalon.net> Cc: Wenzhuo Lu <wenzhuo.lu@intel.com> Cc: Jingjing Wu <jingjing.wu@intel.com> Cc: Ajit Khaparde <ajit.khaparde@broadcom.com> Cc: Somnath Kotur <somnath.kotur@broadcom.com> Cc: John Daley <johndale@cisco.com> Cc: Hyong Youb Kim <hyonkim@cisco.com> Cc: Beilei Xing <beilei.xing@intel.com> Cc: Qi Zhang <qi.z.zhang@intel.com> Cc: Konstantin Ananyev <konstantin.ananyev@intel.com> Cc: Nelio Laranjeiro <nelio.laranjeiro@6wind.com> Cc: Yongseok Koh <yskoh@mellanox.com> Cc: Jacek Siuda <jck@semihalf.com> Cc: Tomasz Duszynski <tdu@semihalf.com> Cc: Dmitri Epshtein <dima@marvell.com> Cc: Natalie Samsonov <nsamsono@marvell.com> Cc: Jianbo Liu <jianbo.liu@arm.com> Cc: Andrew Rybchenko <arybchenko@solarflare.com> Cc: Pascal Mazon <pascal.mazon@6wind.com> --- Hi PMD maintainers, while I'm pretty confident in these changes, I could not validate them with all devices. It would be great if you could apply this patch, run testpmd, create VLAN flow rules with/without inner EtherType as described and send matching traffic while making sure nothing was broken in the process. Thanks! --- app/test-pmd/cmdline_flow.c | 17 +++--- doc/guides/nics/tap.rst | 2 +- doc/guides/prog_guide/rte_flow.rst | 21 +++++-- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 4 +- drivers/net/bnxt/bnxt_filter.c | 38 ++++++++++-- drivers/net/enic/enic_flow.c | 21 ++++--- drivers/net/i40e/i40e_flow.c | 74 ++++++++++++++++++++---- drivers/net/mlx5/mlx5_flow.c | 14 ++++- drivers/net/mvpp2/mrvl_flow.c | 27 +++++++-- drivers/net/sfc/sfc_flow.c | 27 +++++++++ drivers/net/tap/tap_flow.c | 16 +++-- lib/librte_ether/rte_flow.h | 24 +++++--- 12 files changed, 227 insertions(+), 58 deletions(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 2fbd3d8ef..3a486032d 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -99,11 +99,11 @@ enum index { ITEM_ETH_SRC, ITEM_ETH_TYPE, ITEM_VLAN, - ITEM_VLAN_TPID, ITEM_VLAN_TCI, ITEM_VLAN_PCP, ITEM_VLAN_DEI, ITEM_VLAN_VID, + ITEM_VLAN_INNER_TYPE, ITEM_IPV4, ITEM_IPV4_TOS, ITEM_IPV4_TTL, @@ -505,11 +505,11 @@ static const enum index item_eth[] = { }; static const enum index item_vlan[] = { - ITEM_VLAN_TPID, ITEM_VLAN_TCI, ITEM_VLAN_PCP, ITEM_VLAN_DEI, ITEM_VLAN_VID, + ITEM_VLAN_INNER_TYPE, ITEM_NEXT, ZERO, }; @@ -1142,12 +1142,6 @@ static const struct token token_list[] = { .next = NEXT(item_vlan), .call = parse_vc, }, - [ITEM_VLAN_TPID] = { - .name = "tpid", - .help = "tag protocol identifier", - .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param), - .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vlan, tpid)), - }, [ITEM_VLAN_TCI] = { .name = "tci", .help = "tag control information", @@ -1175,6 +1169,13 @@ static const struct token token_list[] = { .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan, tci, "\x0f\xff")), }, + [ITEM_VLAN_INNER_TYPE] = { + .name = "inner_type", + .help = "inner EtherType", + .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vlan, + inner_type)), + }, [ITEM_IPV4] = { .name = "ipv4", .help = "match IPv4 header", diff --git a/doc/guides/nics/tap.rst b/doc/guides/nics/tap.rst index 76eb0bde4..bcf3efe9e 100644 --- a/doc/guides/nics/tap.rst +++ b/doc/guides/nics/tap.rst @@ -97,7 +97,7 @@ The kernel support can be checked with this command:: Supported items: - eth: src and dst (with variable masks), and eth_type (0xffff mask). -- vlan: vid, pcp, tpid, but not eid. (requires kernel 4.9) +- vlan: vid, pcp, but not eid. (requires kernel 4.9) - ipv4/6: src and dst (with variable masks), and ip_proto (0xffff mask). - udp/tcp: src and dst port (0xffff) mask. diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index c893d737a..f1b9d8d76 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -784,9 +784,15 @@ Item: ``ETH`` Matches an Ethernet header. +The ``type`` field either stands for "EtherType" or "TPID" when followed by +so-called layer 2.5 pattern items such as ``RTE_FLOW_ITEM_TYPE_VLAN``. In +the latter case, ``type`` refers to that of the outer header, with the inner +EtherType/TPID provided by the subsequent pattern item. This is the same +order as on the wire. + - ``dst``: destination MAC. - ``src``: source MAC. -- ``type``: EtherType. +- ``type``: EtherType or TPID. - Default ``mask`` matches destination and source addresses only. Item: ``VLAN`` @@ -794,9 +800,13 @@ Item: ``VLAN`` Matches an 802.1Q/ad VLAN tag. -- ``tpid``: tag protocol identifier. +The corresponding standard outer EtherType (TPID) values are ``0x8100`` or +``0x88a8`` (in case of outer QinQ). It can be overridden by the preceding +pattern item. + - ``tci``: tag control information. -- Default ``mask`` matches TCI only. +- ``inner_type``: inner EtherType or TPID. +- Default ``mask`` matches the VID part of TCI only (lower 12 bits). Item: ``IPV4`` ^^^^^^^^^^^^^^ @@ -866,12 +876,15 @@ Item: ``E_TAG`` Matches an IEEE 802.1BR E-Tag header. -- ``tpid``: tag protocol identifier (0x893F) +The corresponding standard outer EtherType (TPID) value is 0x893f. +It can be overridden by the preceding pattern item. + - ``epcp_edei_in_ecid_b``: E-Tag control information (E-TCI), E-PCP (3b), E-DEI (1b), ingress E-CID base (12b). - ``rsvd_grp_ecid_b``: reserved (2b), GRP (2b), E-CID base (12b). - ``in_ecid_e``: ingress E-CID ext. - ``ecid_e``: E-CID ext. +- ``inner_type``: inner EtherType or TPID. - Default ``mask`` simultaneously matches GRP and E-CID base. Item: ``NVGRE`` diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index 738461f44..25fac8430 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3223,15 +3223,15 @@ This section lists supported pattern items and their attributes, if any. - ``dst {MAC-48}``: destination MAC. - ``src {MAC-48}``: source MAC. - - ``type {unsigned}``: EtherType. + - ``type {unsigned}``: EtherType or TPID. - ``vlan``: match 802.1Q/ad VLAN tag. - - ``tpid {unsigned}``: tag protocol identifier. - ``tci {unsigned}``: tag control information. - ``pcp {unsigned}``: priority code point. - ``dei {unsigned}``: drop eligible indicator. - ``vid {unsigned}``: VLAN identifier. + - ``inner_type {unsigned}``: inner EtherType or TPID. - ``ipv4``: match IPv4 header. diff --git a/drivers/net/bnxt/bnxt_filter.c b/drivers/net/bnxt/bnxt_filter.c index 0d735edf6..a97a8dd46 100644 --- a/drivers/net/bnxt/bnxt_filter.c +++ b/drivers/net/bnxt/bnxt_filter.c @@ -327,6 +327,7 @@ bnxt_validate_and_parse_flow_type(struct bnxt *bp, uint32_t vf = 0; int use_ntuple; uint32_t en = 0; + uint32_t en_ethertype; int dflt_vnic; use_ntuple = bnxt_filter_type_check(pattern, error); @@ -336,6 +337,9 @@ bnxt_validate_and_parse_flow_type(struct bnxt *bp, filter->filter_type = use_ntuple ? HWRM_CFA_NTUPLE_FILTER : HWRM_CFA_EM_FILTER; + en_ethertype = use_ntuple ? + NTUPLE_FLTR_ALLOC_INPUT_EN_ETHERTYPE : + EM_FLOW_ALLOC_INPUT_EN_ETHERTYPE; while (item->type != RTE_FLOW_ITEM_TYPE_END) { if (item->last) { @@ -405,30 +409,52 @@ bnxt_validate_and_parse_flow_type(struct bnxt *bp, if (eth_mask->type) { filter->ethertype = rte_be_to_cpu_16(eth_spec->type); - en |= use_ntuple ? - NTUPLE_FLTR_ALLOC_INPUT_EN_ETHERTYPE : - EM_FLOW_ALLOC_INPUT_EN_ETHERTYPE; + en |= en_ethertype; } break; case RTE_FLOW_ITEM_TYPE_VLAN: vlan_spec = item->spec; vlan_mask = item->mask; + if (en & en_ethertype && + filter->ethertype != RTE_BE16(0x8100)) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, + item, + "unsupported outer TPID"); + return -rte_errno; + } if (vlan_mask->tci && - vlan_mask->tci == RTE_BE16(0x0fff) && - !vlan_mask->tpid) { + vlan_mask->tci == RTE_BE16(0x0fff)) { /* Only the VLAN ID can be matched. */ filter->l2_ovlan = rte_be_to_cpu_16(vlan_spec->tci & RTE_BE16(0x0fff)); en |= EM_FLOW_ALLOC_INPUT_EN_OVLAN_VID; - } else if (vlan_mask->tci || vlan_mask->tpid) { + } else if (vlan_mask->tci) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM, item, "VLAN mask is invalid"); return -rte_errno; } + if (vlan_mask->inner_type && + vlan_mask->inner_type != RTE_BE16(0xffff)) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, + item, + "inner ethertype mask not" + " valid"); + return -rte_errno; + } + if (vlan_mask->inner_type) { + filter->ethertype = + rte_be_to_cpu_16(vlan_spec->inner_type); + en |= en_ethertype; + } else { + filter->ethertype = RTE_BE16(0x0000); + en &= ~en_ethertype; + } break; case RTE_FLOW_ITEM_TYPE_IPV4: diff --git a/drivers/net/enic/enic_flow.c b/drivers/net/enic/enic_flow.c index c5c98b870..a413740ab 100644 --- a/drivers/net/enic/enic_flow.c +++ b/drivers/net/enic/enic_flow.c @@ -4,6 +4,7 @@ #include <errno.h> #include <stdint.h> +#include <rte_byteorder.h> #include <rte_log.h> #include <rte_ethdev_driver.h> #include <rte_flow_driver.h> @@ -545,16 +546,22 @@ enic_copy_item_vlan_v2(const struct rte_flow_item *item, if (!spec) return 0; - /* Don't support filtering in tpid */ - if (mask) { - if (mask->tpid != 0) - return ENOTSUP; - } else { + if (!mask) mask = &rte_flow_item_vlan_mask; - RTE_ASSERT(mask->tpid == 0); - } if (*inner_ofst == 0) { + struct ether_hdr *eth_mask = + (void *)gp->layer[FILTER_GENERIC_1_L2].mask; + struct ether_hdr *eth_val = + (void *)gp->layer[FILTER_GENERIC_1_L2].val; + + /* Exactly one TPID value is allowed if specified */ + if ((eth_val->ether_type & eth_mask->ether_type) != + (RTE_BE16(0x8100) & eth_mask->ether_type)) + return ENOTSUP; + eth_mask->ether_type = mask->inner_type; + eth_val->ether_type = spec->inner_type; + /* Outer header. Use the vlan mask/val fields */ gp->mask_vlan = mask->tci; gp->val_vlan = spec->tci; diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c index 1b336df74..c6dd889ad 100644 --- a/drivers/net/i40e/i40e_flow.c +++ b/drivers/net/i40e/i40e_flow.c @@ -2490,24 +2490,36 @@ i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev, "Invalid MAC_addr mask."); return -rte_errno; } + } + if (eth_spec && eth_mask && eth_mask->type) { + enum rte_flow_item_type next = (item + 1)->type; - if ((eth_mask->type & UINT16_MAX) == - UINT16_MAX) { - input_set |= I40E_INSET_LAST_ETHER_TYPE; - filter->input.flow.l2_flow.ether_type = - eth_spec->type; + if (eth_mask->type != RTE_BE16(0xffff)) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, + item, + "Invalid type mask."); + return -rte_errno; } ether_type = rte_be_to_cpu_16(eth_spec->type); - if (ether_type == ETHER_TYPE_IPv4 || - ether_type == ETHER_TYPE_IPv6 || - ether_type == ETHER_TYPE_ARP || - ether_type == outer_tpid) { + + if ((next == RTE_FLOW_ITEM_TYPE_VLAN && + ether_type != outer_tpid) || + (next != RTE_FLOW_ITEM_TYPE_VLAN && + (ether_type == ETHER_TYPE_IPv4 || + ether_type == ETHER_TYPE_IPv6 || + ether_type == ETHER_TYPE_ARP || + ether_type == outer_tpid))) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM, item, "Unsupported ether_type."); return -rte_errno; + } else if (next != RTE_FLOW_ITEM_TYPE_VLAN) { + input_set |= I40E_INSET_LAST_ETHER_TYPE; + filter->input.flow.l2_flow.ether_type = + eth_spec->type; } } @@ -2518,6 +2530,14 @@ i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev, case RTE_FLOW_ITEM_TYPE_VLAN: vlan_spec = item->spec; vlan_mask = item->mask; + + if (input_set & I40E_INSET_LAST_ETHER_TYPE) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, + item, + "Unsupported outer TPID."); + return -rte_errno; + } if (vlan_spec && vlan_mask) { if (vlan_mask->tci == rte_cpu_to_be_16(I40E_TCI_MASK)) { @@ -2526,6 +2546,33 @@ i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev, vlan_spec->tci; } } + if (vlan_spec && vlan_mask && vlan_mask->inner_type) { + if (vlan_mask->inner_type != RTE_BE16(0xffff)) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, + item, + "Invalid inner_type" + " mask."); + return -rte_errno; + } + + ether_type = + rte_be_to_cpu_16(vlan_spec->inner_type); + + if (ether_type == ETHER_TYPE_IPv4 || + ether_type == ETHER_TYPE_IPv6 || + ether_type == ETHER_TYPE_ARP || + ether_type == outer_tpid) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, + item, + "Unsupported inner_type."); + return -rte_errno; + } + input_set |= I40E_INSET_LAST_ETHER_TYPE; + filter->input.flow.l2_flow.ether_type = + vlan_spec->inner_type; + } pctype = I40E_FILTER_PCTYPE_L2_PAYLOAD; layer_idx = I40E_FLXPLD_L2_IDX; @@ -3284,7 +3331,8 @@ i40e_flow_parse_vxlan_pattern(__rte_unused struct rte_eth_dev *dev, case RTE_FLOW_ITEM_TYPE_VLAN: vlan_spec = item->spec; vlan_mask = item->mask; - if (!(vlan_spec && vlan_mask)) { + if (!(vlan_spec && vlan_mask) || + vlan_mask->inner_type) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM, item, @@ -3514,7 +3562,8 @@ i40e_flow_parse_nvgre_pattern(__rte_unused struct rte_eth_dev *dev, case RTE_FLOW_ITEM_TYPE_VLAN: vlan_spec = item->spec; vlan_mask = item->mask; - if (!(vlan_spec && vlan_mask)) { + if (!(vlan_spec && vlan_mask) || + vlan_mask->inner_type) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM, item, @@ -4022,7 +4071,8 @@ i40e_flow_parse_qinq_pattern(__rte_unused struct rte_eth_dev *dev, vlan_spec = item->spec; vlan_mask = item->mask; - if (!(vlan_spec && vlan_mask)) { + if (!(vlan_spec && vlan_mask) || + vlan_mask->inner_type) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM, item, diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index bc1176819..f03413d32 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -17,6 +17,7 @@ #pragma GCC diagnostic error "-Wpedantic" #endif +#include <rte_byteorder.h> #include <rte_common.h> #include <rte_eth_ctrl.h> #include <rte_ethdev_driver.h> @@ -306,6 +307,7 @@ static const struct mlx5_flow_items mlx5_flow_items[] = { .actions = valid_actions, .mask = &(const struct rte_flow_item_vlan){ .tci = -1, + .inner_type = -1, }, .default_mask = &rte_flow_item_vlan_mask, .mask_sz = sizeof(struct rte_flow_item_vlan), @@ -1285,6 +1287,7 @@ mlx5_flow_create_vlan(const struct rte_flow_item *item, struct mlx5_flow_parse *parser = data->parser; struct ibv_flow_spec_eth *eth; const unsigned int eth_size = sizeof(struct ibv_flow_spec_eth); + const char *msg = "VLAN cannot be empty"; if (spec) { unsigned int i; @@ -1306,12 +1309,21 @@ mlx5_flow_create_vlan(const struct rte_flow_item *item, */ if (!eth->mask.vlan_tag) goto error; + /* Exactly one TPID value is allowed if specified. */ + if ((eth->val.ether_type & eth->mask.ether_type) != + (RTE_BE16(0x8100) & eth->mask.ether_type)) { + msg = "unsupported outer TPID"; + goto error; + } + eth->val.ether_type = spec->inner_type; + eth->mask.ether_type = mask->inner_type; + eth->val.ether_type &= eth->mask.ether_type; } return 0; } error: return rte_flow_error_set(data->error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM, - item, "VLAN cannot be empty"); + item, msg); } /** diff --git a/drivers/net/mvpp2/mrvl_flow.c b/drivers/net/mvpp2/mrvl_flow.c index 8fd4dbfb1..6604a411f 100644 --- a/drivers/net/mvpp2/mrvl_flow.c +++ b/drivers/net/mvpp2/mrvl_flow.c @@ -1091,12 +1091,6 @@ mrvl_parse_vlan(const struct rte_flow_item *item, if (ret) return ret; - if (mask->tpid) { - rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM, - NULL, "Not supported by classifier\n"); - return -rte_errno; - } - m = rte_be_to_cpu_16(mask->tci); if (m & MRVL_VLAN_ID_MASK) { RTE_LOG(WARNING, PMD, "vlan id mask is ignored\n"); @@ -1112,6 +1106,27 @@ mrvl_parse_vlan(const struct rte_flow_item *item, goto out; } + if (flow->pattern & F_TYPE) { + rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ITEM, item, + "outer TPID cannot be explicitly matched" + " when VLAN item is also specified\n"); + return -rte_errno; + } + if (mask->inner_type) { + struct rte_flow_item_eth spec_eth = { + .type = spec->inner_type, + }; + struct rte_flow_item_eth mask_eth = { + .type = mask->inner_type, + }; + + RTE_LOG(WARNING, PMD, "inner eth type mask is ignored\n"); + ret = mrvl_parse_type(spec_eth, mask_eth, flow); + if (ret) + goto out; + } + return 0; out: rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, diff --git a/drivers/net/sfc/sfc_flow.c b/drivers/net/sfc/sfc_flow.c index bf9609735..515a61325 100644 --- a/drivers/net/sfc/sfc_flow.c +++ b/drivers/net/sfc/sfc_flow.c @@ -352,6 +352,7 @@ sfc_flow_parse_vlan(const struct rte_flow_item *item, const struct rte_flow_item_vlan *mask = NULL; const struct rte_flow_item_vlan supp_mask = { .tci = rte_cpu_to_be_16(ETH_VLAN_ID_MAX), + .inner_type = RTE_BE16(0xffff), }; rc = sfc_flow_parse_init(item, @@ -394,6 +395,32 @@ sfc_flow_parse_vlan(const struct rte_flow_item *item, return -rte_errno; } + /* + * If an EtherType was already specified, make sure it is a valid + * TPID for the current VLAN layer before overwriting it with the + * specified inner type. + */ + if (efx_spec->efs_match_flags & EFX_FILTER_MATCH_ETHER_TYPE && + efx_spec->efs_ether_type != RTE_BE16(0x8100) && + efx_spec->efs_ether_type != RTE_BE16(0x88a8)) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, item, + "Unsupported outer TPID"); + return -rte_errno; + } + if (!mask->inner_type) { + efx_spec->efs_match_flags &= ~EFX_FILTER_MATCH_ETHER_TYPE; + efx_spec->efs_ether_type = RTE_BE16(0x0000); + } else if (mask->inner_type == supp_mask.inner_type) { + efx_spec->efs_match_flags |= EFX_FILTER_MATCH_ETHER_TYPE; + efx_spec->efs_ether_type = rte_be_to_cpu_16(spec->inner_type); + } else { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, item, + "Bad mask for VLAN inner_type"); + return -rte_errno; + } + return 0; } diff --git a/drivers/net/tap/tap_flow.c b/drivers/net/tap/tap_flow.c index e5eb50fc5..e53eff6ce 100644 --- a/drivers/net/tap/tap_flow.c +++ b/drivers/net/tap/tap_flow.c @@ -270,13 +270,13 @@ static const struct tap_flow_items tap_flow_items[] = { .items = ITEMS(RTE_FLOW_ITEM_TYPE_IPV4, RTE_FLOW_ITEM_TYPE_IPV6), .mask = &(const struct rte_flow_item_vlan){ - .tpid = -1, /* DEI matching is not supported */ #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN .tci = 0xffef, #else .tci = 0xefff, #endif + .inner_type = -1, }, .mask_sz = sizeof(struct rte_flow_item_vlan), .default_mask = &rte_flow_item_vlan_mask, @@ -578,13 +578,21 @@ tap_flow_create_vlan(const struct rte_flow_item *item, void *data) /* use default mask if none provided */ if (!mask) mask = tap_flow_items[RTE_FLOW_ITEM_TYPE_VLAN].default_mask; - /* TC does not support tpid masking. Only accept if exact match. */ - if (mask->tpid && mask->tpid != 0xffff) + /* check that previous eth type is compatible with VLAN */ + if (info->eth_type && info->eth_type != RTE_BE16(ETH_P_8021Q)) return -1; /* Double-tagging not supported. */ - if (spec && mask->tpid && spec->tpid != htons(ETH_P_8021Q)) + if (info->vlan) return -1; info->vlan = 1; + if (mask->inner_type) { + /* TC does not support partial eth_type masking */ + if (mask->inner_type != RTE_BE16(0xffff)) + return -1; + info->eth_type = spec->inner_type; + } else { + info->eth_type = 0; + } if (!flow) return 0; msg = &flow->msg; diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index 1b222ba60..15e383f95 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -454,11 +454,17 @@ static const struct rte_flow_item_raw rte_flow_item_raw_mask = { * RTE_FLOW_ITEM_TYPE_ETH * * Matches an Ethernet header. + * + * The @p type field either stands for "EtherType" or "TPID" when followed + * by so-called layer 2.5 pattern items such as RTE_FLOW_ITEM_TYPE_VLAN. In + * the latter case, @p type refers to that of the outer header, with the + * inner EtherType/TPID provided by the subsequent pattern item. This is the + * same order as on the wire. */ struct rte_flow_item_eth { struct ether_addr dst; /**< Destination MAC. */ struct ether_addr src; /**< Source MAC. */ - rte_be16_t type; /**< EtherType. */ + rte_be16_t type; /**< EtherType or TPID. */ }; /** Default mask for RTE_FLOW_ITEM_TYPE_ETH. */ @@ -475,19 +481,20 @@ static const struct rte_flow_item_eth rte_flow_item_eth_mask = { * * Matches an 802.1Q/ad VLAN tag. * - * This type normally follows either RTE_FLOW_ITEM_TYPE_ETH or - * RTE_FLOW_ITEM_TYPE_VLAN. + * The corresponding standard outer EtherType (TPID) values are 0x8100 or + * 0x88a8 (in case of outer QinQ). It can be overridden by the preceding + * pattern item. */ struct rte_flow_item_vlan { - rte_be16_t tpid; /**< Tag protocol identifier. */ rte_be16_t tci; /**< Tag control information. */ + rte_be16_t inner_type; /**< Inner EtherType or TPID. */ }; /** Default mask for RTE_FLOW_ITEM_TYPE_VLAN. */ #ifndef __cplusplus static const struct rte_flow_item_vlan rte_flow_item_vlan_mask = { - .tpid = RTE_BE16(0x0000), - .tci = RTE_BE16(0xffff), + .tci = RTE_BE16(0x0fff), + .inner_type = RTE_BE16(0x0000), }; #endif @@ -636,9 +643,11 @@ static const struct rte_flow_item_vxlan rte_flow_item_vxlan_mask = { * RTE_FLOW_ITEM_TYPE_E_TAG. * * Matches a E-tag header. + * + * The corresponding standard outer EtherType (TPID) value is 0x893f. + * It can be overridden by the preceding pattern item. */ struct rte_flow_item_e_tag { - rte_be16_t tpid; /**< Tag protocol identifier (0x893F). */ /** * E-Tag control information (E-TCI). * E-PCP (3b), E-DEI (1b), ingress E-CID base (12b). @@ -648,6 +657,7 @@ struct rte_flow_item_e_tag { rte_be16_t rsvd_grp_ecid_b; uint8_t in_ecid_e; /**< Ingress E-CID ext. */ uint8_t ecid_e; /**< E-CID ext. */ + rte_be16_t inner_type; /**< Inner EtherType or TPID. */ }; /** Default mask for RTE_FLOW_ITEM_TYPE_E_TAG. */ -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [dpdk-dev] [PATCH v1 11/16] ethdev: refine TPID handling in flow API 2018-04-04 15:56 ` [dpdk-dev] [PATCH v1 11/16] ethdev: refine TPID handling in flow API Adrien Mazarguil @ 2018-04-05 9:55 ` Nélio Laranjeiro 2018-04-05 12:02 ` Adrien Mazarguil 2018-04-05 14:20 ` Zhang, Qi Z 1 sibling, 1 reply; 157+ messages in thread From: Nélio Laranjeiro @ 2018-04-05 9:55 UTC (permalink / raw) To: Adrien Mazarguil Cc: Thomas Monjalon, Ferruh Yigit, dev, Wenzhuo Lu, Jingjing Wu, Ajit Khaparde, Somnath Kotur, John Daley, Hyong Youb Kim, Beilei Xing, Qi Zhang, Konstantin Ananyev, Yongseok Koh, Jacek Siuda, Tomasz Duszynski, Dmitri Epshtein, Natalie Samsonov, Jianbo Liu, Andrew Rybchenko, Pascal Mazon On Wed, Apr 04, 2018 at 05:56:49PM +0200, Adrien Mazarguil wrote: > TPID handling in rte_flow VLAN and E_TAG pattern item definitions is not > consistent with the normal stacking order of pattern items, which is > confusing to applications. > > Problem is that when followed by one of these layers, the EtherType field > of the preceding layer keeps its "inner" definition, and the "outer" TPID > is provided by the subsequent layer, the reverse of how a packet looks like > on the wire: > > Wire: [ ETH TPID = A | VLAN EtherType = B | B DATA ] > rte_flow: [ ETH EtherType = B | VLAN TPID = A | B DATA ] > > Worse, when QinQ is involved, the stacking order of VLAN layers is > unspecified. It is unclear whether it should be reversed (innermost to > outermost) as well given TPID applies to the previous layer: > > Wire: [ ETH TPID = A | VLAN TPID = B | VLAN EtherType = C | C DATA ] > rte_flow 1: [ ETH EtherType = C | VLAN TPID = B | VLAN TPID = A | C DATA ] > rte_flow 2: [ ETH EtherType = C | VLAN TPID = A | VLAN TPID = B | C DATA ] > > While specifying EtherType/TPID is hopefully rarely necessary, the stacking > order in case of QinQ and the lack of documentation remain an issue. > > This patch replaces TPID in the VLAN pattern item with an inner > EtherType/TPID as is usually done everywhere else (e.g. struct vlan_hdr), > clarifies documentation and updates all relevant code. > > Summary of changes for PMDs that implement ETH, VLAN or E_TAG pattern > items: > > - bnxt: EtherType matching is supported, and vlan->inner_type overrides > eth->type if the latter has standard TPID value 0x8100, otherwise an > error is triggered. > > - e1000: EtherType matching is only supported with the ETHERTYPE filter, > which does not support VLAN matching, therefore no impact. > > - enic: same as bnxt. > > - i40e: same as bnxt with a configurable TPID value for the FDIR filter, > with existing limitations on allowed EtherType values. The remaining > filter types (VXLAN, NVGRE, QINQ) do not support EtherType matching. > > - ixgbe: same as e1000. > > - mlx4: EtherType/TPID matching is not supported, no impact. > > - mlx5: same as bnxt. > > - mrvl: EtherType matching is supported but eth->type cannot be specified > when a VLAN item is present. However vlan->inner_type is used if > specified. > > - sfc: same as bnxt with QinQ TPID value 0x88a8 additionally supported. > > - tap: same as bnxt. > > Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> > Cc: Ferruh Yigit <ferruh.yigit@intel.com> > Cc: Thomas Monjalon <thomas@monjalon.net> > Cc: Wenzhuo Lu <wenzhuo.lu@intel.com> > Cc: Jingjing Wu <jingjing.wu@intel.com> > Cc: Ajit Khaparde <ajit.khaparde@broadcom.com> > Cc: Somnath Kotur <somnath.kotur@broadcom.com> > Cc: John Daley <johndale@cisco.com> > Cc: Hyong Youb Kim <hyonkim@cisco.com> > Cc: Beilei Xing <beilei.xing@intel.com> > Cc: Qi Zhang <qi.z.zhang@intel.com> > Cc: Konstantin Ananyev <konstantin.ananyev@intel.com> > Cc: Nelio Laranjeiro <nelio.laranjeiro@6wind.com> > Cc: Yongseok Koh <yskoh@mellanox.com> > Cc: Jacek Siuda <jck@semihalf.com> > Cc: Tomasz Duszynski <tdu@semihalf.com> > Cc: Dmitri Epshtein <dima@marvell.com> > Cc: Natalie Samsonov <nsamsono@marvell.com> > Cc: Jianbo Liu <jianbo.liu@arm.com> > Cc: Andrew Rybchenko <arybchenko@solarflare.com> > Cc: Pascal Mazon <pascal.mazon@6wind.com> > > --- > > Hi PMD maintainers, while I'm pretty confident in these changes, I could > not validate them with all devices. > > It would be great if you could apply this patch, run testpmd, create VLAN > flow rules with/without inner EtherType as described and send matching > traffic while making sure nothing was broken in the process. > > Thanks! > --- > app/test-pmd/cmdline_flow.c | 17 +++--- > doc/guides/nics/tap.rst | 2 +- > doc/guides/prog_guide/rte_flow.rst | 21 +++++-- > doc/guides/testpmd_app_ug/testpmd_funcs.rst | 4 +- > drivers/net/bnxt/bnxt_filter.c | 38 ++++++++++-- > drivers/net/enic/enic_flow.c | 21 ++++--- > drivers/net/i40e/i40e_flow.c | 74 ++++++++++++++++++++---- > drivers/net/mlx5/mlx5_flow.c | 14 ++++- > drivers/net/mvpp2/mrvl_flow.c | 27 +++++++-- > drivers/net/sfc/sfc_flow.c | 27 +++++++++ > drivers/net/tap/tap_flow.c | 16 +++-- > lib/librte_ether/rte_flow.h | 24 +++++--- > 12 files changed, 227 insertions(+), 58 deletions(-) > > diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c > index 2fbd3d8ef..3a486032d 100644 > --- a/app/test-pmd/cmdline_flow.c > +++ b/app/test-pmd/cmdline_flow.c > @@ -99,11 +99,11 @@ enum index { > ITEM_ETH_SRC, > ITEM_ETH_TYPE, > ITEM_VLAN, > - ITEM_VLAN_TPID, > ITEM_VLAN_TCI, > ITEM_VLAN_PCP, > ITEM_VLAN_DEI, > ITEM_VLAN_VID, > + ITEM_VLAN_INNER_TYPE, > ITEM_IPV4, > ITEM_IPV4_TOS, > ITEM_IPV4_TTL, > @@ -505,11 +505,11 @@ static const enum index item_eth[] = { > }; > > static const enum index item_vlan[] = { > - ITEM_VLAN_TPID, > ITEM_VLAN_TCI, > ITEM_VLAN_PCP, > ITEM_VLAN_DEI, > ITEM_VLAN_VID, > + ITEM_VLAN_INNER_TYPE, > ITEM_NEXT, > ZERO, > }; > @@ -1142,12 +1142,6 @@ static const struct token token_list[] = { > .next = NEXT(item_vlan), > .call = parse_vc, > }, > - [ITEM_VLAN_TPID] = { > - .name = "tpid", > - .help = "tag protocol identifier", > - .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param), > - .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vlan, tpid)), > - }, > [ITEM_VLAN_TCI] = { > .name = "tci", > .help = "tag control information", > @@ -1175,6 +1169,13 @@ static const struct token token_list[] = { > .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan, > tci, "\x0f\xff")), > }, > + [ITEM_VLAN_INNER_TYPE] = { > + .name = "inner_type", > + .help = "inner EtherType", > + .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param), > + .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vlan, > + inner_type)), > + }, > [ITEM_IPV4] = { > .name = "ipv4", > .help = "match IPv4 header", > diff --git a/doc/guides/nics/tap.rst b/doc/guides/nics/tap.rst > index 76eb0bde4..bcf3efe9e 100644 > --- a/doc/guides/nics/tap.rst > +++ b/doc/guides/nics/tap.rst > @@ -97,7 +97,7 @@ The kernel support can be checked with this command:: > Supported items: > > - eth: src and dst (with variable masks), and eth_type (0xffff mask). > -- vlan: vid, pcp, tpid, but not eid. (requires kernel 4.9) > +- vlan: vid, pcp, but not eid. (requires kernel 4.9) > - ipv4/6: src and dst (with variable masks), and ip_proto (0xffff mask). > - udp/tcp: src and dst port (0xffff) mask. > > diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst > index c893d737a..f1b9d8d76 100644 > --- a/doc/guides/prog_guide/rte_flow.rst > +++ b/doc/guides/prog_guide/rte_flow.rst > @@ -784,9 +784,15 @@ Item: ``ETH`` > > Matches an Ethernet header. > > +The ``type`` field either stands for "EtherType" or "TPID" when followed by > +so-called layer 2.5 pattern items such as ``RTE_FLOW_ITEM_TYPE_VLAN``. In > +the latter case, ``type`` refers to that of the outer header, with the inner > +EtherType/TPID provided by the subsequent pattern item. This is the same > +order as on the wire. > + > - ``dst``: destination MAC. > - ``src``: source MAC. > -- ``type``: EtherType. > +- ``type``: EtherType or TPID. > - Default ``mask`` matches destination and source addresses only. > > Item: ``VLAN`` > @@ -794,9 +800,13 @@ Item: ``VLAN`` > > Matches an 802.1Q/ad VLAN tag. > > -- ``tpid``: tag protocol identifier. > +The corresponding standard outer EtherType (TPID) values are ``0x8100`` or > +``0x88a8`` (in case of outer QinQ). It can be overridden by the preceding > +pattern item. > + > - ``tci``: tag control information. > -- Default ``mask`` matches TCI only. > +- ``inner_type``: inner EtherType or TPID. > +- Default ``mask`` matches the VID part of TCI only (lower 12 bits). > > Item: ``IPV4`` > ^^^^^^^^^^^^^^ > @@ -866,12 +876,15 @@ Item: ``E_TAG`` > > Matches an IEEE 802.1BR E-Tag header. > > -- ``tpid``: tag protocol identifier (0x893F) > +The corresponding standard outer EtherType (TPID) value is 0x893f. > +It can be overridden by the preceding pattern item. > + > - ``epcp_edei_in_ecid_b``: E-Tag control information (E-TCI), E-PCP (3b), > E-DEI (1b), ingress E-CID base (12b). > - ``rsvd_grp_ecid_b``: reserved (2b), GRP (2b), E-CID base (12b). > - ``in_ecid_e``: ingress E-CID ext. > - ``ecid_e``: E-CID ext. > +- ``inner_type``: inner EtherType or TPID. > - Default ``mask`` simultaneously matches GRP and E-CID base. > > Item: ``NVGRE`` > diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst > index 738461f44..25fac8430 100644 > --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst > +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst > @@ -3223,15 +3223,15 @@ This section lists supported pattern items and their attributes, if any. > > - ``dst {MAC-48}``: destination MAC. > - ``src {MAC-48}``: source MAC. > - - ``type {unsigned}``: EtherType. > + - ``type {unsigned}``: EtherType or TPID. > > - ``vlan``: match 802.1Q/ad VLAN tag. > > - - ``tpid {unsigned}``: tag protocol identifier. > - ``tci {unsigned}``: tag control information. > - ``pcp {unsigned}``: priority code point. > - ``dei {unsigned}``: drop eligible indicator. > - ``vid {unsigned}``: VLAN identifier. > + - ``inner_type {unsigned}``: inner EtherType or TPID. > > - ``ipv4``: match IPv4 header. > > diff --git a/drivers/net/bnxt/bnxt_filter.c b/drivers/net/bnxt/bnxt_filter.c > index 0d735edf6..a97a8dd46 100644 > --- a/drivers/net/bnxt/bnxt_filter.c > +++ b/drivers/net/bnxt/bnxt_filter.c > @@ -327,6 +327,7 @@ bnxt_validate_and_parse_flow_type(struct bnxt *bp, > uint32_t vf = 0; > int use_ntuple; > uint32_t en = 0; > + uint32_t en_ethertype; > int dflt_vnic; > > use_ntuple = bnxt_filter_type_check(pattern, error); > @@ -336,6 +337,9 @@ bnxt_validate_and_parse_flow_type(struct bnxt *bp, > > filter->filter_type = use_ntuple ? > HWRM_CFA_NTUPLE_FILTER : HWRM_CFA_EM_FILTER; > + en_ethertype = use_ntuple ? > + NTUPLE_FLTR_ALLOC_INPUT_EN_ETHERTYPE : > + EM_FLOW_ALLOC_INPUT_EN_ETHERTYPE; > > while (item->type != RTE_FLOW_ITEM_TYPE_END) { > if (item->last) { > @@ -405,30 +409,52 @@ bnxt_validate_and_parse_flow_type(struct bnxt *bp, > if (eth_mask->type) { > filter->ethertype = > rte_be_to_cpu_16(eth_spec->type); > - en |= use_ntuple ? > - NTUPLE_FLTR_ALLOC_INPUT_EN_ETHERTYPE : > - EM_FLOW_ALLOC_INPUT_EN_ETHERTYPE; > + en |= en_ethertype; > } > > break; > case RTE_FLOW_ITEM_TYPE_VLAN: > vlan_spec = item->spec; > vlan_mask = item->mask; > + if (en & en_ethertype && > + filter->ethertype != RTE_BE16(0x8100)) { > + rte_flow_error_set(error, EINVAL, > + RTE_FLOW_ERROR_TYPE_ITEM, > + item, > + "unsupported outer TPID"); > + return -rte_errno; > + } > if (vlan_mask->tci && > - vlan_mask->tci == RTE_BE16(0x0fff) && > - !vlan_mask->tpid) { > + vlan_mask->tci == RTE_BE16(0x0fff)) { > /* Only the VLAN ID can be matched. */ > filter->l2_ovlan = > rte_be_to_cpu_16(vlan_spec->tci & > RTE_BE16(0x0fff)); > en |= EM_FLOW_ALLOC_INPUT_EN_OVLAN_VID; > - } else if (vlan_mask->tci || vlan_mask->tpid) { > + } else if (vlan_mask->tci) { > rte_flow_error_set(error, EINVAL, > RTE_FLOW_ERROR_TYPE_ITEM, > item, > "VLAN mask is invalid"); > return -rte_errno; > } > + if (vlan_mask->inner_type && > + vlan_mask->inner_type != RTE_BE16(0xffff)) { > + rte_flow_error_set(error, EINVAL, > + RTE_FLOW_ERROR_TYPE_ITEM, > + item, > + "inner ethertype mask not" > + " valid"); > + return -rte_errno; > + } > + if (vlan_mask->inner_type) { > + filter->ethertype = > + rte_be_to_cpu_16(vlan_spec->inner_type); > + en |= en_ethertype; > + } else { > + filter->ethertype = RTE_BE16(0x0000); > + en &= ~en_ethertype; > + } > > break; > case RTE_FLOW_ITEM_TYPE_IPV4: > diff --git a/drivers/net/enic/enic_flow.c b/drivers/net/enic/enic_flow.c > index c5c98b870..a413740ab 100644 > --- a/drivers/net/enic/enic_flow.c > +++ b/drivers/net/enic/enic_flow.c > @@ -4,6 +4,7 @@ > > #include <errno.h> > #include <stdint.h> > +#include <rte_byteorder.h> > #include <rte_log.h> > #include <rte_ethdev_driver.h> > #include <rte_flow_driver.h> > @@ -545,16 +546,22 @@ enic_copy_item_vlan_v2(const struct rte_flow_item *item, > if (!spec) > return 0; > > - /* Don't support filtering in tpid */ > - if (mask) { > - if (mask->tpid != 0) > - return ENOTSUP; > - } else { > + if (!mask) > mask = &rte_flow_item_vlan_mask; > - RTE_ASSERT(mask->tpid == 0); > - } > > if (*inner_ofst == 0) { > + struct ether_hdr *eth_mask = > + (void *)gp->layer[FILTER_GENERIC_1_L2].mask; > + struct ether_hdr *eth_val = > + (void *)gp->layer[FILTER_GENERIC_1_L2].val; > + > + /* Exactly one TPID value is allowed if specified */ > + if ((eth_val->ether_type & eth_mask->ether_type) != > + (RTE_BE16(0x8100) & eth_mask->ether_type)) > + return ENOTSUP; > + eth_mask->ether_type = mask->inner_type; > + eth_val->ether_type = spec->inner_type; > + > /* Outer header. Use the vlan mask/val fields */ > gp->mask_vlan = mask->tci; > gp->val_vlan = spec->tci; > diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c > index 1b336df74..c6dd889ad 100644 > --- a/drivers/net/i40e/i40e_flow.c > +++ b/drivers/net/i40e/i40e_flow.c > @@ -2490,24 +2490,36 @@ i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev, > "Invalid MAC_addr mask."); > return -rte_errno; > } > + } > + if (eth_spec && eth_mask && eth_mask->type) { > + enum rte_flow_item_type next = (item + 1)->type; > > - if ((eth_mask->type & UINT16_MAX) == > - UINT16_MAX) { > - input_set |= I40E_INSET_LAST_ETHER_TYPE; > - filter->input.flow.l2_flow.ether_type = > - eth_spec->type; > + if (eth_mask->type != RTE_BE16(0xffff)) { > + rte_flow_error_set(error, EINVAL, > + RTE_FLOW_ERROR_TYPE_ITEM, > + item, > + "Invalid type mask."); > + return -rte_errno; > } > > ether_type = rte_be_to_cpu_16(eth_spec->type); > - if (ether_type == ETHER_TYPE_IPv4 || > - ether_type == ETHER_TYPE_IPv6 || > - ether_type == ETHER_TYPE_ARP || > - ether_type == outer_tpid) { > + > + if ((next == RTE_FLOW_ITEM_TYPE_VLAN && > + ether_type != outer_tpid) || > + (next != RTE_FLOW_ITEM_TYPE_VLAN && > + (ether_type == ETHER_TYPE_IPv4 || > + ether_type == ETHER_TYPE_IPv6 || > + ether_type == ETHER_TYPE_ARP || > + ether_type == outer_tpid))) { > rte_flow_error_set(error, EINVAL, > RTE_FLOW_ERROR_TYPE_ITEM, > item, > "Unsupported ether_type."); > return -rte_errno; > + } else if (next != RTE_FLOW_ITEM_TYPE_VLAN) { > + input_set |= I40E_INSET_LAST_ETHER_TYPE; > + filter->input.flow.l2_flow.ether_type = > + eth_spec->type; > } > } > > @@ -2518,6 +2530,14 @@ i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev, > case RTE_FLOW_ITEM_TYPE_VLAN: > vlan_spec = item->spec; > vlan_mask = item->mask; > + > + if (input_set & I40E_INSET_LAST_ETHER_TYPE) { > + rte_flow_error_set(error, EINVAL, > + RTE_FLOW_ERROR_TYPE_ITEM, > + item, > + "Unsupported outer TPID."); > + return -rte_errno; > + } > if (vlan_spec && vlan_mask) { > if (vlan_mask->tci == > rte_cpu_to_be_16(I40E_TCI_MASK)) { > @@ -2526,6 +2546,33 @@ i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev, > vlan_spec->tci; > } > } > + if (vlan_spec && vlan_mask && vlan_mask->inner_type) { > + if (vlan_mask->inner_type != RTE_BE16(0xffff)) { > + rte_flow_error_set(error, EINVAL, > + RTE_FLOW_ERROR_TYPE_ITEM, > + item, > + "Invalid inner_type" > + " mask."); > + return -rte_errno; > + } > + > + ether_type = > + rte_be_to_cpu_16(vlan_spec->inner_type); > + > + if (ether_type == ETHER_TYPE_IPv4 || > + ether_type == ETHER_TYPE_IPv6 || > + ether_type == ETHER_TYPE_ARP || > + ether_type == outer_tpid) { > + rte_flow_error_set(error, EINVAL, > + RTE_FLOW_ERROR_TYPE_ITEM, > + item, > + "Unsupported inner_type."); > + return -rte_errno; > + } > + input_set |= I40E_INSET_LAST_ETHER_TYPE; > + filter->input.flow.l2_flow.ether_type = > + vlan_spec->inner_type; > + } > > pctype = I40E_FILTER_PCTYPE_L2_PAYLOAD; > layer_idx = I40E_FLXPLD_L2_IDX; > @@ -3284,7 +3331,8 @@ i40e_flow_parse_vxlan_pattern(__rte_unused struct rte_eth_dev *dev, > case RTE_FLOW_ITEM_TYPE_VLAN: > vlan_spec = item->spec; > vlan_mask = item->mask; > - if (!(vlan_spec && vlan_mask)) { > + if (!(vlan_spec && vlan_mask) || > + vlan_mask->inner_type) { > rte_flow_error_set(error, EINVAL, > RTE_FLOW_ERROR_TYPE_ITEM, > item, > @@ -3514,7 +3562,8 @@ i40e_flow_parse_nvgre_pattern(__rte_unused struct rte_eth_dev *dev, > case RTE_FLOW_ITEM_TYPE_VLAN: > vlan_spec = item->spec; > vlan_mask = item->mask; > - if (!(vlan_spec && vlan_mask)) { > + if (!(vlan_spec && vlan_mask) || > + vlan_mask->inner_type) { > rte_flow_error_set(error, EINVAL, > RTE_FLOW_ERROR_TYPE_ITEM, > item, > @@ -4022,7 +4071,8 @@ i40e_flow_parse_qinq_pattern(__rte_unused struct rte_eth_dev *dev, > vlan_spec = item->spec; > vlan_mask = item->mask; > > - if (!(vlan_spec && vlan_mask)) { > + if (!(vlan_spec && vlan_mask) || > + vlan_mask->inner_type) { > rte_flow_error_set(error, EINVAL, > RTE_FLOW_ERROR_TYPE_ITEM, > item, > diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c > index bc1176819..f03413d32 100644 > --- a/drivers/net/mlx5/mlx5_flow.c > +++ b/drivers/net/mlx5/mlx5_flow.c > @@ -17,6 +17,7 @@ > #pragma GCC diagnostic error "-Wpedantic" > #endif > > +#include <rte_byteorder.h> > #include <rte_common.h> > #include <rte_eth_ctrl.h> > #include <rte_ethdev_driver.h> > @@ -306,6 +307,7 @@ static const struct mlx5_flow_items mlx5_flow_items[] = { > .actions = valid_actions, > .mask = &(const struct rte_flow_item_vlan){ > .tci = -1, > + .inner_type = -1, > }, > .default_mask = &rte_flow_item_vlan_mask, > .mask_sz = sizeof(struct rte_flow_item_vlan), > @@ -1285,6 +1287,7 @@ mlx5_flow_create_vlan(const struct rte_flow_item *item, > struct mlx5_flow_parse *parser = data->parser; > struct ibv_flow_spec_eth *eth; > const unsigned int eth_size = sizeof(struct ibv_flow_spec_eth); > + const char *msg = "VLAN cannot be empty"; > > if (spec) { > unsigned int i; > @@ -1306,12 +1309,21 @@ mlx5_flow_create_vlan(const struct rte_flow_item *item, > */ > if (!eth->mask.vlan_tag) > goto error; > + /* Exactly one TPID value is allowed if specified. */ > + if ((eth->val.ether_type & eth->mask.ether_type) != > + (RTE_BE16(0x8100) & eth->mask.ether_type)) { You can use ETHER_TYPE_VLAN present in rte_ether.h instead of hard coded values. > + msg = "unsupported outer TPID"; > + goto error; > + } > + eth->val.ether_type = spec->inner_type; > + eth->mask.ether_type = mask->inner_type; > + eth->val.ether_type &= eth->mask.ether_type; > } > return 0; > } > error: > return rte_flow_error_set(data->error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM, > - item, "VLAN cannot be empty"); > + item, msg); > } > > /** > diff --git a/drivers/net/mvpp2/mrvl_flow.c b/drivers/net/mvpp2/mrvl_flow.c > index 8fd4dbfb1..6604a411f 100644 > --- a/drivers/net/mvpp2/mrvl_flow.c > +++ b/drivers/net/mvpp2/mrvl_flow.c > @@ -1091,12 +1091,6 @@ mrvl_parse_vlan(const struct rte_flow_item *item, > if (ret) > return ret; > > - if (mask->tpid) { > - rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM, > - NULL, "Not supported by classifier\n"); > - return -rte_errno; > - } > - > m = rte_be_to_cpu_16(mask->tci); > if (m & MRVL_VLAN_ID_MASK) { > RTE_LOG(WARNING, PMD, "vlan id mask is ignored\n"); > @@ -1112,6 +1106,27 @@ mrvl_parse_vlan(const struct rte_flow_item *item, > goto out; > } > > + if (flow->pattern & F_TYPE) { > + rte_flow_error_set(error, ENOTSUP, > + RTE_FLOW_ERROR_TYPE_ITEM, item, > + "outer TPID cannot be explicitly matched" > + " when VLAN item is also specified\n"); > + return -rte_errno; > + } > + if (mask->inner_type) { > + struct rte_flow_item_eth spec_eth = { > + .type = spec->inner_type, > + }; > + struct rte_flow_item_eth mask_eth = { > + .type = mask->inner_type, > + }; > + > + RTE_LOG(WARNING, PMD, "inner eth type mask is ignored\n"); > + ret = mrvl_parse_type(spec_eth, mask_eth, flow); > + if (ret) > + goto out; > + } > + > return 0; > out: > rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, > diff --git a/drivers/net/sfc/sfc_flow.c b/drivers/net/sfc/sfc_flow.c > index bf9609735..515a61325 100644 > --- a/drivers/net/sfc/sfc_flow.c > +++ b/drivers/net/sfc/sfc_flow.c > @@ -352,6 +352,7 @@ sfc_flow_parse_vlan(const struct rte_flow_item *item, > const struct rte_flow_item_vlan *mask = NULL; > const struct rte_flow_item_vlan supp_mask = { > .tci = rte_cpu_to_be_16(ETH_VLAN_ID_MAX), > + .inner_type = RTE_BE16(0xffff), > }; > > rc = sfc_flow_parse_init(item, > @@ -394,6 +395,32 @@ sfc_flow_parse_vlan(const struct rte_flow_item *item, > return -rte_errno; > } > > + /* > + * If an EtherType was already specified, make sure it is a valid > + * TPID for the current VLAN layer before overwriting it with the > + * specified inner type. > + */ > + if (efx_spec->efs_match_flags & EFX_FILTER_MATCH_ETHER_TYPE && > + efx_spec->efs_ether_type != RTE_BE16(0x8100) && > + efx_spec->efs_ether_type != RTE_BE16(0x88a8)) { > + rte_flow_error_set(error, EINVAL, > + RTE_FLOW_ERROR_TYPE_ITEM, item, > + "Unsupported outer TPID"); > + return -rte_errno; > + } > + if (!mask->inner_type) { > + efx_spec->efs_match_flags &= ~EFX_FILTER_MATCH_ETHER_TYPE; > + efx_spec->efs_ether_type = RTE_BE16(0x0000); > + } else if (mask->inner_type == supp_mask.inner_type) { > + efx_spec->efs_match_flags |= EFX_FILTER_MATCH_ETHER_TYPE; > + efx_spec->efs_ether_type = rte_be_to_cpu_16(spec->inner_type); > + } else { > + rte_flow_error_set(error, EINVAL, > + RTE_FLOW_ERROR_TYPE_ITEM, item, > + "Bad mask for VLAN inner_type"); > + return -rte_errno; > + } > + > return 0; > } > > diff --git a/drivers/net/tap/tap_flow.c b/drivers/net/tap/tap_flow.c > index e5eb50fc5..e53eff6ce 100644 > --- a/drivers/net/tap/tap_flow.c > +++ b/drivers/net/tap/tap_flow.c > @@ -270,13 +270,13 @@ static const struct tap_flow_items tap_flow_items[] = { > .items = ITEMS(RTE_FLOW_ITEM_TYPE_IPV4, > RTE_FLOW_ITEM_TYPE_IPV6), > .mask = &(const struct rte_flow_item_vlan){ > - .tpid = -1, > /* DEI matching is not supported */ > #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN > .tci = 0xffef, > #else > .tci = 0xefff, > #endif > + .inner_type = -1, > }, > .mask_sz = sizeof(struct rte_flow_item_vlan), > .default_mask = &rte_flow_item_vlan_mask, > @@ -578,13 +578,21 @@ tap_flow_create_vlan(const struct rte_flow_item *item, void *data) > /* use default mask if none provided */ > if (!mask) > mask = tap_flow_items[RTE_FLOW_ITEM_TYPE_VLAN].default_mask; > - /* TC does not support tpid masking. Only accept if exact match. */ > - if (mask->tpid && mask->tpid != 0xffff) > + /* check that previous eth type is compatible with VLAN */ > + if (info->eth_type && info->eth_type != RTE_BE16(ETH_P_8021Q)) > return -1; > /* Double-tagging not supported. */ > - if (spec && mask->tpid && spec->tpid != htons(ETH_P_8021Q)) > + if (info->vlan) > return -1; > info->vlan = 1; > + if (mask->inner_type) { > + /* TC does not support partial eth_type masking */ > + if (mask->inner_type != RTE_BE16(0xffff)) > + return -1; > + info->eth_type = spec->inner_type; > + } else { > + info->eth_type = 0; > + } > if (!flow) > return 0; > msg = &flow->msg; > diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h > index 1b222ba60..15e383f95 100644 > --- a/lib/librte_ether/rte_flow.h > +++ b/lib/librte_ether/rte_flow.h > @@ -454,11 +454,17 @@ static const struct rte_flow_item_raw rte_flow_item_raw_mask = { > * RTE_FLOW_ITEM_TYPE_ETH > * > * Matches an Ethernet header. > + * > + * The @p type field either stands for "EtherType" or "TPID" when followed > + * by so-called layer 2.5 pattern items such as RTE_FLOW_ITEM_TYPE_VLAN. In > + * the latter case, @p type refers to that of the outer header, with the > + * inner EtherType/TPID provided by the subsequent pattern item. This is the > + * same order as on the wire. > */ > struct rte_flow_item_eth { > struct ether_addr dst; /**< Destination MAC. */ > struct ether_addr src; /**< Source MAC. */ > - rte_be16_t type; /**< EtherType. */ > + rte_be16_t type; /**< EtherType or TPID. */ > }; > > /** Default mask for RTE_FLOW_ITEM_TYPE_ETH. */ > @@ -475,19 +481,20 @@ static const struct rte_flow_item_eth rte_flow_item_eth_mask = { > * > * Matches an 802.1Q/ad VLAN tag. > * > - * This type normally follows either RTE_FLOW_ITEM_TYPE_ETH or > - * RTE_FLOW_ITEM_TYPE_VLAN. > + * The corresponding standard outer EtherType (TPID) values are 0x8100 or > + * 0x88a8 (in case of outer QinQ). It can be overridden by the preceding > + * pattern item. > */ > struct rte_flow_item_vlan { > - rte_be16_t tpid; /**< Tag protocol identifier. */ > rte_be16_t tci; /**< Tag control information. */ > + rte_be16_t inner_type; /**< Inner EtherType or TPID. */ > }; > > /** Default mask for RTE_FLOW_ITEM_TYPE_VLAN. */ > #ifndef __cplusplus > static const struct rte_flow_item_vlan rte_flow_item_vlan_mask = { > - .tpid = RTE_BE16(0x0000), > - .tci = RTE_BE16(0xffff), > + .tci = RTE_BE16(0x0fff), > + .inner_type = RTE_BE16(0x0000), > }; > #endif > > @@ -636,9 +643,11 @@ static const struct rte_flow_item_vxlan rte_flow_item_vxlan_mask = { > * RTE_FLOW_ITEM_TYPE_E_TAG. > * > * Matches a E-tag header. > + * > + * The corresponding standard outer EtherType (TPID) value is 0x893f. > + * It can be overridden by the preceding pattern item. > */ > struct rte_flow_item_e_tag { > - rte_be16_t tpid; /**< Tag protocol identifier (0x893F). */ > /** > * E-Tag control information (E-TCI). > * E-PCP (3b), E-DEI (1b), ingress E-CID base (12b). > @@ -648,6 +657,7 @@ struct rte_flow_item_e_tag { > rte_be16_t rsvd_grp_ecid_b; > uint8_t in_ecid_e; /**< Ingress E-CID ext. */ > uint8_t ecid_e; /**< E-CID ext. */ > + rte_be16_t inner_type; /**< Inner EtherType or TPID. */ > }; > > /** Default mask for RTE_FLOW_ITEM_TYPE_E_TAG. */ > -- > 2.11.0 -- Nélio Laranjeiro 6WIND ^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [dpdk-dev] [PATCH v1 11/16] ethdev: refine TPID handling in flow API 2018-04-05 9:55 ` Nélio Laranjeiro @ 2018-04-05 12:02 ` Adrien Mazarguil 0 siblings, 0 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-05 12:02 UTC (permalink / raw) To: Nélio Laranjeiro Cc: Thomas Monjalon, Ferruh Yigit, dev, Wenzhuo Lu, Jingjing Wu, Ajit Khaparde, Somnath Kotur, John Daley, Hyong Youb Kim, Beilei Xing, Qi Zhang, Konstantin Ananyev, Yongseok Koh, Jacek Siuda, Tomasz Duszynski, Dmitri Epshtein, Natalie Samsonov, Jianbo Liu, Andrew Rybchenko, Pascal Mazon On Thu, Apr 05, 2018 at 11:55:10AM +0200, Nélio Laranjeiro wrote: > On Wed, Apr 04, 2018 at 05:56:49PM +0200, Adrien Mazarguil wrote: > > TPID handling in rte_flow VLAN and E_TAG pattern item definitions is not > > consistent with the normal stacking order of pattern items, which is > > confusing to applications. > > > > Problem is that when followed by one of these layers, the EtherType field > > of the preceding layer keeps its "inner" definition, and the "outer" TPID > > is provided by the subsequent layer, the reverse of how a packet looks like > > on the wire: > > > > Wire: [ ETH TPID = A | VLAN EtherType = B | B DATA ] > > rte_flow: [ ETH EtherType = B | VLAN TPID = A | B DATA ] > > > > Worse, when QinQ is involved, the stacking order of VLAN layers is > > unspecified. It is unclear whether it should be reversed (innermost to > > outermost) as well given TPID applies to the previous layer: > > > > Wire: [ ETH TPID = A | VLAN TPID = B | VLAN EtherType = C | C DATA ] > > rte_flow 1: [ ETH EtherType = C | VLAN TPID = B | VLAN TPID = A | C DATA ] > > rte_flow 2: [ ETH EtherType = C | VLAN TPID = A | VLAN TPID = B | C DATA ] > > > > While specifying EtherType/TPID is hopefully rarely necessary, the stacking > > order in case of QinQ and the lack of documentation remain an issue. > > > > This patch replaces TPID in the VLAN pattern item with an inner > > EtherType/TPID as is usually done everywhere else (e.g. struct vlan_hdr), > > clarifies documentation and updates all relevant code. > > > > Summary of changes for PMDs that implement ETH, VLAN or E_TAG pattern > > items: > > > > - bnxt: EtherType matching is supported, and vlan->inner_type overrides > > eth->type if the latter has standard TPID value 0x8100, otherwise an > > error is triggered. > > > > - e1000: EtherType matching is only supported with the ETHERTYPE filter, > > which does not support VLAN matching, therefore no impact. > > > > - enic: same as bnxt. > > > > - i40e: same as bnxt with a configurable TPID value for the FDIR filter, > > with existing limitations on allowed EtherType values. The remaining > > filter types (VXLAN, NVGRE, QINQ) do not support EtherType matching. > > > > - ixgbe: same as e1000. > > > > - mlx4: EtherType/TPID matching is not supported, no impact. > > > > - mlx5: same as bnxt. > > > > - mrvl: EtherType matching is supported but eth->type cannot be specified > > when a VLAN item is present. However vlan->inner_type is used if > > specified. > > > > - sfc: same as bnxt with QinQ TPID value 0x88a8 additionally supported. > > > > - tap: same as bnxt. > > > > Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> <snip> > > @@ -1306,12 +1309,21 @@ mlx5_flow_create_vlan(const struct rte_flow_item *item, > > */ > > if (!eth->mask.vlan_tag) > > goto error; > > + /* Exactly one TPID value is allowed if specified. */ > > + if ((eth->val.ether_type & eth->mask.ether_type) != > > + (RTE_BE16(0x8100) & eth->mask.ether_type)) { > > You can use ETHER_TYPE_VLAN present in rte_ether.h instead of hard coded > values. Good catch, I forgot about those macros. I'll make the change in all impacted code in the next revision. -- Adrien Mazarguil 6WIND ^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [dpdk-dev] [PATCH v1 11/16] ethdev: refine TPID handling in flow API 2018-04-04 15:56 ` [dpdk-dev] [PATCH v1 11/16] ethdev: refine TPID handling in flow API Adrien Mazarguil 2018-04-05 9:55 ` Nélio Laranjeiro @ 2018-04-05 14:20 ` Zhang, Qi Z 2018-04-05 14:39 ` Adrien Mazarguil 1 sibling, 1 reply; 157+ messages in thread From: Zhang, Qi Z @ 2018-04-05 14:20 UTC (permalink / raw) To: Adrien Mazarguil, Thomas Monjalon, Yigit, Ferruh, dev Cc: Lu, Wenzhuo, Wu, Jingjing, Ajit Khaparde, Somnath Kotur, John Daley, Hyong Youb Kim, Xing, Beilei, Ananyev, Konstantin, Nelio Laranjeiro, Yongseok Koh, Jacek Siuda, Tomasz Duszynski, Dmitri Epshtein, Natalie Samsonov, Jianbo Liu, Andrew Rybchenko, Pascal Mazon Hi Adrien: > Hi PMD maintainers, while I'm pretty confident in these changes, I could not > validate them with all devices. > > It would be great if you could apply this patch, run testpmd, create VLAN flow > rules with/without inner EtherType as described and send matching traffic > while making sure nothing was broken in the process. > > Thanks! > --- > diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c index > 1b336df74..c6dd889ad 100644 > --- a/drivers/net/i40e/i40e_flow.c > +++ b/drivers/net/i40e/i40e_flow.c > @@ -2490,24 +2490,36 @@ i40e_flow_parse_fdir_pattern(struct rte_eth_dev > *dev, > "Invalid MAC_addr mask."); > return -rte_errno; > } > + } > + if (eth_spec && eth_mask && eth_mask->type) { > + enum rte_flow_item_type next = (item + 1)->type; > > - if ((eth_mask->type & UINT16_MAX) == > - UINT16_MAX) { > - input_set |= I40E_INSET_LAST_ETHER_TYPE; > - filter->input.flow.l2_flow.ether_type = > - eth_spec->type; > + if (eth_mask->type != RTE_BE16(0xffff)) { > + rte_flow_error_set(error, EINVAL, > + RTE_FLOW_ERROR_TYPE_ITEM, > + item, > + "Invalid type mask."); > + return -rte_errno; > } > > ether_type = rte_be_to_cpu_16(eth_spec->type); > - if (ether_type == ETHER_TYPE_IPv4 || > - ether_type == ETHER_TYPE_IPv6 || > - ether_type == ETHER_TYPE_ARP || > - ether_type == outer_tpid) { > + > + if ((next == RTE_FLOW_ITEM_TYPE_VLAN && > + ether_type != outer_tpid) || > + (next != RTE_FLOW_ITEM_TYPE_VLAN && > + (ether_type == ETHER_TYPE_IPv4 || > + ether_type == ETHER_TYPE_IPv6 || > + ether_type == ETHER_TYPE_ARP || > + ether_type == outer_tpid))) { > rte_flow_error_set(error, EINVAL, > RTE_FLOW_ERROR_TYPE_ITEM, > item, > "Unsupported ether_type."); > return -rte_errno; > + } else if (next != RTE_FLOW_ITEM_TYPE_VLAN) { > + input_set |= I40E_INSET_LAST_ETHER_TYPE; > + filter->input.flow.l2_flow.ether_type = > + eth_spec->type; > } > } > > @@ -2518,6 +2530,14 @@ i40e_flow_parse_fdir_pattern(struct rte_eth_dev > *dev, > case RTE_FLOW_ITEM_TYPE_VLAN: > vlan_spec = item->spec; > vlan_mask = item->mask; > + > + if (input_set & I40E_INSET_LAST_ETHER_TYPE) { > + rte_flow_error_set(error, EINVAL, > + RTE_FLOW_ERROR_TYPE_ITEM, > + item, > + "Unsupported outer TPID."); > + return -rte_errno; > + } Please correct me I'm wrong, now I40E_INSET_LAST_ETHER_TYPE will only be set when next != RTE_FLOW_ITEM_TYPE_VLAN while, RTE_FLOW_ITEM_TYPE_VLAN will only be the next to RTE_FLOW_ITEM_TYPE_ETH for fdir, so above check seems unnecessary ? Thanks Qi > if (vlan_spec && vlan_mask) { > if (vlan_mask->tci == > rte_cpu_to_be_16(I40E_TCI_MASK)) { @@ -2526,6 > +2546,33 @@ i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev, > vlan_spec->tci; > } > } > + if (vlan_spec && vlan_mask && vlan_mask->inner_type) { > + if (vlan_mask->inner_type != RTE_BE16(0xffff)) { > + rte_flow_error_set(error, EINVAL, > + RTE_FLOW_ERROR_TYPE_ITEM, > + item, > + "Invalid inner_type" > + " mask."); > + return -rte_errno; > + } > + > + ether_type = > + rte_be_to_cpu_16(vlan_spec->inner_type); > + > + if (ether_type == ETHER_TYPE_IPv4 || > + ether_type == ETHER_TYPE_IPv6 || > + ether_type == ETHER_TYPE_ARP || > + ether_type == outer_tpid) { > + rte_flow_error_set(error, EINVAL, > + RTE_FLOW_ERROR_TYPE_ITEM, > + item, > + "Unsupported inner_type."); > + return -rte_errno; > + } > + input_set |= I40E_INSET_LAST_ETHER_TYPE; > + filter->input.flow.l2_flow.ether_type = > + vlan_spec->inner_type; > + } > > pctype = I40E_FILTER_PCTYPE_L2_PAYLOAD; > layer_idx = I40E_FLXPLD_L2_IDX; > @@ -3284,7 +3331,8 @@ i40e_flow_parse_vxlan_pattern(__rte_unused struct > rte_eth_dev *dev, > case RTE_FLOW_ITEM_TYPE_VLAN: > vlan_spec = item->spec; > vlan_mask = item->mask; > - if (!(vlan_spec && vlan_mask)) { > + if (!(vlan_spec && vlan_mask) || > + vlan_mask->inner_type) { > rte_flow_error_set(error, EINVAL, > RTE_FLOW_ERROR_TYPE_ITEM, > item, > @@ -3514,7 +3562,8 @@ i40e_flow_parse_nvgre_pattern(__rte_unused > struct rte_eth_dev *dev, > case RTE_FLOW_ITEM_TYPE_VLAN: > vlan_spec = item->spec; > vlan_mask = item->mask; > - if (!(vlan_spec && vlan_mask)) { > + if (!(vlan_spec && vlan_mask) || > + vlan_mask->inner_type) { > rte_flow_error_set(error, EINVAL, > RTE_FLOW_ERROR_TYPE_ITEM, > item, > @@ -4022,7 +4071,8 @@ i40e_flow_parse_qinq_pattern(__rte_unused struct > rte_eth_dev *dev, > vlan_spec = item->spec; > vlan_mask = item->mask; > > - if (!(vlan_spec && vlan_mask)) { > + if (!(vlan_spec && vlan_mask) || > + vlan_mask->inner_type) { > rte_flow_error_set(error, EINVAL, > RTE_FLOW_ERROR_TYPE_ITEM, > item, ^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [dpdk-dev] [PATCH v1 11/16] ethdev: refine TPID handling in flow API 2018-04-05 14:20 ` Zhang, Qi Z @ 2018-04-05 14:39 ` Adrien Mazarguil 2018-04-06 4:59 ` Zhang, Qi Z 0 siblings, 1 reply; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-05 14:39 UTC (permalink / raw) To: Zhang, Qi Z Cc: Thomas Monjalon, Yigit, Ferruh, dev, Lu, Wenzhuo, Wu, Jingjing, Ajit Khaparde, Somnath Kotur, John Daley, Hyong Youb Kim, Xing, Beilei, Ananyev, Konstantin, Nelio Laranjeiro, Yongseok Koh, Jacek Siuda, Tomasz Duszynski, Dmitri Epshtein, Natalie Samsonov, Jianbo Liu, Andrew Rybchenko, Pascal Mazon On Thu, Apr 05, 2018 at 02:20:34PM +0000, Zhang, Qi Z wrote: > Hi Adrien: > > > Hi PMD maintainers, while I'm pretty confident in these changes, I could not > > validate them with all devices. > > > > It would be great if you could apply this patch, run testpmd, create VLAN flow > > rules with/without inner EtherType as described and send matching traffic > > while making sure nothing was broken in the process. > > > > Thanks! > > --- > > diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c index > > 1b336df74..c6dd889ad 100644 > > --- a/drivers/net/i40e/i40e_flow.c > > +++ b/drivers/net/i40e/i40e_flow.c > > @@ -2490,24 +2490,36 @@ i40e_flow_parse_fdir_pattern(struct rte_eth_dev > > *dev, > > "Invalid MAC_addr mask."); > > return -rte_errno; > > } > > + } > > + if (eth_spec && eth_mask && eth_mask->type) { > > + enum rte_flow_item_type next = (item + 1)->type; > > > > - if ((eth_mask->type & UINT16_MAX) == > > - UINT16_MAX) { > > - input_set |= I40E_INSET_LAST_ETHER_TYPE; > > - filter->input.flow.l2_flow.ether_type = > > - eth_spec->type; > > + if (eth_mask->type != RTE_BE16(0xffff)) { > > + rte_flow_error_set(error, EINVAL, > > + RTE_FLOW_ERROR_TYPE_ITEM, > > + item, > > + "Invalid type mask."); > > + return -rte_errno; > > } > > > > ether_type = rte_be_to_cpu_16(eth_spec->type); > > - if (ether_type == ETHER_TYPE_IPv4 || > > - ether_type == ETHER_TYPE_IPv6 || > > - ether_type == ETHER_TYPE_ARP || > > - ether_type == outer_tpid) { > > + > > + if ((next == RTE_FLOW_ITEM_TYPE_VLAN && > > + ether_type != outer_tpid) || > > + (next != RTE_FLOW_ITEM_TYPE_VLAN && > > + (ether_type == ETHER_TYPE_IPv4 || > > + ether_type == ETHER_TYPE_IPv6 || > > + ether_type == ETHER_TYPE_ARP || > > + ether_type == outer_tpid))) { > > rte_flow_error_set(error, EINVAL, > > RTE_FLOW_ERROR_TYPE_ITEM, > > item, > > "Unsupported ether_type."); > > return -rte_errno; > > + } else if (next != RTE_FLOW_ITEM_TYPE_VLAN) { > > + input_set |= I40E_INSET_LAST_ETHER_TYPE; > > + filter->input.flow.l2_flow.ether_type = > > + eth_spec->type; > > } > > } > > > > @@ -2518,6 +2530,14 @@ i40e_flow_parse_fdir_pattern(struct rte_eth_dev > > *dev, > > case RTE_FLOW_ITEM_TYPE_VLAN: > > vlan_spec = item->spec; > > vlan_mask = item->mask; > > + > > + if (input_set & I40E_INSET_LAST_ETHER_TYPE) { > > + rte_flow_error_set(error, EINVAL, > > + RTE_FLOW_ERROR_TYPE_ITEM, > > + item, > > + "Unsupported outer TPID."); > > + return -rte_errno; > > + } > > Please correct me I'm wrong, now I40E_INSET_LAST_ETHER_TYPE will only be set when next != RTE_FLOW_ITEM_TYPE_VLAN > while, RTE_FLOW_ITEM_TYPE_VLAN will only be the next to RTE_FLOW_ITEM_TYPE_ETH for fdir, so above check seems unnecessary ? You're right, it's unnecessary. I can remove this change or leave it as a safety measure for future contributions, since when parsing a VLAN item one is not necessarily aware of what happened in previous iterations. How about an assertion check for debugging purposes instead? RTE_ASSERT(!(input_set & I40E_INSET_LAST_ETHER_TYPE)); -- Adrien Mazarguil 6WIND ^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [dpdk-dev] [PATCH v1 11/16] ethdev: refine TPID handling in flow API 2018-04-05 14:39 ` Adrien Mazarguil @ 2018-04-06 4:59 ` Zhang, Qi Z 0 siblings, 0 replies; 157+ messages in thread From: Zhang, Qi Z @ 2018-04-06 4:59 UTC (permalink / raw) To: Adrien Mazarguil Cc: Thomas Monjalon, Yigit, Ferruh, dev, Lu, Wenzhuo, Wu, Jingjing, Ajit Khaparde, Somnath Kotur, John Daley, Hyong Youb Kim, Xing, Beilei, Ananyev, Konstantin, Nelio Laranjeiro, Yongseok Koh, Jacek Siuda, Tomasz Duszynski, Dmitri Epshtein, Natalie Samsonov, Jianbo Liu, Andrew Rybchenko, Pascal Mazon > -----Original Message----- > From: Adrien Mazarguil [mailto:adrien.mazarguil@6wind.com] > Sent: Thursday, April 5, 2018 10:39 PM > To: Zhang, Qi Z <qi.z.zhang@intel.com> > Cc: Thomas Monjalon <thomas@monjalon.net>; Yigit, Ferruh > <ferruh.yigit@intel.com>; dev@dpdk.org; Lu, Wenzhuo > <wenzhuo.lu@intel.com>; Wu, Jingjing <jingjing.wu@intel.com>; Ajit Khaparde > <ajit.khaparde@broadcom.com>; Somnath Kotur > <somnath.kotur@broadcom.com>; John Daley <johndale@cisco.com>; Hyong > Youb Kim <hyonkim@cisco.com>; Xing, Beilei <beilei.xing@intel.com>; Ananyev, > Konstantin <konstantin.ananyev@intel.com>; Nelio Laranjeiro > <nelio.laranjeiro@6wind.com>; Yongseok Koh <yskoh@mellanox.com>; Jacek > Siuda <jck@semihalf.com>; Tomasz Duszynski <tdu@semihalf.com>; Dmitri > Epshtein <dima@marvell.com>; Natalie Samsonov <nsamsono@marvell.com>; > Jianbo Liu <jianbo.liu@arm.com>; Andrew Rybchenko > <arybchenko@solarflare.com>; Pascal Mazon <pascal.mazon@6wind.com> > Subject: Re: [PATCH v1 11/16] ethdev: refine TPID handling in flow API > > On Thu, Apr 05, 2018 at 02:20:34PM +0000, Zhang, Qi Z wrote: > > Hi Adrien: > > > > > Hi PMD maintainers, while I'm pretty confident in these changes, I > > > could not validate them with all devices. > > > > > > It would be great if you could apply this patch, run testpmd, create > > > VLAN flow rules with/without inner EtherType as described and send > > > matching traffic while making sure nothing was broken in the process. > > > > > > Thanks! > > > --- > > > diff --git a/drivers/net/i40e/i40e_flow.c > > > b/drivers/net/i40e/i40e_flow.c index 1b336df74..c6dd889ad 100644 > > > --- a/drivers/net/i40e/i40e_flow.c > > > +++ b/drivers/net/i40e/i40e_flow.c > > > @@ -2490,24 +2490,36 @@ i40e_flow_parse_fdir_pattern(struct > > > rte_eth_dev *dev, > > > "Invalid MAC_addr mask."); > > > return -rte_errno; > > > } > > > + } > > > + if (eth_spec && eth_mask && eth_mask->type) { > > > + enum rte_flow_item_type next = (item + 1)->type; > > > > > > - if ((eth_mask->type & UINT16_MAX) == > > > - UINT16_MAX) { > > > - input_set |= I40E_INSET_LAST_ETHER_TYPE; > > > - filter->input.flow.l2_flow.ether_type = > > > - eth_spec->type; > > > + if (eth_mask->type != RTE_BE16(0xffff)) { > > > + rte_flow_error_set(error, EINVAL, > > > + RTE_FLOW_ERROR_TYPE_ITEM, > > > + item, > > > + "Invalid type mask."); > > > + return -rte_errno; > > > } > > > > > > ether_type = rte_be_to_cpu_16(eth_spec->type); > > > - if (ether_type == ETHER_TYPE_IPv4 || > > > - ether_type == ETHER_TYPE_IPv6 || > > > - ether_type == ETHER_TYPE_ARP || > > > - ether_type == outer_tpid) { > > > + > > > + if ((next == RTE_FLOW_ITEM_TYPE_VLAN && > > > + ether_type != outer_tpid) || > > > + (next != RTE_FLOW_ITEM_TYPE_VLAN && > > > + (ether_type == ETHER_TYPE_IPv4 || > > > + ether_type == ETHER_TYPE_IPv6 || > > > + ether_type == ETHER_TYPE_ARP || > > > + ether_type == outer_tpid))) { > > > rte_flow_error_set(error, EINVAL, > > > RTE_FLOW_ERROR_TYPE_ITEM, > > > item, > > > "Unsupported ether_type."); > > > return -rte_errno; > > > + } else if (next != RTE_FLOW_ITEM_TYPE_VLAN) { > > > + input_set |= I40E_INSET_LAST_ETHER_TYPE; > > > + filter->input.flow.l2_flow.ether_type = > > > + eth_spec->type; > > > } > > > } > > > > > > @@ -2518,6 +2530,14 @@ i40e_flow_parse_fdir_pattern(struct > > > rte_eth_dev *dev, > > > case RTE_FLOW_ITEM_TYPE_VLAN: > > > vlan_spec = item->spec; > > > vlan_mask = item->mask; > > > + > > > + if (input_set & I40E_INSET_LAST_ETHER_TYPE) { > > > + rte_flow_error_set(error, EINVAL, > > > + RTE_FLOW_ERROR_TYPE_ITEM, > > > + item, > > > + "Unsupported outer TPID."); > > > + return -rte_errno; > > > + } > > > > Please correct me I'm wrong, now I40E_INSET_LAST_ETHER_TYPE will only > > be set when next != RTE_FLOW_ITEM_TYPE_VLAN while, > RTE_FLOW_ITEM_TYPE_VLAN will only be the next to > RTE_FLOW_ITEM_TYPE_ETH for fdir, so above check seems unnecessary ? > > You're right, it's unnecessary. I can remove this change or leave it as a safety > measure for future contributions, since when parsing a VLAN item one is not > necessarily aware of what happened in previous iterations. > > How about an assertion check for debugging purposes instead? > > RTE_ASSERT(!(input_set & I40E_INSET_LAST_ETHER_TYPE)); Agree to use assert. > > -- > Adrien Mazarguil > 6WIND ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v1 12/16] ethdev: add transfer attribute to flow API 2018-04-04 15:56 [dpdk-dev] [PATCH v1 00/16] Flow API overhaul for switch offloads Adrien Mazarguil ` (10 preceding siblings ...) 2018-04-04 15:56 ` [dpdk-dev] [PATCH v1 11/16] ethdev: refine TPID handling in flow API Adrien Mazarguil @ 2018-04-04 15:56 ` Adrien Mazarguil 2018-04-04 15:56 ` [dpdk-dev] [PATCH v1 13/16] ethdev: update behavior of VF/PF in " Adrien Mazarguil ` (4 subsequent siblings) 16 siblings, 0 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-04 15:56 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev This new attribute enables applications to create flow rules that do not simply match traffic whose origin is specified in the pattern (e.g. some non-default physical port or VF), but actively affect it by applying the flow rule at the lowest possible level in the underlying device. Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> --- app/test-pmd/cmdline_flow.c | 11 +++++ app/test-pmd/config.c | 6 ++- doc/guides/prog_guide/rte_flow.rst | 14 +++++++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 11 ++--- drivers/net/bnxt/bnxt_filter.c | 8 ++++ drivers/net/e1000/igb_flow.c | 44 ++++++++++++++++++++ drivers/net/enic/enic_flow.c | 6 +++ drivers/net/i40e/i40e_flow.c | 8 ++++ drivers/net/ixgbe/ixgbe_flow.c | 53 ++++++++++++++++++++++++ drivers/net/mlx4/mlx4_flow.c | 4 ++ drivers/net/mlx5/mlx5_flow.c | 7 ++++ drivers/net/mvpp2/mrvl_flow.c | 6 +++ drivers/net/sfc/sfc_flow.c | 6 +++ drivers/net/tap/tap_flow.c | 6 +++ lib/librte_ether/rte_flow.h | 18 +++++++- 15 files changed, 200 insertions(+), 8 deletions(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 3a486032d..122e9d50b 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -69,6 +69,7 @@ enum index { PRIORITY, INGRESS, EGRESS, + TRANSFER, /* Validate/create pattern. */ PATTERN, @@ -407,6 +408,7 @@ static const enum index next_vc_attr[] = { PRIORITY, INGRESS, EGRESS, + TRANSFER, PATTERN, ZERO, }; @@ -960,6 +962,12 @@ static const struct token token_list[] = { .next = NEXT(next_vc_attr), .call = parse_vc, }, + [TRANSFER] = { + .name = "transfer", + .help = "apply rule directly to endpoints found in pattern", + .next = NEXT(next_vc_attr), + .call = parse_vc, + }, /* Validate/create pattern. */ [PATTERN] = { .name = "pattern", @@ -1945,6 +1953,9 @@ parse_vc(struct context *ctx, const struct token *token, case EGRESS: out->args.vc.attr.egress = 1; return len; + case TRANSFER: + out->args.vc.attr.transfer = 1; + return len; case PATTERN: out->args.vc.pattern = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1), diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index c0fefe475..49ef87782 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -1223,6 +1223,7 @@ port_flow_complain(struct rte_flow_error *error) [RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY] = "priority field", [RTE_FLOW_ERROR_TYPE_ATTR_INGRESS] = "ingress field", [RTE_FLOW_ERROR_TYPE_ATTR_EGRESS] = "egress field", + [RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER] = "transfer field", [RTE_FLOW_ERROR_TYPE_ATTR] = "attributes structure", [RTE_FLOW_ERROR_TYPE_ITEM_NUM] = "pattern length", [RTE_FLOW_ERROR_TYPE_ITEM_SPEC] = "item specification", @@ -1488,12 +1489,13 @@ port_flow_list(portid_t port_id, uint32_t n, const uint32_t group[n]) const struct rte_flow_item *item = pf->pattern; const struct rte_flow_action *action = pf->actions; - printf("%" PRIu32 "\t%" PRIu32 "\t%" PRIu32 "\t%c%c\t", + printf("%" PRIu32 "\t%" PRIu32 "\t%" PRIu32 "\t%c%c%c\t", pf->id, pf->attr.group, pf->attr.priority, pf->attr.ingress ? 'i' : '-', - pf->attr.egress ? 'e' : '-'); + pf->attr.egress ? 'e' : '-', + pf->attr.transfer ? 't' : '-'); while (item->type != RTE_FLOW_ITEM_TYPE_END) { if (item->type != RTE_FLOW_ITEM_TYPE_VOID) printf("%s ", flow_item[item->type].name); diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index f1b9d8d76..a4c8f5e3e 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -178,6 +178,20 @@ directions. At least one direction must be specified. Specifying both directions at once for a given rule is not recommended but may be valid in a few cases (e.g. shared counters). +Attribute: Transfer +^^^^^^^^^^^^^^^^^^^ + +Instead of simply matching the properties of traffic as it would appear on a +given DPDK port ID, enabling this attribute transfers a flow rule to the +lowest possible level of any device endpoints found in the pattern. + +When supported, this effectively enables an application to re-route traffic +not necessarily intended for it (e.g. coming from or addressed to different +physical ports, VFs or applications) at the device level. + +It complements the behavior of some pattern items such as `Item: PORT`_ and +is meaningless without them. + Pattern item ~~~~~~~~~~~~ diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index 25fac8430..a87cd1542 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -2970,14 +2970,14 @@ following sections. - Check whether a flow rule can be created:: flow validate {port_id} - [group {group_id}] [priority {level}] [ingress] [egress] + [group {group_id}] [priority {level}] [ingress] [egress] [transfer] pattern {item} [/ {item} [...]] / end actions {action} [/ {action} [...]] / end - Create a flow rule:: flow create {port_id} - [group {group_id}] [priority {level}] [ingress] [egress] + [group {group_id}] [priority {level}] [ingress] [egress] [transfer] pattern {item} [/ {item} [...]] / end actions {action} [/ {action} [...]] / end @@ -3010,7 +3010,7 @@ underlying device in its current state but stops short of creating it. It is bound to ``rte_flow_validate()``:: flow validate {port_id} - [group {group_id}] [priority {level}] [ingress] [egress] + [group {group_id}] [priority {level}] [ingress] [egress] [transfer] pattern {item} [/ {item} [...]] / end actions {action} [/ {action} [...]] / end @@ -3047,7 +3047,7 @@ Creating flow rules to ``rte_flow_create()``:: flow create {port_id} - [group {group_id}] [priority {level}] [ingress] [egress] + [group {group_id}] [priority {level}] [ingress] [egress] [transfer] pattern {item} [/ {item} [...]] / end actions {action} [/ {action} [...]] / end @@ -3061,7 +3061,7 @@ Otherwise it will show an error message of the form:: Parameters describe in the following order: -- Attributes (*group*, *priority*, *ingress*, *egress* tokens). +- Attributes (*group*, *priority*, *ingress*, *egress*, *transfer* tokens). - A matching pattern, starting with the *pattern* token and terminated by an *end* pattern item. - Actions, starting with the *actions* token and terminated by an *end* @@ -3089,6 +3089,7 @@ specified before the ``pattern`` token. - ``priority {level}``: priority level within group. - ``ingress``: rule applies to ingress traffic. - ``egress``: rule applies to egress traffic. +- ``transfer``: apply rule directly to endpoints found in pattern. Each instance of an attribute specified several times overrides the previous value as shown below (group 4 is used):: diff --git a/drivers/net/bnxt/bnxt_filter.c b/drivers/net/bnxt/bnxt_filter.c index a97a8dd46..dedd24166 100644 --- a/drivers/net/bnxt/bnxt_filter.c +++ b/drivers/net/bnxt/bnxt_filter.c @@ -777,6 +777,14 @@ bnxt_flow_parse_attr(const struct rte_flow_attr *attr, } /* Not supported */ + if (attr->transfer) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + attr, "No support for transfer."); + return -rte_errno; + } + + /* Not supported */ if (attr->priority) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, diff --git a/drivers/net/e1000/igb_flow.c b/drivers/net/e1000/igb_flow.c index 13f6f2a28..ac0d05bfa 100644 --- a/drivers/net/e1000/igb_flow.c +++ b/drivers/net/e1000/igb_flow.c @@ -379,6 +379,15 @@ cons_parse_ntuple_filter(const struct rte_flow_attr *attr, return -rte_errno; } + /* not supported */ + if (attr->transfer) { + memset(filter, 0, sizeof(struct rte_eth_ntuple_filter)); + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + attr, "No support for transfer."); + return -rte_errno; + } + if (attr->priority > 0xFFFF) { memset(filter, 0, sizeof(struct rte_eth_ntuple_filter)); rte_flow_error_set(error, EINVAL, @@ -624,6 +633,14 @@ cons_parse_ethertype_filter(const struct rte_flow_attr *attr, } /* Not supported */ + if (attr->transfer) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + attr, "No support for transfer."); + return -rte_errno; + } + + /* Not supported */ if (attr->priority) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, @@ -923,6 +940,15 @@ cons_parse_syn_filter(const struct rte_flow_attr *attr, return -rte_errno; } + /* not supported */ + if (attr->transfer) { + memset(filter, 0, sizeof(struct rte_eth_syn_filter)); + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + attr, "No support for transfer."); + return -rte_errno; + } + /* Support 2 priorities, the lowest or highest. */ if (!attr->priority) { filter->hig_pri = 0; @@ -1211,6 +1237,15 @@ cons_parse_flex_filter(const struct rte_flow_attr *attr, return -rte_errno; } + /* not supported */ + if (attr->transfer) { + memset(filter, 0, sizeof(struct rte_eth_flex_filter)); + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + attr, "No support for transfer."); + return -rte_errno; + } + if (attr->priority > 0xFFFF) { memset(filter, 0, sizeof(struct rte_eth_flex_filter)); rte_flow_error_set(error, EINVAL, @@ -1361,6 +1396,15 @@ igb_parse_rss_filter(struct rte_eth_dev *dev, return -rte_errno; } + /* not supported */ + if (attr->transfer) { + memset(rss_conf, 0, sizeof(struct igb_rte_flow_rss_conf)); + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + attr, "No support for transfer."); + return -rte_errno; + } + if (attr->priority > 0xFFFF) { memset(rss_conf, 0, sizeof(struct igb_rte_flow_rss_conf)); rte_flow_error_set(error, EINVAL, diff --git a/drivers/net/enic/enic_flow.c b/drivers/net/enic/enic_flow.c index a413740ab..3ec4de72a 100644 --- a/drivers/net/enic/enic_flow.c +++ b/drivers/net/enic/enic_flow.c @@ -1300,6 +1300,12 @@ enic_flow_parse(struct rte_eth_dev *dev, NULL, "egress is not supported"); return -rte_errno; + } else if (attrs->transfer) { + rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + NULL, + "transfer is not supported"); + return -rte_errno; } else if (!attrs->ingress) { rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c index c6dd889ad..e374f874b 100644 --- a/drivers/net/i40e/i40e_flow.c +++ b/drivers/net/i40e/i40e_flow.c @@ -1917,6 +1917,14 @@ i40e_flow_parse_attr(const struct rte_flow_attr *attr, } /* Not supported */ + if (attr->transfer) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + attr, "No support for transfer."); + return -rte_errno; + } + + /* Not supported */ if (attr->priority) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, diff --git a/drivers/net/ixgbe/ixgbe_flow.c b/drivers/net/ixgbe/ixgbe_flow.c index 67d22b382..1f1fa9dc4 100644 --- a/drivers/net/ixgbe/ixgbe_flow.c +++ b/drivers/net/ixgbe/ixgbe_flow.c @@ -557,6 +557,15 @@ cons_parse_ntuple_filter(const struct rte_flow_attr *attr, return -rte_errno; } + /* not supported */ + if (attr->transfer) { + memset(filter, 0, sizeof(struct rte_eth_ntuple_filter)); + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + attr, "No support for transfer."); + return -rte_errno; + } + if (attr->priority > 0xFFFF) { memset(filter, 0, sizeof(struct rte_eth_ntuple_filter)); rte_flow_error_set(error, EINVAL, @@ -787,6 +796,14 @@ cons_parse_ethertype_filter(const struct rte_flow_attr *attr, } /* Not supported */ + if (attr->transfer) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + attr, "No support for transfer."); + return -rte_errno; + } + + /* Not supported */ if (attr->priority) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, @@ -1078,6 +1095,15 @@ cons_parse_syn_filter(const struct rte_flow_attr *attr, return -rte_errno; } + /* not supported */ + if (attr->transfer) { + memset(filter, 0, sizeof(struct rte_eth_syn_filter)); + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + attr, "No support for transfer."); + return -rte_errno; + } + /* Support 2 priorities, the lowest or highest. */ if (!attr->priority) { filter->hig_pri = 0; @@ -1250,6 +1276,15 @@ cons_parse_l2_tn_filter(struct rte_eth_dev *dev, } /* not supported */ + if (attr->transfer) { + memset(filter, 0, sizeof(struct rte_eth_l2_tunnel_conf)); + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + attr, "No support for transfer."); + return -rte_errno; + } + + /* not supported */ if (attr->priority) { memset(filter, 0, sizeof(struct rte_eth_l2_tunnel_conf)); rte_flow_error_set(error, EINVAL, @@ -1354,6 +1389,15 @@ ixgbe_parse_fdir_act_attr(const struct rte_flow_attr *attr, } /* not supported */ + if (attr->transfer) { + memset(rule, 0, sizeof(struct ixgbe_fdir_rule)); + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + attr, "No support for transfer."); + return -rte_errno; + } + + /* not supported */ if (attr->priority) { memset(rule, 0, sizeof(struct ixgbe_fdir_rule)); rte_flow_error_set(error, EINVAL, @@ -2829,6 +2873,15 @@ ixgbe_parse_rss_filter(struct rte_eth_dev *dev, return -rte_errno; } + /* not supported */ + if (attr->transfer) { + memset(rss_conf, 0, sizeof(struct ixgbe_rte_flow_rss_conf)); + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + attr, "No support for transfer."); + return -rte_errno; + } + if (attr->priority > 0xFFFF) { memset(rss_conf, 0, sizeof(struct ixgbe_rte_flow_rss_conf)); rte_flow_error_set(error, EINVAL, diff --git a/drivers/net/mlx4/mlx4_flow.c b/drivers/net/mlx4/mlx4_flow.c index 779641e11..480442f87 100644 --- a/drivers/net/mlx4/mlx4_flow.c +++ b/drivers/net/mlx4/mlx4_flow.c @@ -652,6 +652,10 @@ mlx4_flow_prepare(struct priv *priv, return rte_flow_error_set (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, NULL, "egress is not supported"); + if (attr->transfer) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + NULL, "transfer is not supported"); if (!attr->ingress) return rte_flow_error_set (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index f03413d32..5c48670c6 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -568,6 +568,13 @@ mlx5_flow_convert_attributes(const struct rte_flow_attr *attr, "egress is not supported"); return -rte_errno; } + if (attr->transfer) { + rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + NULL, + "transfer is not supported"); + return -rte_errno; + } if (!attr->ingress) { rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, diff --git a/drivers/net/mvpp2/mrvl_flow.c b/drivers/net/mvpp2/mrvl_flow.c index 6604a411f..4848d5cf9 100644 --- a/drivers/net/mvpp2/mrvl_flow.c +++ b/drivers/net/mvpp2/mrvl_flow.c @@ -2188,6 +2188,12 @@ mrvl_flow_parse_attr(struct mrvl_priv *priv __rte_unused, "Egress is not supported"); return -rte_errno; } + if (attr->transfer) { + rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, NULL, + "Transfer is not supported"); + return -rte_errno; + } return 0; } diff --git a/drivers/net/sfc/sfc_flow.c b/drivers/net/sfc/sfc_flow.c index 515a61325..77598f2a4 100644 --- a/drivers/net/sfc/sfc_flow.c +++ b/drivers/net/sfc/sfc_flow.c @@ -1126,6 +1126,12 @@ sfc_flow_parse_attr(const struct rte_flow_attr *attr, "Egress is not supported"); return -rte_errno; } + if (attr->transfer != 0) { + rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, attr, + "Transfer is not supported"); + return -rte_errno; + } if (attr->ingress == 0) { rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, attr, diff --git a/drivers/net/tap/tap_flow.c b/drivers/net/tap/tap_flow.c index e53eff6ce..597945ad2 100644 --- a/drivers/net/tap/tap_flow.c +++ b/drivers/net/tap/tap_flow.c @@ -1041,6 +1041,12 @@ priv_flow_process(struct pmd_internals *pmd, }; int action = 0; /* Only one action authorized for now */ + if (attr->transfer) { + rte_flow_error_set( + error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + NULL, "transfer is not supported"); + return -rte_errno; + } if (attr->group > MAX_GROUP) { rte_flow_error_set( error, EINVAL, RTE_FLOW_ERROR_TYPE_ATTR_GROUP, diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index 15e383f95..cbb9fd53b 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -72,7 +72,22 @@ struct rte_flow_attr { uint32_t priority; /**< Priority level within group. */ uint32_t ingress:1; /**< Rule applies to ingress traffic. */ uint32_t egress:1; /**< Rule applies to egress traffic. */ - uint32_t reserved:30; /**< Reserved, must be zero. */ + /** + * Instead of simply matching the properties of traffic as it would + * appear on a given DPDK port ID, enabling this attribute transfers + * a flow rule to the lowest possible level of any device endpoints + * found in the pattern. + * + * When supported, this effectively enables an application to + * re-route traffic not necessarily intended for it (e.g. coming + * from or addressed to different physical ports, VFs or + * applications) at the device level. + * + * It complements the behavior of some pattern items such as + * RTE_FLOW_ITEM_TYPE_PORT and is meaningless without them. + */ + uint32_t transfer:1; + uint32_t reserved:29; /**< Reserved, must be zero. */ }; /** @@ -1174,6 +1189,7 @@ enum rte_flow_error_type { RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, /**< Priority field. */ RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, /**< Ingress field. */ RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, /**< Egress field. */ + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, /**< Transfer field. */ RTE_FLOW_ERROR_TYPE_ATTR, /**< Attributes structure. */ RTE_FLOW_ERROR_TYPE_ITEM_NUM, /**< Pattern length. */ RTE_FLOW_ERROR_TYPE_ITEM_SPEC, /**< Item specification. */ -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v1 13/16] ethdev: update behavior of VF/PF in flow API 2018-04-04 15:56 [dpdk-dev] [PATCH v1 00/16] Flow API overhaul for switch offloads Adrien Mazarguil ` (11 preceding siblings ...) 2018-04-04 15:56 ` [dpdk-dev] [PATCH v1 12/16] ethdev: add transfer attribute to " Adrien Mazarguil @ 2018-04-04 15:56 ` Adrien Mazarguil 2018-04-04 15:56 ` [dpdk-dev] [PATCH v1 14/16] ethdev: rename physical port item " Adrien Mazarguil ` (3 subsequent siblings) 16 siblings, 0 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-04 15:56 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev Cc: Ajit Khaparde, Somnath Kotur, Beilei Xing, Qi Zhang Contrary to all other pattern items, these are inconsistently documented as affecting traffic instead of simply matching its origin, without provision for the latter. This commit clarifies documentation and updates PMDs since the original behavior now has to be explicitly requested using the new transfer attribute. Impacted PMDs are bnxt and i40e, for which the VF pattern item is now only supported when a transfer attribute is also present. Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Cc: Ajit Khaparde <ajit.khaparde@broadcom.com> Cc: Somnath Kotur <somnath.kotur@broadcom.com> Cc: Beilei Xing <beilei.xing@intel.com> Cc: Qi Zhang <qi.z.zhang@intel.com> --- app/test-pmd/cmdline_flow.c | 12 +++--- doc/guides/prog_guide/rte_flow.rst | 36 +++++++++--------- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 12 +++--- drivers/net/bnxt/bnxt_filter.c | 22 ++++++----- drivers/net/i40e/i40e_flow.c | 23 +++++++----- lib/librte_ether/rte_flow.h | 47 ++++++++++-------------- 6 files changed, 77 insertions(+), 75 deletions(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 122e9d50b..741d66b22 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -1041,21 +1041,21 @@ static const struct token token_list[] = { }, [ITEM_PF] = { .name = "pf", - .help = "match packets addressed to the physical function", + .help = "match traffic from/to the physical function", .priv = PRIV_ITEM(PF, 0), .next = NEXT(NEXT_ENTRY(ITEM_NEXT)), .call = parse_vc, }, [ITEM_VF] = { .name = "vf", - .help = "match packets addressed to a virtual function ID", + .help = "match traffic from/to a virtual function ID", .priv = PRIV_ITEM(VF, sizeof(struct rte_flow_item_vf)), .next = NEXT(item_vf), .call = parse_vc, }, [ITEM_VF_ID] = { .name = "id", - .help = "destination VF ID", + .help = "VF ID", .next = NEXT(item_vf, NEXT_ENTRY(UNSIGNED), item_param), .args = ARGS(ARGS_ENTRY(struct rte_flow_item_vf, id)), }, @@ -1686,14 +1686,14 @@ static const struct token token_list[] = { }, [ACTION_PF] = { .name = "pf", - .help = "redirect packets to physical device function", + .help = "direct traffic to physical function", .priv = PRIV_ACTION(PF, 0), .next = NEXT(NEXT_ENTRY(ACTION_NEXT)), .call = parse_vc, }, [ACTION_VF] = { .name = "vf", - .help = "redirect packets to virtual device function", + .help = "direct traffic to a virtual function ID", .priv = PRIV_ACTION(VF, sizeof(struct rte_flow_action_vf)), .next = NEXT(action_vf), .call = parse_vc, @@ -1708,7 +1708,7 @@ static const struct token token_list[] = { }, [ACTION_VF_ID] = { .name = "id", - .help = "VF ID to redirect packets to", + .help = "VF ID", .next = NEXT(action_vf, NEXT_ENTRY(UNSIGNED)), .args = ARGS(ARGS_ENTRY(struct rte_flow_action_vf, id)), .call = parse_vc_conf, diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index a4c8f5e3e..070db1926 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -518,15 +518,12 @@ Usage example, matching non-TCPv4 packets only: Item: ``PF`` ^^^^^^^^^^^^ -Matches packets addressed to the physical function of the device. +Matches traffic originating from (ingress) or going to (egress) the physical +function of the current device. -If the underlying device function differs from the one that would normally -receive the matched traffic, specifying this item prevents it from reaching -that device unless the flow rule contains a `Action: PF`_. Packets are not -duplicated between device instances by default. +If supported, should work even if the physical function is not managed by +the application and thus not associated with a DPDK port ID. -- Likely to return an error or never match any traffic if applied to a VF - device. - Can be combined with any number of `Item: VF`_ to match both PF and VF traffic. - ``spec``, ``last`` and ``mask`` must not be set. @@ -548,15 +545,15 @@ duplicated between device instances by default. Item: ``VF`` ^^^^^^^^^^^^ -Matches packets addressed to a virtual function ID of the device. +Matches traffic originating from (ingress) or going to (egress) a given +virtual function of the current device. -If the underlying device function differs from the one that would normally -receive the matched traffic, specifying this item prevents it from reaching -that device unless the flow rule contains a `Action: VF`_. Packets are not -duplicated between device instances by default. +If supported, should work even if the virtual function is not managed by the +application and thus not associated with a DPDK port ID. + +Note this pattern item does not match VF representors traffic which, as +separate entities, should be addressed through their own DPDK port IDs. -- Likely to return an error or never match any traffic if this causes a VF - device to match traffic addressed to a different VF. - Can be specified multiple times to match traffic addressed to several VF IDs. - Can be combined with a PF item to match both PF and VF traffic. @@ -1378,7 +1375,10 @@ only matching traffic goes through. Action: ``PF`` ^^^^^^^^^^^^^^ -Redirects packets to the physical function (PF) of the current device. +Directs matching traffic to the physical function (PF) of the current +device. + +See `Item: PF`_. - No configurable properties. @@ -1395,13 +1395,15 @@ Redirects packets to the physical function (PF) of the current device. Action: ``VF`` ^^^^^^^^^^^^^^ -Redirects packets to a virtual function (VF) of the current device. +Directs matching traffic to a given virtual function of the current device. Packets matched by a VF pattern item can be redirected to their original VF ID instead of the specified one. This parameter may not be available and is not guaranteed to work properly if the VF part is matched by a prior flow rule or if packets are not addressed to a VF in the first place. +See `Item: VF`_. + .. _table_rte_flow_action_vf: .. table:: VF @@ -1411,7 +1413,7 @@ rule or if packets are not addressed to a VF in the first place. +==============+================================+ | ``original`` | use original VF ID if possible | +--------------+--------------------------------+ - | ``vf`` | VF ID to redirect packets to | + | ``id`` | VF ID | +--------------+--------------------------------+ Action: ``METER`` diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index a87cd1542..2f1db9a29 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3202,11 +3202,11 @@ This section lists supported pattern items and their attributes, if any. - ``num {unsigned}``: number of layers covered. -- ``pf``: match packets addressed to the physical function. +- ``pf``: match traffic from/to the physical function. -- ``vf``: match packets addressed to a virtual function ID. +- ``vf``: match traffic from/to a virtual function ID. - - ``id {unsigned}``: destination VF ID. + - ``id {unsigned}``: VF ID. - ``port``: device-specific physical port index to use. @@ -3414,12 +3414,12 @@ This section lists supported actions and their attributes, if any. - ``queues [{unsigned} [...]] end``: queue indices to use. -- ``pf``: redirect packets to physical device function. +- ``pf``: direct traffic to physical function. -- ``vf``: redirect packets to virtual device function. +- ``vf``: direct traffic to a virtual function ID. - ``original {boolean}``: use original VF ID if possible. - - ``id {unsigned}``: VF ID to redirect packets to. + - ``id {unsigned}``: VF ID. Destroying flow rules ~~~~~~~~~~~~~~~~~~~~~ diff --git a/drivers/net/bnxt/bnxt_filter.c b/drivers/net/bnxt/bnxt_filter.c index dedd24166..2a7beaf66 100644 --- a/drivers/net/bnxt/bnxt_filter.c +++ b/drivers/net/bnxt/bnxt_filter.c @@ -303,6 +303,7 @@ bnxt_filter_type_check(const struct rte_flow_item pattern[], static int bnxt_validate_and_parse_flow_type(struct bnxt *bp, + const struct rte_flow_attr *attr, const struct rte_flow_item pattern[], struct rte_flow_error *error, struct bnxt_filter_info *filter) @@ -730,6 +731,16 @@ bnxt_validate_and_parse_flow_type(struct bnxt *bp, return -rte_errno; } + if (!attr->transfer) { + rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ITEM, + item, + "Matching VF traffic without" + " affecting it (transfer attribute)" + " is unsupported"); + return -rte_errno; + } + filter->mirror_vnic_id = dflt_vnic = bnxt_hwrm_func_qcfg_vf_dflt_vnic_id(bp, vf); if (dflt_vnic < 0) { @@ -777,14 +788,6 @@ bnxt_flow_parse_attr(const struct rte_flow_attr *attr, } /* Not supported */ - if (attr->transfer) { - rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, - attr, "No support for transfer."); - return -rte_errno; - } - - /* Not supported */ if (attr->priority) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, @@ -864,7 +867,8 @@ bnxt_validate_and_parse_flow(struct rte_eth_dev *dev, goto ret; } - rc = bnxt_validate_and_parse_flow_type(bp, pattern, error, filter); + rc = bnxt_validate_and_parse_flow_type(bp, attr, pattern, error, + filter); if (rc != 0) goto ret; diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c index e374f874b..e3a77dfce 100644 --- a/drivers/net/i40e/i40e_flow.c +++ b/drivers/net/i40e/i40e_flow.c @@ -53,6 +53,7 @@ static int i40e_flow_parse_ethertype_action(struct rte_eth_dev *dev, struct rte_flow_error *error, struct rte_eth_ethertype_filter *filter); static int i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev, + const struct rte_flow_attr *attr, const struct rte_flow_item *pattern, struct rte_flow_error *error, struct i40e_fdir_filter_conf *filter); @@ -1917,14 +1918,6 @@ i40e_flow_parse_attr(const struct rte_flow_attr *attr, } /* Not supported */ - if (attr->transfer) { - rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, - attr, "No support for transfer."); - return -rte_errno; - } - - /* Not supported */ if (attr->priority) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, @@ -2427,6 +2420,7 @@ i40e_flow_fdir_get_pctype_value(struct i40e_pf *pf, */ static int i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev, + const struct rte_flow_attr *attr, const struct rte_flow_item *pattern, struct rte_flow_error *error, struct i40e_fdir_filter_conf *filter) @@ -2973,6 +2967,16 @@ i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev, break; case RTE_FLOW_ITEM_TYPE_VF: vf_spec = item->spec; + if (!attr->transfer) { + rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ITEM, + item, + "Matching VF traffic" + " without affecting it" + " (transfer attribute)" + " is unsupported"); + return -rte_errno; + } filter->input.flow_ext.is_vf = 1; filter->input.flow_ext.dst_id = vf_spec->id; if (filter->input.flow_ext.is_vf && @@ -3135,7 +3139,8 @@ i40e_flow_parse_fdir_filter(struct rte_eth_dev *dev, &filter->fdir_filter; int ret; - ret = i40e_flow_parse_fdir_pattern(dev, pattern, error, fdir_filter); + ret = i40e_flow_parse_fdir_pattern(dev, attr, pattern, error, + fdir_filter); if (ret) return ret; diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index cbb9fd53b..6d8582f18 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -148,13 +148,8 @@ enum rte_flow_item_type { /** * [META] * - * Matches packets addressed to the physical function of the device. - * - * If the underlying device function differs from the one that would - * normally receive the matched traffic, specifying this item - * prevents it from reaching that device unless the flow rule - * contains a PF action. Packets are not duplicated between device - * instances by default. + * Matches traffic originating from (ingress) or going to (egress) + * the physical function of the current device. * * No associated specification structure. */ @@ -163,13 +158,8 @@ enum rte_flow_item_type { /** * [META] * - * Matches packets addressed to a virtual function ID of the device. - * - * If the underlying device function differs from the one that would - * normally receive the matched traffic, specifying this item - * prevents it from reaching that device unless the flow rule - * contains a VF action. Packets are not duplicated between device - * instances by default. + * Matches traffic originating from (ingress) or going to (egress) a + * given virtual function of the current device. * * See struct rte_flow_item_vf. */ @@ -367,15 +357,15 @@ static const struct rte_flow_item_any rte_flow_item_any_mask = { /** * RTE_FLOW_ITEM_TYPE_VF * - * Matches packets addressed to a virtual function ID of the device. + * Matches traffic originating from (ingress) or going to (egress) a given + * virtual function of the current device. * - * If the underlying device function differs from the one that would - * normally receive the matched traffic, specifying this item prevents it - * from reaching that device unless the flow rule contains a VF - * action. Packets are not duplicated between device instances by default. + * If supported, should work even if the virtual function is not managed by + * the application and thus not associated with a DPDK port ID. + * + * Note this pattern item does not match VF representors traffic which, as + * separate entities, should be addressed through their own DPDK port IDs. * - * - Likely to return an error or never match any traffic if this causes a - * VF device to match traffic addressed to a different VF. * - Can be specified multiple times to match traffic addressed to several * VF IDs. * - Can be combined with a PF item to match both PF and VF traffic. @@ -383,7 +373,7 @@ static const struct rte_flow_item_any rte_flow_item_any_mask = { * A zeroed mask can be used to match any VF ID. */ struct rte_flow_item_vf { - uint32_t id; /**< Destination VF ID. */ + uint32_t id; /**< VF ID. */ }; /** Default mask for RTE_FLOW_ITEM_TYPE_VF. */ @@ -983,16 +973,16 @@ enum rte_flow_action_type { RTE_FLOW_ACTION_TYPE_RSS, /** - * Redirects packets to the physical function (PF) of the current - * device. + * Directs matching traffic to the physical function (PF) of the + * current device. * * No associated configuration structure. */ RTE_FLOW_ACTION_TYPE_PF, /** - * Redirects packets to the virtual function (VF) of the current - * device with the specified ID. + * Directs matching traffic to a given virtual function of the + * current device. * * See struct rte_flow_action_vf. */ @@ -1100,7 +1090,8 @@ struct rte_flow_action_rss { /** * RTE_FLOW_ACTION_TYPE_VF * - * Redirects packets to a virtual function (VF) of the current device. + * Directs matching traffic to a given virtual function of the current + * device. * * Packets matched by a VF pattern item can be redirected to their original * VF ID instead of the specified one. This parameter may not be available @@ -1111,7 +1102,7 @@ struct rte_flow_action_rss { struct rte_flow_action_vf { uint32_t original:1; /**< Use original VF ID if possible. */ uint32_t reserved:31; /**< Reserved, must be zero. */ - uint32_t id; /**< VF ID to redirect packets to. */ + uint32_t id; /**< VF ID. */ }; /** -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v1 14/16] ethdev: rename physical port item in flow API 2018-04-04 15:56 [dpdk-dev] [PATCH v1 00/16] Flow API overhaul for switch offloads Adrien Mazarguil ` (12 preceding siblings ...) 2018-04-04 15:56 ` [dpdk-dev] [PATCH v1 13/16] ethdev: update behavior of VF/PF in " Adrien Mazarguil @ 2018-04-04 15:56 ` Adrien Mazarguil 2018-04-04 15:56 ` [dpdk-dev] [PATCH v1 15/16] ethdev: add physical port action to " Adrien Mazarguil ` (2 subsequent siblings) 16 siblings, 0 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-04 15:56 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev While RTE_FLOW_ITEM_TYPE_PORT refers to physical ports of the underlying device using specific identifiers, these are often confused with DPDK port IDs exposed to applications in the global name space. Since this pattern item is seldom used, rename it RTE_FLOW_ITEM_PHY_PORT for better clarity. Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> --- app/test-pmd/cmdline_flow.c | 27 +++++++++++---------- app/test-pmd/config.c | 2 +- doc/guides/prog_guide/rte_flow.rst | 18 +++++++------- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 2 +- lib/librte_ether/rte_flow.c | 2 +- lib/librte_ether/rte_flow.h | 31 ++++++++++-------------- 6 files changed, 39 insertions(+), 43 deletions(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 741d66b22..bfe532f0a 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -87,8 +87,8 @@ enum index { ITEM_PF, ITEM_VF, ITEM_VF_ID, - ITEM_PORT, - ITEM_PORT_INDEX, + ITEM_PHY_PORT, + ITEM_PHY_PORT_INDEX, ITEM_RAW, ITEM_RAW_RELATIVE, ITEM_RAW_SEARCH, @@ -441,7 +441,7 @@ static const enum index next_item[] = { ITEM_ANY, ITEM_PF, ITEM_VF, - ITEM_PORT, + ITEM_PHY_PORT, ITEM_RAW, ITEM_ETH, ITEM_VLAN, @@ -482,8 +482,8 @@ static const enum index item_vf[] = { ZERO, }; -static const enum index item_port[] = { - ITEM_PORT_INDEX, +static const enum index item_phy_port[] = { + ITEM_PHY_PORT_INDEX, ITEM_NEXT, ZERO, }; @@ -1059,18 +1059,19 @@ static const struct token token_list[] = { .next = NEXT(item_vf, NEXT_ENTRY(UNSIGNED), item_param), .args = ARGS(ARGS_ENTRY(struct rte_flow_item_vf, id)), }, - [ITEM_PORT] = { - .name = "port", - .help = "device-specific physical port index to use", - .priv = PRIV_ITEM(PORT, sizeof(struct rte_flow_item_port)), - .next = NEXT(item_port), + [ITEM_PHY_PORT] = { + .name = "phy_port", + .help = "match traffic from/to a specific physical port", + .priv = PRIV_ITEM(PHY_PORT, + sizeof(struct rte_flow_item_phy_port)), + .next = NEXT(item_phy_port), .call = parse_vc, }, - [ITEM_PORT_INDEX] = { + [ITEM_PHY_PORT_INDEX] = { .name = "index", .help = "physical port index", - .next = NEXT(item_port, NEXT_ENTRY(UNSIGNED), item_param), - .args = ARGS(ARGS_ENTRY(struct rte_flow_item_port, index)), + .next = NEXT(item_phy_port, NEXT_ENTRY(UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_phy_port, index)), }, [ITEM_RAW] = { .name = "raw", diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 49ef87782..9f968919e 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -960,7 +960,7 @@ static const struct { MK_FLOW_ITEM(ANY, sizeof(struct rte_flow_item_any)), MK_FLOW_ITEM(PF, 0), MK_FLOW_ITEM(VF, sizeof(struct rte_flow_item_vf)), - MK_FLOW_ITEM(PORT, sizeof(struct rte_flow_item_port)), + MK_FLOW_ITEM(PHY_PORT, sizeof(struct rte_flow_item_phy_port)), MK_FLOW_ITEM(RAW, sizeof(struct rte_flow_item_raw)), MK_FLOW_ITEM(ETH, sizeof(struct rte_flow_item_eth)), MK_FLOW_ITEM(VLAN, sizeof(struct rte_flow_item_vlan)), diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 070db1926..aab124d99 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -573,15 +573,15 @@ separate entities, should be addressed through their own DPDK port IDs. | ``mask`` | ``id`` | zeroed to match any VF ID | +----------+----------+---------------------------+ -Item: ``PORT`` -^^^^^^^^^^^^^^ +Item: ``PHY_PORT`` +^^^^^^^^^^^^^^^^^^ -Matches packets coming from the specified physical port of the underlying -device. +Matches traffic originating from (ingress) or going to (egress) a physical +port of the underlying device. -The first PORT item overrides the physical port normally associated with the -specified DPDK input port (port_id). This item can be provided several times -to match additional physical ports. +The first PHY_PORT item overrides the physical port normally associated with +the specified DPDK input port (port_id). This item can be provided several +times to match additional physical ports. Note that physical ports are not necessarily tied to DPDK input ports (port_id) when those are not under DPDK control. Possible values are @@ -593,9 +593,9 @@ associated with a port_id should be retrieved by other means. - Default ``mask`` matches any port index. -.. _table_rte_flow_item_port: +.. _table_rte_flow_item_phy_port: -.. table:: PORT +.. table:: PHY_PORT +----------+-----------+--------------------------------+ | Field | Subfield | Value | diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index 2f1db9a29..1d9ce6963 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3208,7 +3208,7 @@ This section lists supported pattern items and their attributes, if any. - ``id {unsigned}``: VF ID. -- ``port``: device-specific physical port index to use. +- ``phy_port``: match traffic from/to a specific physical port. - ``index {unsigned}``: physical port index. diff --git a/lib/librte_ether/rte_flow.c b/lib/librte_ether/rte_flow.c index 1f247d656..6d4d7f5ed 100644 --- a/lib/librte_ether/rte_flow.c +++ b/lib/librte_ether/rte_flow.c @@ -38,7 +38,7 @@ static const struct rte_flow_desc_data rte_flow_desc_item[] = { MK_FLOW_ITEM(ANY, sizeof(struct rte_flow_item_any)), MK_FLOW_ITEM(PF, 0), MK_FLOW_ITEM(VF, sizeof(struct rte_flow_item_vf)), - MK_FLOW_ITEM(PORT, sizeof(struct rte_flow_item_port)), + MK_FLOW_ITEM(PHY_PORT, sizeof(struct rte_flow_item_phy_port)), MK_FLOW_ITEM(RAW, sizeof(struct rte_flow_item_raw)), MK_FLOW_ITEM(ETH, sizeof(struct rte_flow_item_eth)), MK_FLOW_ITEM(VLAN, sizeof(struct rte_flow_item_vlan)), diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index 6d8582f18..1fcec5a97 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -84,7 +84,7 @@ struct rte_flow_attr { * applications) at the device level. * * It complements the behavior of some pattern items such as - * RTE_FLOW_ITEM_TYPE_PORT and is meaningless without them. + * RTE_FLOW_ITEM_TYPE_PHY_PORT and is meaningless without them. */ uint32_t transfer:1; uint32_t reserved:29; /**< Reserved, must be zero. */ @@ -168,17 +168,12 @@ enum rte_flow_item_type { /** * [META] * - * Matches packets coming from the specified physical port of the - * underlying device. - * - * The first PORT item overrides the physical port normally - * associated with the specified DPDK input port (port_id). This - * item can be provided several times to match additional physical - * ports. + * Matches traffic originating from (ingress) or going to (egress) a + * physical port of the underlying device. * - * See struct rte_flow_item_port. + * See struct rte_flow_item_phy_port. */ - RTE_FLOW_ITEM_TYPE_PORT, + RTE_FLOW_ITEM_TYPE_PHY_PORT, /** * Matches a byte string of a given length at a given offset. @@ -384,13 +379,13 @@ static const struct rte_flow_item_vf rte_flow_item_vf_mask = { #endif /** - * RTE_FLOW_ITEM_TYPE_PORT + * RTE_FLOW_ITEM_TYPE_PHY_PORT * - * Matches packets coming from the specified physical port of the underlying - * device. + * Matches traffic originating from (ingress) or going to (egress) a + * physical port of the underlying device. * - * The first PORT item overrides the physical port normally associated with - * the specified DPDK input port (port_id). This item can be provided + * The first PHY_PORT item overrides the physical port normally associated + * with the specified DPDK input port (port_id). This item can be provided * several times to match additional physical ports. * * Note that physical ports are not necessarily tied to DPDK input ports @@ -403,13 +398,13 @@ static const struct rte_flow_item_vf rte_flow_item_vf_mask = { * * A zeroed mask can be used to match any port index. */ -struct rte_flow_item_port { +struct rte_flow_item_phy_port { uint32_t index; /**< Physical port index. */ }; -/** Default mask for RTE_FLOW_ITEM_TYPE_PORT. */ +/** Default mask for RTE_FLOW_ITEM_TYPE_PHY_PORT. */ #ifndef __cplusplus -static const struct rte_flow_item_port rte_flow_item_port_mask = { +static const struct rte_flow_item_phy_port rte_flow_item_phy_port_mask = { .index = 0x00000000, }; #endif -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v1 15/16] ethdev: add physical port action to flow API 2018-04-04 15:56 [dpdk-dev] [PATCH v1 00/16] Flow API overhaul for switch offloads Adrien Mazarguil ` (13 preceding siblings ...) 2018-04-04 15:56 ` [dpdk-dev] [PATCH v1 14/16] ethdev: rename physical port item " Adrien Mazarguil @ 2018-04-04 15:56 ` Adrien Mazarguil 2018-04-04 15:56 ` [dpdk-dev] [PATCH v1 16/16] ethdev: add port ID item and " Adrien Mazarguil 2018-04-06 13:25 ` [dpdk-dev] [PATCH v2 00/15] Flow API overhaul for switch offloads Adrien Mazarguil 16 siblings, 0 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-04 15:56 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev; +Cc: Zhang, Qi Z This patch adds the missing action counterpart to the PHY_PORT pattern item, that is, the ability to directly inject matching traffic into a physical port of the underlying device. Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Cc: "Zhang, Qi Z" <qi.z.zhang@intel.com> --- app/test-pmd/cmdline_flow.c | 35 ++++++++++++++++++++++++ app/test-pmd/config.c | 1 + doc/guides/prog_guide/rte_flow.rst | 20 ++++++++++++++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 5 ++++ lib/librte_ether/rte_flow.c | 1 + lib/librte_ether/rte_flow.h | 22 +++++++++++++++ 6 files changed, 84 insertions(+) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index bfe532f0a..c77525ad9 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -182,6 +182,9 @@ enum index { ACTION_VF, ACTION_VF_ORIGINAL, ACTION_VF_ID, + ACTION_PHY_PORT, + ACTION_PHY_PORT_ORIGINAL, + ACTION_PHY_PORT_INDEX, ACTION_METER, ACTION_METER_ID, }; @@ -623,6 +626,7 @@ static const enum index next_action[] = { ACTION_RSS, ACTION_PF, ACTION_VF, + ACTION_PHY_PORT, ACTION_METER, ZERO, }; @@ -657,6 +661,13 @@ static const enum index action_vf[] = { ZERO, }; +static const enum index action_phy_port[] = { + ACTION_PHY_PORT_ORIGINAL, + ACTION_PHY_PORT_INDEX, + ACTION_NEXT, + ZERO, +}; + static const enum index action_meter[] = { ACTION_METER_ID, ACTION_NEXT, @@ -1714,6 +1725,30 @@ static const struct token token_list[] = { .args = ARGS(ARGS_ENTRY(struct rte_flow_action_vf, id)), .call = parse_vc_conf, }, + [ACTION_PHY_PORT] = { + .name = "phy_port", + .help = "direct packets to physical port index", + .priv = PRIV_ACTION(PHY_PORT, + sizeof(struct rte_flow_action_phy_port)), + .next = NEXT(action_phy_port), + .call = parse_vc, + }, + [ACTION_PHY_PORT_ORIGINAL] = { + .name = "original", + .help = "use original port index if possible", + .next = NEXT(action_phy_port, NEXT_ENTRY(BOOLEAN)), + .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_phy_port, + original, 1)), + .call = parse_vc_conf, + }, + [ACTION_PHY_PORT_INDEX] = { + .name = "index", + .help = "physical port index", + .next = NEXT(action_phy_port, NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_phy_port, + index)), + .call = parse_vc_conf, + }, [ACTION_METER] = { .name = "meter", .help = "meter the directed packets at given id", diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 9f968919e..effb4ff81 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -1058,6 +1058,7 @@ static const struct { MK_FLOW_ACTION(RSS, sizeof(struct rte_flow_action_rss)), MK_FLOW_ACTION(PF, 0), MK_FLOW_ACTION(VF, sizeof(struct rte_flow_action_vf)), + MK_FLOW_ACTION(PHY_PORT, sizeof(struct rte_flow_action_phy_port)), MK_FLOW_ACTION(METER, sizeof(struct rte_flow_action_meter)), }; diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index aab124d99..941285495 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -1416,6 +1416,26 @@ See `Item: VF`_. | ``id`` | VF ID | +--------------+--------------------------------+ +Action: ``PHY_PORT`` +^^^^^^^^^^^^^^^^^^^^ + +Directs matching traffic to a given physical port index of the underlying +device. + +See `Item: PHY_PORT`_. + +.. _table_rte_flow_action_phy_port: + +.. table:: PHY_PORT + + +--------------+-------------------------------------+ + | Field | Value | + +==============+=====================================+ + | ``original`` | use original port index if possible | + +--------------+-------------------------------------+ + | ``index`` | physical port index | + +--------------+-------------------------------------+ + Action: ``METER`` ^^^^^^^^^^^^^^^^^ diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index 1d9ce6963..ca23ba146 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3421,6 +3421,11 @@ This section lists supported actions and their attributes, if any. - ``original {boolean}``: use original VF ID if possible. - ``id {unsigned}``: VF ID. +- ``phy_port``: direct packets to physical port index. + + - ``original {boolean}``: use original port index if possible. + - ``index {unsigned}``: physical port index. + Destroying flow rules ~~~~~~~~~~~~~~~~~~~~~ diff --git a/lib/librte_ether/rte_flow.c b/lib/librte_ether/rte_flow.c index 6d4d7f5ed..e0fd78dd5 100644 --- a/lib/librte_ether/rte_flow.c +++ b/lib/librte_ether/rte_flow.c @@ -76,6 +76,7 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = { MK_FLOW_ACTION(RSS, sizeof(struct rte_flow_action_rss)), MK_FLOW_ACTION(PF, 0), MK_FLOW_ACTION(VF, sizeof(struct rte_flow_action_vf)), + MK_FLOW_ACTION(PHY_PORT, sizeof(struct rte_flow_action_phy_port)), }; static int diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index 1fcec5a97..49845ec35 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -984,6 +984,14 @@ enum rte_flow_action_type { RTE_FLOW_ACTION_TYPE_VF, /** + * Directs packets to a given physical port index of the underlying + * device. + * + * See struct rte_flow_action_phy_port. + */ + RTE_FLOW_ACTION_TYPE_PHY_PORT, + + /** * Traffic metering and policing (MTR). * * See struct rte_flow_action_meter. @@ -1101,6 +1109,20 @@ struct rte_flow_action_vf { }; /** + * RTE_FLOW_ACTION_TYPE_PHY_PORT + * + * Directs packets to a given physical port index of the underlying + * device. + * + * @see RTE_FLOW_ITEM_TYPE_PHY_PORT + */ +struct rte_flow_action_phy_port { + uint32_t original:1; /**< Use original port index if possible. */ + uint32_t reserved:31; /**< Reserved, must be zero. */ + uint32_t index; /**< Physical port index. */ +}; + +/** * RTE_FLOW_ACTION_TYPE_METER * * Traffic metering and policing (MTR). -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v1 16/16] ethdev: add port ID item and action to flow API 2018-04-04 15:56 [dpdk-dev] [PATCH v1 00/16] Flow API overhaul for switch offloads Adrien Mazarguil ` (14 preceding siblings ...) 2018-04-04 15:56 ` [dpdk-dev] [PATCH v1 15/16] ethdev: add physical port action to " Adrien Mazarguil @ 2018-04-04 15:56 ` Adrien Mazarguil 2018-04-05 12:24 ` Zhang, Qi Z 2018-04-06 13:25 ` [dpdk-dev] [PATCH v2 00/15] Flow API overhaul for switch offloads Adrien Mazarguil 16 siblings, 1 reply; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-04 15:56 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev; +Cc: Zhang, Qi Z, Declan Doherty RTE_FLOW_ACTION_TYPE_PORT_ID brings the ability to inject matching traffic into a different device, as identified by its DPDK port ID. This is normally only supported when the target port ID has some kind of relationship with the port ID the flow rule is created against, such as being exposed by a common physical device (e.g. a different port of an Ethernet switch). The converse pattern item, RTE_FLOW_ITEM_TYPE_PORT_ID, makes the resulting flow rule match traffic whose origin is the specified port ID. Note that specifying a port ID that differs from the one the flow rule is created against is normally meaningless (if even accepted), but can make sense if combined with the transfer attribute. These must not be confused with their PHY_PORT counterparts, which refer to physical ports using device-specific indices, but unlike PORT_ID are not necessarily tied to DPDK port IDs. Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Cc: "Zhang, Qi Z" <qi.z.zhang@intel.com> Cc: Declan Doherty <declan.doherty@intel.com> --- This patch provides the same functionality and supersedes Qi Zhang's "ether: add flow action to redirect packet to a port" [1]. The main differences are: - Action is named PORT_ID instead of PORT. - Addition of a PORT_ID pattern item. - More extensive documentation. - Testpmd support. - rte_flow_copy() support. [1] http://dpdk.org/ml/archives/dev/2018-April/094648.html --- app/test-pmd/cmdline_flow.c | 57 ++++++++++++++++++++++++ app/test-pmd/config.c | 2 + doc/guides/prog_guide/rte_flow.rst | 48 ++++++++++++++++++++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 9 ++++ lib/librte_ether/rte_flow.c | 2 + lib/librte_ether/rte_flow.h | 56 +++++++++++++++++++++++ 6 files changed, 174 insertions(+) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index c77525ad9..f85c1c57f 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -89,6 +89,8 @@ enum index { ITEM_VF_ID, ITEM_PHY_PORT, ITEM_PHY_PORT_INDEX, + ITEM_PORT_ID, + ITEM_PORT_ID_ID, ITEM_RAW, ITEM_RAW_RELATIVE, ITEM_RAW_SEARCH, @@ -185,6 +187,9 @@ enum index { ACTION_PHY_PORT, ACTION_PHY_PORT_ORIGINAL, ACTION_PHY_PORT_INDEX, + ACTION_PORT_ID, + ACTION_PORT_ID_ORIGINAL, + ACTION_PORT_ID_ID, ACTION_METER, ACTION_METER_ID, }; @@ -445,6 +450,7 @@ static const enum index next_item[] = { ITEM_PF, ITEM_VF, ITEM_PHY_PORT, + ITEM_PORT_ID, ITEM_RAW, ITEM_ETH, ITEM_VLAN, @@ -491,6 +497,12 @@ static const enum index item_phy_port[] = { ZERO, }; +static const enum index item_port_id[] = { + ITEM_PORT_ID_ID, + ITEM_NEXT, + ZERO, +}; + static const enum index item_raw[] = { ITEM_RAW_RELATIVE, ITEM_RAW_SEARCH, @@ -627,6 +639,7 @@ static const enum index next_action[] = { ACTION_PF, ACTION_VF, ACTION_PHY_PORT, + ACTION_PORT_ID, ACTION_METER, ZERO, }; @@ -668,6 +681,13 @@ static const enum index action_phy_port[] = { ZERO, }; +static const enum index action_port_id[] = { + ACTION_PORT_ID_ORIGINAL, + ACTION_PORT_ID_ID, + ACTION_NEXT, + ZERO, +}; + static const enum index action_meter[] = { ACTION_METER_ID, ACTION_NEXT, @@ -1084,6 +1104,20 @@ static const struct token token_list[] = { .next = NEXT(item_phy_port, NEXT_ENTRY(UNSIGNED), item_param), .args = ARGS(ARGS_ENTRY(struct rte_flow_item_phy_port, index)), }, + [ITEM_PORT_ID] = { + .name = "port_id", + .help = "match traffic from/to a given DPDK port ID", + .priv = PRIV_ITEM(PORT_ID, + sizeof(struct rte_flow_item_port_id)), + .next = NEXT(item_port_id), + .call = parse_vc, + }, + [ITEM_PORT_ID_ID] = { + .name = "id", + .help = "DPDK port ID", + .next = NEXT(item_port_id, NEXT_ENTRY(UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_port_id, id)), + }, [ITEM_RAW] = { .name = "raw", .help = "match an arbitrary byte string", @@ -1749,6 +1783,29 @@ static const struct token token_list[] = { index)), .call = parse_vc_conf, }, + [ACTION_PORT_ID] = { + .name = "port_id", + .help = "direct matching traffic to a given DPDK port ID", + .priv = PRIV_ACTION(PORT_ID, + sizeof(struct rte_flow_action_port_id)), + .next = NEXT(action_port_id), + .call = parse_vc, + }, + [ACTION_PORT_ID_ORIGINAL] = { + .name = "original", + .help = "use original DPDK port ID if possible", + .next = NEXT(action_port_id, NEXT_ENTRY(BOOLEAN)), + .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_port_id, + original, 1)), + .call = parse_vc_conf, + }, + [ACTION_PORT_ID_ID] = { + .name = "id", + .help = "DPDK port ID", + .next = NEXT(action_port_id, NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_port_id, id)), + .call = parse_vc_conf, + }, [ACTION_METER] = { .name = "meter", .help = "meter the directed packets at given id", diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index effb4ff81..4a273eff7 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -961,6 +961,7 @@ static const struct { MK_FLOW_ITEM(PF, 0), MK_FLOW_ITEM(VF, sizeof(struct rte_flow_item_vf)), MK_FLOW_ITEM(PHY_PORT, sizeof(struct rte_flow_item_phy_port)), + MK_FLOW_ITEM(PORT_ID, sizeof(struct rte_flow_item_port_id)), MK_FLOW_ITEM(RAW, sizeof(struct rte_flow_item_raw)), MK_FLOW_ITEM(ETH, sizeof(struct rte_flow_item_eth)), MK_FLOW_ITEM(VLAN, sizeof(struct rte_flow_item_vlan)), @@ -1059,6 +1060,7 @@ static const struct { MK_FLOW_ACTION(PF, 0), MK_FLOW_ACTION(VF, sizeof(struct rte_flow_action_vf)), MK_FLOW_ACTION(PHY_PORT, sizeof(struct rte_flow_action_phy_port)), + MK_FLOW_ACTION(PORT_ID, sizeof(struct rte_flow_action_port_id)), MK_FLOW_ACTION(METER, sizeof(struct rte_flow_action_meter)), }; diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 941285495..a94b84fb5 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -607,6 +607,36 @@ associated with a port_id should be retrieved by other means. | ``mask`` | ``index`` | zeroed to match any port index | +----------+-----------+--------------------------------+ +Item: ``PORT_ID`` +^^^^^^^^^^^^^^^^^ + +Matches traffic originating from (ingress) or going to (egress) a given DPDK +port ID. + +Normally only supported if the port ID in question is known by the +underlying PMD and related to the device the flow rule is created against. + +This must not be confused with `Item: PHY_PORT`_ which refers to the +physical port of a device, whereas `Item: PORT_ID`_ refers to a ``struct +rte_eth_dev`` object on the application side (also known as "port +representor" depending on the kind of underlying device). + +- Default ``mask`` matches the specified DPDK port ID. + +.. _table_rte_flow_item_phy_port: + +.. table:: PORT_ID + + +----------+----------+-----------------------------+ + | Field | Subfield | Value | + +==========+==========+=============================+ + | ``spec`` | ``id`` | DPDK port ID | + +----------+----------+-----------------------------+ + | ``last`` | ``id`` | upper range value | + +----------+----------+-----------------------------+ + | ``mask`` | ``id`` | zeroed to match any port ID | + +----------+----------+-----------------------------+ + Data matching item types ~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1436,6 +1466,24 @@ See `Item: PHY_PORT`_. | ``index`` | physical port index | +--------------+-------------------------------------+ +Action: ``PORT_ID`` +^^^^^^^^^^^^^^^^^^^ +Directs matching traffic to a given DPDK port ID. + +See `Item: PORT_ID`_. + +.. _table_rte_flow_action_phy_port: + +.. table:: PORT_ID + + +--------------+---------------------------------------+ + | Field | Value | + +==============+=======================================+ + | ``original`` | use original DPDK port ID if possible | + +--------------+---------------------------------------+ + | ``id`` | DPDK port ID | + +--------------+---------------------------------------+ + Action: ``METER`` ^^^^^^^^^^^^^^^^^ diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index ca23ba146..e78f26dce 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3212,6 +3212,10 @@ This section lists supported pattern items and their attributes, if any. - ``index {unsigned}``: physical port index. +- ``port_id``: match traffic from/to a given DPDK port ID. + + - ``id {unsigned}``: DPDK port ID. + - ``raw``: match an arbitrary byte string. - ``relative {boolean}``: look for pattern after the previous item. @@ -3426,6 +3430,11 @@ This section lists supported actions and their attributes, if any. - ``original {boolean}``: use original port index if possible. - ``index {unsigned}``: physical port index. +- ``port_id``: direct matching traffic to a given DPDK port ID. + + - ``original {boolean}``: use original DPDK port ID if possible. + - ``id {unsigned}``: DPDK port ID. + Destroying flow rules ~~~~~~~~~~~~~~~~~~~~~ diff --git a/lib/librte_ether/rte_flow.c b/lib/librte_ether/rte_flow.c index e0fd78dd5..3d8116ebd 100644 --- a/lib/librte_ether/rte_flow.c +++ b/lib/librte_ether/rte_flow.c @@ -39,6 +39,7 @@ static const struct rte_flow_desc_data rte_flow_desc_item[] = { MK_FLOW_ITEM(PF, 0), MK_FLOW_ITEM(VF, sizeof(struct rte_flow_item_vf)), MK_FLOW_ITEM(PHY_PORT, sizeof(struct rte_flow_item_phy_port)), + MK_FLOW_ITEM(PORT_ID, sizeof(struct rte_flow_item_port_id)), MK_FLOW_ITEM(RAW, sizeof(struct rte_flow_item_raw)), MK_FLOW_ITEM(ETH, sizeof(struct rte_flow_item_eth)), MK_FLOW_ITEM(VLAN, sizeof(struct rte_flow_item_vlan)), @@ -77,6 +78,7 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = { MK_FLOW_ACTION(PF, 0), MK_FLOW_ACTION(VF, sizeof(struct rte_flow_action_vf)), MK_FLOW_ACTION(PHY_PORT, sizeof(struct rte_flow_action_phy_port)), + MK_FLOW_ACTION(PORT_ID, sizeof(struct rte_flow_action_port_id)), }; static int diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index 49845ec35..af9bf3f25 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -176,6 +176,16 @@ enum rte_flow_item_type { RTE_FLOW_ITEM_TYPE_PHY_PORT, /** + * [META] + * + * Matches traffic originating from (ingress) or going to (egress) a + * given DPDK port ID. + * + * See struct rte_flow_item_port_id. + */ + RTE_FLOW_ITEM_TYPE_PORT_ID, + + /** * Matches a byte string of a given length at a given offset. * * See struct rte_flow_item_raw. @@ -410,6 +420,32 @@ static const struct rte_flow_item_phy_port rte_flow_item_phy_port_mask = { #endif /** + * RTE_FLOW_ITEM_TYPE_PORT_ID + * + * Matches traffic originating from (ingress) or going to (egress) a given + * DPDK port ID. + * + * Normally only supported if the port ID in question is known by the + * underlying PMD and related to the device the flow rule is created + * against. + * + * This must not be confused with @p PHY_PORT which refers to the physical + * port of a device, whereas @p PORT_ID refers to a struct rte_eth_dev + * object on the application side (also known as "port representor" + * depending on the kind of underlying device). + */ +struct rte_flow_item_port_id { + uint32_t id; /**< DPDK port ID. */ +}; + +/** Default mask for RTE_FLOW_ITEM_TYPE_PORT_ID. */ +#ifndef __cplusplus +static const struct rte_flow_item_port_id rte_flow_item_port_id_mask = { + .id = 0xffffffff, +}; +#endif + +/** * RTE_FLOW_ITEM_TYPE_RAW * * Matches a byte string of a given length at a given offset. @@ -992,6 +1028,13 @@ enum rte_flow_action_type { RTE_FLOW_ACTION_TYPE_PHY_PORT, /** + * Directs matching traffic to a given DPDK port ID. + * + * See struct rte_flow_action_port_id. + */ + RTE_FLOW_ACTION_TYPE_PORT_ID, + + /** * Traffic metering and policing (MTR). * * See struct rte_flow_action_meter. @@ -1123,6 +1166,19 @@ struct rte_flow_action_phy_port { }; /** + * RTE_FLOW_ACTION_TYPE_PORT_ID + * + * Directs matching traffic to a given DPDK port ID. + * + * @see RTE_FLOW_ITEM_TYPE_PORT_ID + */ +struct rte_flow_action_port_id { + uint32_t original:1; /**< Use original DPDK port ID if possible. */ + uint32_t reserved:31; /**< Reserved, must be zero. */ + uint32_t id; /**< DPDK port ID. */ +}; + +/** * RTE_FLOW_ACTION_TYPE_METER * * Traffic metering and policing (MTR). -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [dpdk-dev] [PATCH v1 16/16] ethdev: add port ID item and action to flow API 2018-04-04 15:56 ` [dpdk-dev] [PATCH v1 16/16] ethdev: add port ID item and " Adrien Mazarguil @ 2018-04-05 12:24 ` Zhang, Qi Z 0 siblings, 0 replies; 157+ messages in thread From: Zhang, Qi Z @ 2018-04-05 12:24 UTC (permalink / raw) To: Adrien Mazarguil, Thomas Monjalon, Yigit, Ferruh, dev; +Cc: Doherty, Declan > -----Original Message----- > From: Adrien Mazarguil [mailto:adrien.mazarguil@6wind.com] > Sent: Wednesday, April 4, 2018 11:57 PM > To: Thomas Monjalon <thomas@monjalon.net>; Yigit, Ferruh > <ferruh.yigit@intel.com>; dev@dpdk.org > Cc: Zhang, Qi Z <qi.z.zhang@intel.com>; Doherty, Declan > <declan.doherty@intel.com> > Subject: [PATCH v1 16/16] ethdev: add port ID item and action to flow API > > RTE_FLOW_ACTION_TYPE_PORT_ID brings the ability to inject matching traffic > into a different device, as identified by its DPDK port ID. > > This is normally only supported when the target port ID has some kind of > relationship with the port ID the flow rule is created against, such as being > exposed by a common physical device (e.g. a different port of an Ethernet > switch). > > The converse pattern item, RTE_FLOW_ITEM_TYPE_PORT_ID, makes the > resulting flow rule match traffic whose origin is the specified port ID. Note that > specifying a port ID that differs from the one the flow rule is created against is > normally meaningless (if even accepted), but can make sense if combined with > the transfer attribute. > > These must not be confused with their PHY_PORT counterparts, which refer to > physical ports using device-specific indices, but unlike PORT_ID are not > necessarily tied to DPDK port IDs. > > Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> > Cc: "Zhang, Qi Z" <qi.z.zhang@intel.com> > Cc: Declan Doherty <declan.doherty@intel.com> Reviewed-by: Qi Zhang <qi.z.zhang@intel.com> This patch cover http://dpdk.org/dev/patchwork/patch/36839/ > > --- > > This patch provides the same functionality and supersedes Qi Zhang's > "ether: add flow action to redirect packet to a port" [1]. > > The main differences are: > > - Action is named PORT_ID instead of PORT. > - Addition of a PORT_ID pattern item. > - More extensive documentation. > - Testpmd support. > - rte_flow_copy() support. > > [1] http://dpdk.org/ml/archives/dev/2018-April/094648.html > --- > app/test-pmd/cmdline_flow.c | 57 > ++++++++++++++++++++++++ > app/test-pmd/config.c | 2 + > doc/guides/prog_guide/rte_flow.rst | 48 ++++++++++++++++++++ > doc/guides/testpmd_app_ug/testpmd_funcs.rst | 9 ++++ > lib/librte_ether/rte_flow.c | 2 + > lib/librte_ether/rte_flow.h | 56 > +++++++++++++++++++++++ > 6 files changed, 174 insertions(+) > > diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c > index c77525ad9..f85c1c57f 100644 > --- a/app/test-pmd/cmdline_flow.c > +++ b/app/test-pmd/cmdline_flow.c > @@ -89,6 +89,8 @@ enum index { > ITEM_VF_ID, > ITEM_PHY_PORT, > ITEM_PHY_PORT_INDEX, > + ITEM_PORT_ID, > + ITEM_PORT_ID_ID, > ITEM_RAW, > ITEM_RAW_RELATIVE, > ITEM_RAW_SEARCH, > @@ -185,6 +187,9 @@ enum index { > ACTION_PHY_PORT, > ACTION_PHY_PORT_ORIGINAL, > ACTION_PHY_PORT_INDEX, > + ACTION_PORT_ID, > + ACTION_PORT_ID_ORIGINAL, > + ACTION_PORT_ID_ID, > ACTION_METER, > ACTION_METER_ID, > }; > @@ -445,6 +450,7 @@ static const enum index next_item[] = { > ITEM_PF, > ITEM_VF, > ITEM_PHY_PORT, > + ITEM_PORT_ID, > ITEM_RAW, > ITEM_ETH, > ITEM_VLAN, > @@ -491,6 +497,12 @@ static const enum index item_phy_port[] = { > ZERO, > }; > > +static const enum index item_port_id[] = { > + ITEM_PORT_ID_ID, > + ITEM_NEXT, > + ZERO, > +}; > + > static const enum index item_raw[] = { > ITEM_RAW_RELATIVE, > ITEM_RAW_SEARCH, > @@ -627,6 +639,7 @@ static const enum index next_action[] = { > ACTION_PF, > ACTION_VF, > ACTION_PHY_PORT, > + ACTION_PORT_ID, > ACTION_METER, > ZERO, > }; > @@ -668,6 +681,13 @@ static const enum index action_phy_port[] = { > ZERO, > }; > > +static const enum index action_port_id[] = { > + ACTION_PORT_ID_ORIGINAL, > + ACTION_PORT_ID_ID, > + ACTION_NEXT, > + ZERO, > +}; > + > static const enum index action_meter[] = { > ACTION_METER_ID, > ACTION_NEXT, > @@ -1084,6 +1104,20 @@ static const struct token token_list[] = { > .next = NEXT(item_phy_port, NEXT_ENTRY(UNSIGNED), > item_param), > .args = ARGS(ARGS_ENTRY(struct rte_flow_item_phy_port, index)), > }, > + [ITEM_PORT_ID] = { > + .name = "port_id", > + .help = "match traffic from/to a given DPDK port ID", > + .priv = PRIV_ITEM(PORT_ID, > + sizeof(struct rte_flow_item_port_id)), > + .next = NEXT(item_port_id), > + .call = parse_vc, > + }, > + [ITEM_PORT_ID_ID] = { > + .name = "id", > + .help = "DPDK port ID", > + .next = NEXT(item_port_id, NEXT_ENTRY(UNSIGNED), item_param), > + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_port_id, id)), > + }, > [ITEM_RAW] = { > .name = "raw", > .help = "match an arbitrary byte string", @@ -1749,6 +1783,29 @@ > static const struct token token_list[] = { > index)), > .call = parse_vc_conf, > }, > + [ACTION_PORT_ID] = { > + .name = "port_id", > + .help = "direct matching traffic to a given DPDK port ID", > + .priv = PRIV_ACTION(PORT_ID, > + sizeof(struct rte_flow_action_port_id)), > + .next = NEXT(action_port_id), > + .call = parse_vc, > + }, > + [ACTION_PORT_ID_ORIGINAL] = { > + .name = "original", > + .help = "use original DPDK port ID if possible", > + .next = NEXT(action_port_id, NEXT_ENTRY(BOOLEAN)), > + .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_port_id, > + original, 1)), > + .call = parse_vc_conf, > + }, > + [ACTION_PORT_ID_ID] = { > + .name = "id", > + .help = "DPDK port ID", > + .next = NEXT(action_port_id, NEXT_ENTRY(UNSIGNED)), > + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_port_id, id)), > + .call = parse_vc_conf, > + }, > [ACTION_METER] = { > .name = "meter", > .help = "meter the directed packets at given id", diff --git > a/app/test-pmd/config.c b/app/test-pmd/config.c index effb4ff81..4a273eff7 > 100644 > --- a/app/test-pmd/config.c > +++ b/app/test-pmd/config.c > @@ -961,6 +961,7 @@ static const struct { > MK_FLOW_ITEM(PF, 0), > MK_FLOW_ITEM(VF, sizeof(struct rte_flow_item_vf)), > MK_FLOW_ITEM(PHY_PORT, sizeof(struct rte_flow_item_phy_port)), > + MK_FLOW_ITEM(PORT_ID, sizeof(struct rte_flow_item_port_id)), > MK_FLOW_ITEM(RAW, sizeof(struct rte_flow_item_raw)), > MK_FLOW_ITEM(ETH, sizeof(struct rte_flow_item_eth)), > MK_FLOW_ITEM(VLAN, sizeof(struct rte_flow_item_vlan)), @@ -1059,6 > +1060,7 @@ static const struct { > MK_FLOW_ACTION(PF, 0), > MK_FLOW_ACTION(VF, sizeof(struct rte_flow_action_vf)), > MK_FLOW_ACTION(PHY_PORT, sizeof(struct rte_flow_action_phy_port)), > + MK_FLOW_ACTION(PORT_ID, sizeof(struct rte_flow_action_port_id)), > MK_FLOW_ACTION(METER, sizeof(struct rte_flow_action_meter)), }; > > diff --git a/doc/guides/prog_guide/rte_flow.rst > b/doc/guides/prog_guide/rte_flow.rst > index 941285495..a94b84fb5 100644 > --- a/doc/guides/prog_guide/rte_flow.rst > +++ b/doc/guides/prog_guide/rte_flow.rst > @@ -607,6 +607,36 @@ associated with a port_id should be retrieved by > other means. > | ``mask`` | ``index`` | zeroed to match any port index | > +----------+-----------+--------------------------------+ > > +Item: ``PORT_ID`` > +^^^^^^^^^^^^^^^^^ > + > +Matches traffic originating from (ingress) or going to (egress) a given > +DPDK port ID. > + > +Normally only supported if the port ID in question is known by the > +underlying PMD and related to the device the flow rule is created against. > + > +This must not be confused with `Item: PHY_PORT`_ which refers to the > +physical port of a device, whereas `Item: PORT_ID`_ refers to a > +``struct rte_eth_dev`` object on the application side (also known as > +"port representor" depending on the kind of underlying device). > + > +- Default ``mask`` matches the specified DPDK port ID. > + > +.. _table_rte_flow_item_phy_port: > + > +.. table:: PORT_ID > + > + +----------+----------+-----------------------------+ > + | Field | Subfield | Value | > + +==========+==========+=============================+ > + | ``spec`` | ``id`` | DPDK port ID | > + +----------+----------+-----------------------------+ > + | ``last`` | ``id`` | upper range value | > + +----------+----------+-----------------------------+ > + | ``mask`` | ``id`` | zeroed to match any port ID | > + +----------+----------+-----------------------------+ > + > Data matching item types > ~~~~~~~~~~~~~~~~~~~~~~~~ > > @@ -1436,6 +1466,24 @@ See `Item: PHY_PORT`_. > | ``index`` | physical port index | > +--------------+-------------------------------------+ > > +Action: ``PORT_ID`` > +^^^^^^^^^^^^^^^^^^^ > +Directs matching traffic to a given DPDK port ID. > + > +See `Item: PORT_ID`_. > + > +.. _table_rte_flow_action_phy_port: > + > +.. table:: PORT_ID > + > + +--------------+---------------------------------------+ > + | Field | Value | > + +==============+=======================================+ > + | ``original`` | use original DPDK port ID if possible | > + +--------------+---------------------------------------+ > + | ``id`` | DPDK port ID | > + +--------------+---------------------------------------+ > + > Action: ``METER`` > ^^^^^^^^^^^^^^^^^ > > diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst > b/doc/guides/testpmd_app_ug/testpmd_funcs.rst > index ca23ba146..e78f26dce 100644 > --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst > +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst > @@ -3212,6 +3212,10 @@ This section lists supported pattern items and their > attributes, if any. > > - ``index {unsigned}``: physical port index. > > +- ``port_id``: match traffic from/to a given DPDK port ID. > + > + - ``id {unsigned}``: DPDK port ID. > + > - ``raw``: match an arbitrary byte string. > > - ``relative {boolean}``: look for pattern after the previous item. > @@ -3426,6 +3430,11 @@ This section lists supported actions and their > attributes, if any. > - ``original {boolean}``: use original port index if possible. > - ``index {unsigned}``: physical port index. > > +- ``port_id``: direct matching traffic to a given DPDK port ID. > + > + - ``original {boolean}``: use original DPDK port ID if possible. > + - ``id {unsigned}``: DPDK port ID. > + > Destroying flow rules > ~~~~~~~~~~~~~~~~~~~~~ > > diff --git a/lib/librte_ether/rte_flow.c b/lib/librte_ether/rte_flow.c index > e0fd78dd5..3d8116ebd 100644 > --- a/lib/librte_ether/rte_flow.c > +++ b/lib/librte_ether/rte_flow.c > @@ -39,6 +39,7 @@ static const struct rte_flow_desc_data > rte_flow_desc_item[] = { > MK_FLOW_ITEM(PF, 0), > MK_FLOW_ITEM(VF, sizeof(struct rte_flow_item_vf)), > MK_FLOW_ITEM(PHY_PORT, sizeof(struct rte_flow_item_phy_port)), > + MK_FLOW_ITEM(PORT_ID, sizeof(struct rte_flow_item_port_id)), > MK_FLOW_ITEM(RAW, sizeof(struct rte_flow_item_raw)), > MK_FLOW_ITEM(ETH, sizeof(struct rte_flow_item_eth)), > MK_FLOW_ITEM(VLAN, sizeof(struct rte_flow_item_vlan)), @@ -77,6 > +78,7 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = { > MK_FLOW_ACTION(PF, 0), > MK_FLOW_ACTION(VF, sizeof(struct rte_flow_action_vf)), > MK_FLOW_ACTION(PHY_PORT, sizeof(struct rte_flow_action_phy_port)), > + MK_FLOW_ACTION(PORT_ID, sizeof(struct rte_flow_action_port_id)), > }; > > static int > diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index > 49845ec35..af9bf3f25 100644 > --- a/lib/librte_ether/rte_flow.h > +++ b/lib/librte_ether/rte_flow.h > @@ -176,6 +176,16 @@ enum rte_flow_item_type { > RTE_FLOW_ITEM_TYPE_PHY_PORT, > > /** > + * [META] > + * > + * Matches traffic originating from (ingress) or going to (egress) a > + * given DPDK port ID. > + * > + * See struct rte_flow_item_port_id. > + */ > + RTE_FLOW_ITEM_TYPE_PORT_ID, > + > + /** > * Matches a byte string of a given length at a given offset. > * > * See struct rte_flow_item_raw. > @@ -410,6 +420,32 @@ static const struct rte_flow_item_phy_port > rte_flow_item_phy_port_mask = { #endif > > /** > + * RTE_FLOW_ITEM_TYPE_PORT_ID > + * > + * Matches traffic originating from (ingress) or going to (egress) a > +given > + * DPDK port ID. > + * > + * Normally only supported if the port ID in question is known by the > + * underlying PMD and related to the device the flow rule is created > + * against. > + * > + * This must not be confused with @p PHY_PORT which refers to the > +physical > + * port of a device, whereas @p PORT_ID refers to a struct rte_eth_dev > + * object on the application side (also known as "port representor" > + * depending on the kind of underlying device). > + */ > +struct rte_flow_item_port_id { > + uint32_t id; /**< DPDK port ID. */ > +}; > + > +/** Default mask for RTE_FLOW_ITEM_TYPE_PORT_ID. */ #ifndef __cplusplus > +static const struct rte_flow_item_port_id rte_flow_item_port_id_mask = { > + .id = 0xffffffff, > +}; > +#endif > + > +/** > * RTE_FLOW_ITEM_TYPE_RAW > * > * Matches a byte string of a given length at a given offset. > @@ -992,6 +1028,13 @@ enum rte_flow_action_type { > RTE_FLOW_ACTION_TYPE_PHY_PORT, > > /** > + * Directs matching traffic to a given DPDK port ID. > + * > + * See struct rte_flow_action_port_id. > + */ > + RTE_FLOW_ACTION_TYPE_PORT_ID, > + > + /** > * Traffic metering and policing (MTR). > * > * See struct rte_flow_action_meter. > @@ -1123,6 +1166,19 @@ struct rte_flow_action_phy_port { }; > > /** > + * RTE_FLOW_ACTION_TYPE_PORT_ID > + * > + * Directs matching traffic to a given DPDK port ID. > + * > + * @see RTE_FLOW_ITEM_TYPE_PORT_ID > + */ > +struct rte_flow_action_port_id { > + uint32_t original:1; /**< Use original DPDK port ID if possible. */ > + uint32_t reserved:31; /**< Reserved, must be zero. */ > + uint32_t id; /**< DPDK port ID. */ > +}; > + > +/** > * RTE_FLOW_ACTION_TYPE_METER > * > * Traffic metering and policing (MTR). > -- > 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v2 00/15] Flow API overhaul for switch offloads 2018-04-04 15:56 [dpdk-dev] [PATCH v1 00/16] Flow API overhaul for switch offloads Adrien Mazarguil ` (15 preceding siblings ...) 2018-04-04 15:56 ` [dpdk-dev] [PATCH v1 16/16] ethdev: add port ID item and " Adrien Mazarguil @ 2018-04-06 13:25 ` Adrien Mazarguil 2018-04-06 13:25 ` [dpdk-dev] [PATCH v2 01/15] ethdev: add error types to flow API Adrien Mazarguil ` (15 more replies) 16 siblings, 16 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-06 13:25 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev As summarized in a prior RFC [1], the flow API (rte_flow) was chosen as a means to manage switch offloads supported by many devices (usually going by names such as E-Switch or vSwitch) through user-specified flow rules. Combined with the need to support encap/decap actions, this requires a change in the way flow actions are processed (in order and possibly repeated) which modifies the behavior of some of the existing actions, thus warranting a major ABI breakage. Given this ABI breakage is also required by other work submitted for the current release [2][3], this series addresses various longstanding issues with the flow API and makes minor improvements in preparation for upcoming features. Changes summary: - Additional error types. - Clearer documentation. - Improved C++ compatibility. - Exhaustive RSS action. - Consistent behavior of VLAN pattern item. - New "transfer" attribute bringing consistency to VF/PF pattern items. - Confusing "PORT" pattern item renamed "PHY_PORT", with new action counterpart. - New "PORT_ID" pattern item and action to be used with port representors. This series piggybacks on the major ABI update introduced by a prior commit [4] for DPDK 18.05 and depends on several fixes [5] which must be applied first. [1] "[RFC] Switch device offload with DPDK" http://dpdk.org/ml/archives/dev/2018-March/092513.html [2] commit 676b605182a5 ("doc: announce ethdev API change for RSS configuration") [3] "[PATCH v1 00/21] MLX5 tunnel Rx offloading" http://dpdk.org/ml/archives/dev/2018-March/092264.html [4] commit 653e038efc9b ("ethdev: remove versioning of filter control function") [5] "[PATCH v3 00/11] Bunch of flow API-related fixes" http://dpdk.org/ml/archives/dev/2018-April/095762.html v2 changes: - Squashed "ethdev: update ABI for flow API functions" in subsequent patches. - Emphasized ABI impact in relevant commit logs. - Modified documentation in "ethdev: alter behavior of flow API actions" to describe how terminating flow rules without any action of the fate kind result in undefined behavior instead of dropping traffic. - Fixed other minor documentation formatting issues. - Modified "ethdev: refine TPID handling in flow API" as follows: - Using standard macro definitions for VLAN, QinQ and E-Tag EtherTypes. - Fixed endian conversion in sfc. - Replaced a condition in VLAN pattern item processing with an assertion check for i40e. Adrien Mazarguil (15): ethdev: add error types to flow API ethdev: clarify flow API pattern items and actions doc: remove flow API migration section ethdev: remove DUP action from flow API ethdev: alter behavior of flow API actions ethdev: remove C99 flexible arrays from flow API ethdev: flatten RSS configuration in flow API ethdev: add hash function to RSS flow API action ethdev: add encap level to RSS flow API action ethdev: refine TPID handling in flow API ethdev: add transfer attribute to flow API ethdev: update behavior of VF/PF in flow API ethdev: rename physical port item in flow API ethdev: add physical port action to flow API ethdev: add port ID item and action to flow API app/test-pmd/cmdline_flow.c | 405 ++++++++++----- app/test-pmd/config.c | 78 +-- doc/guides/nics/tap.rst | 2 +- doc/guides/prog_guide/rte_flow.rst | 602 ++++++++--------------- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 54 +- drivers/net/bnxt/bnxt_filter.c | 53 +- drivers/net/e1000/e1000_ethdev.h | 13 +- drivers/net/e1000/igb_ethdev.c | 4 +- drivers/net/e1000/igb_flow.c | 83 +++- drivers/net/e1000/igb_rxtx.c | 55 ++- drivers/net/enic/enic_flow.c | 53 +- drivers/net/i40e/i40e_ethdev.c | 57 ++- drivers/net/i40e/i40e_ethdev.h | 15 +- drivers/net/i40e/i40e_flow.c | 139 ++++-- drivers/net/ixgbe/ixgbe_ethdev.c | 7 +- drivers/net/ixgbe/ixgbe_ethdev.h | 13 +- drivers/net/ixgbe/ixgbe_flow.c | 91 +++- drivers/net/ixgbe/ixgbe_rxtx.c | 55 ++- drivers/net/mlx4/mlx4.c | 2 +- drivers/net/mlx4/mlx4_flow.c | 117 +++-- drivers/net/mlx4/mlx4_flow.h | 2 +- drivers/net/mlx4/mlx4_rxq.c | 2 +- drivers/net/mlx4/mlx4_rxtx.h | 2 +- drivers/net/mlx5/mlx5_flow.c | 319 ++++++------ drivers/net/mlx5/mlx5_rxq.c | 22 +- drivers/net/mlx5/mlx5_rxtx.h | 26 +- drivers/net/mvpp2/mrvl_flow.c | 33 +- drivers/net/sfc/sfc_flow.c | 83 +++- drivers/net/tap/tap_flow.c | 51 +- examples/ipsec-secgw/ipsec.c | 21 +- lib/librte_ether/rte_ethdev_version.map | 22 +- lib/librte_ether/rte_flow.c | 68 +-- lib/librte_ether/rte_flow.h | 329 ++++++++----- lib/librte_net/rte_ether.h | 1 + 34 files changed, 1755 insertions(+), 1124 deletions(-) -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v2 01/15] ethdev: add error types to flow API 2018-04-06 13:25 ` [dpdk-dev] [PATCH v2 00/15] Flow API overhaul for switch offloads Adrien Mazarguil @ 2018-04-06 13:25 ` Adrien Mazarguil 2018-04-07 9:15 ` Andrew Rybchenko 2018-04-06 13:25 ` [dpdk-dev] [PATCH v2 02/15] ethdev: clarify flow API pattern items and actions Adrien Mazarguil ` (14 subsequent siblings) 15 siblings, 1 reply; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-06 13:25 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev These enable more precise reporting of objects responsible for errors. This breaks ABI compatibility for the following public functions: - rte_flow_create() - rte_flow_destroy() - rte_flow_error_set() - rte_flow_flush() - rte_flow_isolate() - rte_flow_query() - rte_flow_validate() Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> --- app/test-pmd/config.c | 4 ++++ lib/librte_ether/rte_ethdev_version.map | 20 +++++++++++++------- lib/librte_ether/rte_flow.h | 4 ++++ 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 2058e6ec8..7ae0295f6 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -1228,8 +1228,12 @@ port_flow_complain(struct rte_flow_error *error) [RTE_FLOW_ERROR_TYPE_ATTR_EGRESS] = "egress field", [RTE_FLOW_ERROR_TYPE_ATTR] = "attributes structure", [RTE_FLOW_ERROR_TYPE_ITEM_NUM] = "pattern length", + [RTE_FLOW_ERROR_TYPE_ITEM_SPEC] = "item specification", + [RTE_FLOW_ERROR_TYPE_ITEM_LAST] = "item specification range", + [RTE_FLOW_ERROR_TYPE_ITEM_MASK] = "item specification mask", [RTE_FLOW_ERROR_TYPE_ITEM] = "specific pattern item", [RTE_FLOW_ERROR_TYPE_ACTION_NUM] = "number of actions", + [RTE_FLOW_ERROR_TYPE_ACTION_CONF] = "action configuration", [RTE_FLOW_ERROR_TYPE_ACTION] = "specific action", }; const char *errstr; diff --git a/lib/librte_ether/rte_ethdev_version.map b/lib/librte_ether/rte_ethdev_version.map index 34df6c8b5..e915e7929 100644 --- a/lib/librte_ether/rte_ethdev_version.map +++ b/lib/librte_ether/rte_ethdev_version.map @@ -127,11 +127,6 @@ DPDK_17.02 { _rte_eth_dev_reset; rte_eth_dev_fw_version_get; - rte_flow_create; - rte_flow_destroy; - rte_flow_flush; - rte_flow_query; - rte_flow_validate; } DPDK_16.07; @@ -153,7 +148,6 @@ DPDK_17.08 { _rte_eth_dev_callback_process; rte_eth_dev_adjust_nb_rx_tx_desc; rte_flow_copy; - rte_flow_isolate; rte_tm_capabilities_get; rte_tm_hierarchy_commit; rte_tm_level_capabilities_get; @@ -192,7 +186,6 @@ DPDK_17.11 { rte_eth_dev_get_sec_ctx; rte_eth_dev_pool_ops_supported; rte_eth_dev_reset; - rte_flow_error_set; } DPDK_17.08; @@ -203,6 +196,19 @@ DPDK_18.02 { } DPDK_17.11; +DPDK_18.05 { + global: + + rte_flow_create; + rte_flow_destroy; + rte_flow_error_set; + rte_flow_flush; + rte_flow_isolate; + rte_flow_query; + rte_flow_validate; + +} DPDK_18.02; + EXPERIMENTAL { global: diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index cdaaa3a5b..95799fd9c 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -1186,8 +1186,12 @@ enum rte_flow_error_type { RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, /**< Egress field. */ RTE_FLOW_ERROR_TYPE_ATTR, /**< Attributes structure. */ RTE_FLOW_ERROR_TYPE_ITEM_NUM, /**< Pattern length. */ + RTE_FLOW_ERROR_TYPE_ITEM_SPEC, /**< Item specification. */ + RTE_FLOW_ERROR_TYPE_ITEM_LAST, /**< Item specification range. */ + RTE_FLOW_ERROR_TYPE_ITEM_MASK, /**< Item specification mask. */ RTE_FLOW_ERROR_TYPE_ITEM, /**< Specific pattern item. */ RTE_FLOW_ERROR_TYPE_ACTION_NUM, /**< Number of actions. */ + RTE_FLOW_ERROR_TYPE_ACTION_CONF, /**< Action configuration. */ RTE_FLOW_ERROR_TYPE_ACTION, /**< Specific action. */ }; -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [dpdk-dev] [PATCH v2 01/15] ethdev: add error types to flow API 2018-04-06 13:25 ` [dpdk-dev] [PATCH v2 01/15] ethdev: add error types to flow API Adrien Mazarguil @ 2018-04-07 9:15 ` Andrew Rybchenko 2018-04-07 9:18 ` Andrew Rybchenko 0 siblings, 1 reply; 157+ messages in thread From: Andrew Rybchenko @ 2018-04-07 9:15 UTC (permalink / raw) To: Adrien Mazarguil, Thomas Monjalon, Ferruh Yigit, dev On 04/06/2018 04:25 PM, Adrien Mazarguil wrote: > These enable more precise reporting of objects responsible for errors. > > This breaks ABI compatibility for the following public functions: > > - rte_flow_create() > - rte_flow_destroy() > - rte_flow_error_set() > - rte_flow_flush() > - rte_flow_isolate() > - rte_flow_query() > - rte_flow_validate() > > Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> > --- > app/test-pmd/config.c | 4 ++++ > lib/librte_ether/rte_ethdev_version.map | 20 +++++++++++++------- > lib/librte_ether/rte_flow.h | 4 ++++ > 3 files changed, 21 insertions(+), 7 deletions(-) I think PMD maintainers with flow API support should be additionally notified and encouraged to refine error reporting. ^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [dpdk-dev] [PATCH v2 01/15] ethdev: add error types to flow API 2018-04-07 9:15 ` Andrew Rybchenko @ 2018-04-07 9:18 ` Andrew Rybchenko 0 siblings, 0 replies; 157+ messages in thread From: Andrew Rybchenko @ 2018-04-07 9:18 UTC (permalink / raw) To: Adrien Mazarguil, Thomas Monjalon, Ferruh Yigit, dev On 04/07/2018 12:15 PM, Andrew Rybchenko wrote: > On 04/06/2018 04:25 PM, Adrien Mazarguil wrote: >> These enable more precise reporting of objects responsible for errors. >> >> This breaks ABI compatibility for the following public functions: >> >> - rte_flow_create() >> - rte_flow_destroy() >> - rte_flow_error_set() >> - rte_flow_flush() >> - rte_flow_isolate() >> - rte_flow_query() >> - rte_flow_validate() >> >> Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> >> --- >> app/test-pmd/config.c | 4 ++++ >> lib/librte_ether/rte_ethdev_version.map | 20 +++++++++++++------- >> lib/librte_ether/rte_flow.h | 4 ++++ >> 3 files changed, 21 insertions(+), 7 deletions(-) > > I think PMD maintainers with flow API support should be additionally > notified and encouraged to refine error reporting. Acked-by: Andrew Rybchenko <arybchenko@solarflare.com> ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v2 02/15] ethdev: clarify flow API pattern items and actions 2018-04-06 13:25 ` [dpdk-dev] [PATCH v2 00/15] Flow API overhaul for switch offloads Adrien Mazarguil 2018-04-06 13:25 ` [dpdk-dev] [PATCH v2 01/15] ethdev: add error types to flow API Adrien Mazarguil @ 2018-04-06 13:25 ` Adrien Mazarguil 2018-04-07 9:21 ` Andrew Rybchenko 2018-04-06 13:25 ` [dpdk-dev] [PATCH v2 03/15] doc: remove flow API migration section Adrien Mazarguil ` (13 subsequent siblings) 15 siblings, 1 reply; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-06 13:25 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev Although pattern items and actions examples end with "and so on", these lists include all existing definitions and as a result are updated almost every time new types are added. This is cumbersome and pointless. This patch also synchronizes Doxygen and external API documentation wording with a slight clarification regarding meta pattern items. No fundamental API change. Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> --- doc/guides/prog_guide/rte_flow.rst | 23 +++++++++++------------ lib/librte_ether/rte_flow.h | 23 ++++++++++------------- 2 files changed, 21 insertions(+), 25 deletions(-) diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 961943dda..a11ebd617 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -186,12 +186,13 @@ Pattern item Pattern items fall in two categories: -- Matching protocol headers and packet data (ANY, RAW, ETH, VLAN, IPV4, - IPV6, ICMP, UDP, TCP, SCTP, VXLAN, MPLS, GRE, ESP and so on), usually - associated with a specification structure. +- Matching protocol headers and packet data, usually associated with a + specification structure. These must be stacked in the same order as the + protocol layers to match inside packets, starting from the lowest. -- Matching meta-data or affecting pattern processing (END, VOID, INVERT, PF, - VF, PORT and so on), often without a specification structure. +- Matching meta-data or affecting pattern processing, often without a + specification structure. Since they do not match packet contents, their + position in the list is usually not relevant. Item specification structures are used to match specific values among protocol fields (or item properties). Documentation describes for each item @@ -1001,15 +1002,13 @@ to a flow rule. That list is not ordered. They fall in three categories: -- Terminating actions (such as QUEUE, DROP, RSS, PF, VF) that prevent - processing matched packets by subsequent flow rules, unless overridden - with PASSTHRU. +- Terminating actions that prevent processing matched packets by subsequent + flow rules, unless overridden with PASSTHRU. -- Non-terminating actions (PASSTHRU, DUP) that leave matched packets up for - additional processing by subsequent flow rules. +- Non-terminating actions that leave matched packets up for additional + processing by subsequent flow rules. -- Other non-terminating meta actions that do not affect the fate of packets - (END, VOID, MARK, FLAG, COUNT, SECURITY). +- Other non-terminating meta actions that do not affect the fate of packets. When several actions are combined in a flow rule, they should all have different types (e.g. dropping a packet twice is not possible). diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index 95799fd9c..36fd38ffa 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -78,15 +78,13 @@ struct rte_flow_attr { * * Pattern items fall in two categories: * - * - Matching protocol headers and packet data (ANY, RAW, ETH, VLAN, IPV4, - * IPV6, ICMP, UDP, TCP, SCTP, VXLAN and so on), usually associated with a + * - Matching protocol headers and packet data, usually associated with a * specification structure. These must be stacked in the same order as the - * protocol layers to match, starting from the lowest. + * protocol layers to match inside packets, starting from the lowest. * - * - Matching meta-data or affecting pattern processing (END, VOID, INVERT, - * PF, VF, PORT and so on), often without a specification structure. Since - * they do not match packet contents, these can be specified anywhere - * within item lists without affecting others. + * - Matching meta-data or affecting pattern processing, often without a + * specification structure. Since they do not match packet contents, their + * position in the list is usually not relevant. * * See the description of individual types for more information. Those * marked with [META] fall into the second category. @@ -865,15 +863,14 @@ struct rte_flow_item { * * They fall in three categories: * - * - Terminating actions (such as QUEUE, DROP, RSS, PF, VF) that prevent - * processing matched packets by subsequent flow rules, unless overridden - * with PASSTHRU. + * - Terminating actions that prevent processing matched packets by + * subsequent flow rules, unless overridden with PASSTHRU. * - * - Non terminating actions (PASSTHRU, DUP) that leave matched packets up - * for additional processing by subsequent flow rules. + * - Non terminating actions that leave matched packets up for additional + * processing by subsequent flow rules. * * - Other non terminating meta actions that do not affect the fate of - * packets (END, VOID, MARK, FLAG, COUNT). + * packets. * * When several actions are combined in a flow rule, they should all have * different types (e.g. dropping a packet twice is not possible). -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [dpdk-dev] [PATCH v2 02/15] ethdev: clarify flow API pattern items and actions 2018-04-06 13:25 ` [dpdk-dev] [PATCH v2 02/15] ethdev: clarify flow API pattern items and actions Adrien Mazarguil @ 2018-04-07 9:21 ` Andrew Rybchenko 0 siblings, 0 replies; 157+ messages in thread From: Andrew Rybchenko @ 2018-04-07 9:21 UTC (permalink / raw) To: Adrien Mazarguil, Thomas Monjalon, Ferruh Yigit, dev On 04/06/2018 04:25 PM, Adrien Mazarguil wrote: > Although pattern items and actions examples end with "and so on", these > lists include all existing definitions and as a result are updated almost > every time new types are added. This is cumbersome and pointless. > > This patch also synchronizes Doxygen and external API documentation wording > with a slight clarification regarding meta pattern items. > > No fundamental API change. > > Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> > --- > doc/guides/prog_guide/rte_flow.rst | 23 +++++++++++------------ > lib/librte_ether/rte_flow.h | 23 ++++++++++------------- > 2 files changed, 21 insertions(+), 25 deletions(-) Acked-by: Andrew Rybchenko <arybchenko@solarflare.com> ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v2 03/15] doc: remove flow API migration section 2018-04-06 13:25 ` [dpdk-dev] [PATCH v2 00/15] Flow API overhaul for switch offloads Adrien Mazarguil 2018-04-06 13:25 ` [dpdk-dev] [PATCH v2 01/15] ethdev: add error types to flow API Adrien Mazarguil 2018-04-06 13:25 ` [dpdk-dev] [PATCH v2 02/15] ethdev: clarify flow API pattern items and actions Adrien Mazarguil @ 2018-04-06 13:25 ` Adrien Mazarguil 2018-04-07 9:22 ` Andrew Rybchenko 2018-04-06 13:25 ` [dpdk-dev] [PATCH v2 04/15] ethdev: remove DUP action from flow API Adrien Mazarguil ` (12 subsequent siblings) 15 siblings, 1 reply; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-06 13:25 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev This section has become less relevant since the flow API (rte_flow) is now a mature DPDK API with applications developed directly on top of it instead of an afterthought. This patch removes it for the following reasons: - It has never been updated to track the latest changes in the legacy filter types and never will. - Many provided examples are theoretical and misleading since PMDs do not implement them. Others are obvious. - Upcoming work on the flow API will alter the behavior of several pattern items, actions and in some cases, flow rules, which will in turn cause existing examples to be wrong. Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> --- doc/guides/prog_guide/rte_flow.rst | 298 -------------------------------- 1 file changed, 298 deletions(-) diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index a11ebd617..51826d04c 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -55,9 +55,6 @@ encompasses and supersedes (including all functions and filter types) in order to expose a single interface with an unambiguous behavior that is common to all poll-mode drivers (PMDs). -Several methods to migrate existing applications are described in `API -migration`_. - Flow rule --------- @@ -2068,298 +2065,3 @@ Future evolutions - Optional software fallback when PMDs are unable to handle requested flow rules so applications do not have to implement their own. - -API migration -------------- - -Exhaustive list of deprecated filter types (normally prefixed with -*RTE_ETH_FILTER_*) found in ``rte_eth_ctrl.h`` and methods to convert them -to *rte_flow* rules. - -``MACVLAN`` to ``ETH`` → ``VF``, ``PF`` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -*MACVLAN* can be translated to a basic `Item: ETH`_ flow rule with a -terminating `Action: VF`_ or `Action: PF`_. - -.. _table_rte_flow_migration_macvlan: - -.. table:: MACVLAN conversion - - +--------------------------+---------+ - | Pattern | Actions | - +===+=====+==========+=====+=========+ - | 0 | ETH | ``spec`` | any | VF, | - | | +----------+-----+ PF | - | | | ``last`` | N/A | | - | | +----------+-----+ | - | | | ``mask`` | any | | - +---+-----+----------+-----+---------+ - | 1 | END | END | - +---+----------------------+---------+ - -``ETHERTYPE`` to ``ETH`` → ``QUEUE``, ``DROP`` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -*ETHERTYPE* is basically an `Item: ETH`_ flow rule with a terminating -`Action: QUEUE`_ or `Action: DROP`_. - -.. _table_rte_flow_migration_ethertype: - -.. table:: ETHERTYPE conversion - - +--------------------------+---------+ - | Pattern | Actions | - +===+=====+==========+=====+=========+ - | 0 | ETH | ``spec`` | any | QUEUE, | - | | +----------+-----+ DROP | - | | | ``last`` | N/A | | - | | +----------+-----+ | - | | | ``mask`` | any | | - +---+-----+----------+-----+---------+ - | 1 | END | END | - +---+----------------------+---------+ - -``FLEXIBLE`` to ``RAW`` → ``QUEUE`` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -*FLEXIBLE* can be translated to one `Item: RAW`_ pattern with a terminating -`Action: QUEUE`_ and a defined priority level. - -.. _table_rte_flow_migration_flexible: - -.. table:: FLEXIBLE conversion - - +--------------------------+---------+ - | Pattern | Actions | - +===+=====+==========+=====+=========+ - | 0 | RAW | ``spec`` | any | QUEUE | - | | +----------+-----+ | - | | | ``last`` | N/A | | - | | +----------+-----+ | - | | | ``mask`` | any | | - +---+-----+----------+-----+---------+ - | 1 | END | END | - +---+----------------------+---------+ - -``SYN`` to ``TCP`` → ``QUEUE`` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -*SYN* is a `Item: TCP`_ rule with only the ``syn`` bit enabled and masked, -and a terminating `Action: QUEUE`_. - -Priority level can be set to simulate the high priority bit. - -.. _table_rte_flow_migration_syn: - -.. table:: SYN conversion - - +-----------------------------------+---------+ - | Pattern | Actions | - +===+======+==========+=============+=========+ - | 0 | ETH | ``spec`` | unset | QUEUE | - | | +----------+-------------+ | - | | | ``last`` | unset | | - | | +----------+-------------+ | - | | | ``mask`` | unset | | - +---+------+----------+-------------+---------+ - | 1 | IPV4 | ``spec`` | unset | END | - | | +----------+-------------+ | - | | | ``mask`` | unset | | - | | +----------+-------------+ | - | | | ``mask`` | unset | | - +---+------+----------+---------+---+ | - | 2 | TCP | ``spec`` | ``syn`` | 1 | | - | | +----------+---------+---+ | - | | | ``mask`` | ``syn`` | 1 | | - +---+------+----------+---------+---+ | - | 3 | END | | - +---+-------------------------------+---------+ - -``NTUPLE`` to ``IPV4``, ``TCP``, ``UDP`` → ``QUEUE`` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -*NTUPLE* is similar to specifying an empty L2, `Item: IPV4`_ as L3 with -`Item: TCP`_ or `Item: UDP`_ as L4 and a terminating `Action: QUEUE`_. - -A priority level can be specified as well. - -.. _table_rte_flow_migration_ntuple: - -.. table:: NTUPLE conversion - - +-----------------------------+---------+ - | Pattern | Actions | - +===+======+==========+=======+=========+ - | 0 | ETH | ``spec`` | unset | QUEUE | - | | +----------+-------+ | - | | | ``last`` | unset | | - | | +----------+-------+ | - | | | ``mask`` | unset | | - +---+------+----------+-------+---------+ - | 1 | IPV4 | ``spec`` | any | END | - | | +----------+-------+ | - | | | ``last`` | unset | | - | | +----------+-------+ | - | | | ``mask`` | any | | - +---+------+----------+-------+ | - | 2 | TCP, | ``spec`` | any | | - | | UDP +----------+-------+ | - | | | ``last`` | unset | | - | | +----------+-------+ | - | | | ``mask`` | any | | - +---+------+----------+-------+ | - | 3 | END | | - +---+-------------------------+---------+ - -``TUNNEL`` to ``ETH``, ``IPV4``, ``IPV6``, ``VXLAN`` (or other) → ``QUEUE`` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -*TUNNEL* matches common IPv4 and IPv6 L3/L4-based tunnel types. - -In the following table, `Item: ANY`_ is used to cover the optional L4. - -.. _table_rte_flow_migration_tunnel: - -.. table:: TUNNEL conversion - - +-------------------------------------------------------+---------+ - | Pattern | Actions | - +===+==========================+==========+=============+=========+ - | 0 | ETH | ``spec`` | any | QUEUE | - | | +----------+-------------+ | - | | | ``last`` | unset | | - | | +----------+-------------+ | - | | | ``mask`` | any | | - +---+--------------------------+----------+-------------+---------+ - | 1 | IPV4, IPV6 | ``spec`` | any | END | - | | +----------+-------------+ | - | | | ``last`` | unset | | - | | +----------+-------------+ | - | | | ``mask`` | any | | - +---+--------------------------+----------+-------------+ | - | 2 | ANY | ``spec`` | any | | - | | +----------+-------------+ | - | | | ``last`` | unset | | - | | +----------+---------+---+ | - | | | ``mask`` | ``num`` | 0 | | - +---+--------------------------+----------+---------+---+ | - | 3 | VXLAN, GENEVE, TEREDO, | ``spec`` | any | | - | | NVGRE, GRE, ... +----------+-------------+ | - | | | ``last`` | unset | | - | | +----------+-------------+ | - | | | ``mask`` | any | | - +---+--------------------------+----------+-------------+ | - | 4 | END | | - +---+---------------------------------------------------+---------+ - -``FDIR`` to most item types → ``QUEUE``, ``DROP``, ``PASSTHRU`` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -*FDIR* is more complex than any other type, there are several methods to -emulate its functionality. It is summarized for the most part in the table -below. - -A few features are intentionally not supported: - -- The ability to configure the matching input set and masks for the entire - device, PMDs should take care of it automatically according to the - requested flow rules. - - For example if a device supports only one bit-mask per protocol type, - source/address IPv4 bit-masks can be made immutable by the first created - rule. Subsequent IPv4 or TCPv4 rules can only be created if they are - compatible. - - Note that only protocol bit-masks affected by existing flow rules are - immutable, others can be changed later. They become mutable again after - the related flow rules are destroyed. - -- Returning four or eight bytes of matched data when using flex bytes - filtering. Although a specific action could implement it, it conflicts - with the much more useful 32 bits tagging on devices that support it. - -- Side effects on RSS processing of the entire device. Flow rules that - conflict with the current device configuration should not be - allowed. Similarly, device configuration should not be allowed when it - affects existing flow rules. - -- Device modes of operation. "none" is unsupported since filtering cannot be - disabled as long as a flow rule is present. - -- "MAC VLAN" or "tunnel" perfect matching modes should be automatically set - according to the created flow rules. - -- Signature mode of operation is not defined but could be handled through - "FUZZY" item. - -.. _table_rte_flow_migration_fdir: - -.. table:: FDIR conversion - - +----------------------------------------+-----------------------+ - | Pattern | Actions | - +===+===================+==========+=====+=======================+ - | 0 | ETH, RAW | ``spec`` | any | QUEUE, DROP, PASSTHRU | - | | +----------+-----+ | - | | | ``last`` | N/A | | - | | +----------+-----+ | - | | | ``mask`` | any | | - +---+-------------------+----------+-----+-----------------------+ - | 1 | IPV4, IPv6 | ``spec`` | any | MARK | - | | +----------+-----+ | - | | | ``last`` | N/A | | - | | +----------+-----+ | - | | | ``mask`` | any | | - +---+-------------------+----------+-----+-----------------------+ - | 2 | TCP, UDP, SCTP | ``spec`` | any | END | - | | +----------+-----+ | - | | | ``last`` | N/A | | - | | +----------+-----+ | - | | | ``mask`` | any | | - +---+-------------------+----------+-----+ | - | 3 | VF, PF, FUZZY | ``spec`` | any | | - | | (optional) +----------+-----+ | - | | | ``last`` | N/A | | - | | +----------+-----+ | - | | | ``mask`` | any | | - +---+-------------------+----------+-----+ | - | 4 | END | | - +---+------------------------------------+-----------------------+ - -``HASH`` -~~~~~~~~ - -There is no counterpart to this filter type because it translates to a -global device setting instead of a pattern item. Device settings are -automatically set according to the created flow rules. - -``L2_TUNNEL`` to ``VOID`` → ``VXLAN`` (or others) -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -All packets are matched. This type alters incoming packets to encapsulate -them in a chosen tunnel type, optionally redirect them to a VF as well. - -The destination pool for tag based forwarding can be emulated with other -flow rules using `Action: DUP`_. - -.. _table_rte_flow_migration_l2tunnel: - -.. table:: L2_TUNNEL conversion - - +---------------------------+--------------------+ - | Pattern | Actions | - +===+======+==========+=====+====================+ - | 0 | VOID | ``spec`` | N/A | VXLAN, GENEVE, ... | - | | | | | | - | | | | | | - | | +----------+-----+ | - | | | ``last`` | N/A | | - | | +----------+-----+ | - | | | ``mask`` | N/A | | - | | | | | | - +---+------+----------+-----+--------------------+ - | 1 | END | VF (optional) | - +---+ +--------------------+ - | 2 | | END | - +---+-----------------------+--------------------+ -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [dpdk-dev] [PATCH v2 03/15] doc: remove flow API migration section 2018-04-06 13:25 ` [dpdk-dev] [PATCH v2 03/15] doc: remove flow API migration section Adrien Mazarguil @ 2018-04-07 9:22 ` Andrew Rybchenko 0 siblings, 0 replies; 157+ messages in thread From: Andrew Rybchenko @ 2018-04-07 9:22 UTC (permalink / raw) To: Adrien Mazarguil, Thomas Monjalon, Ferruh Yigit, dev On 04/06/2018 04:25 PM, Adrien Mazarguil wrote: > This section has become less relevant since the flow API (rte_flow) is now > a mature DPDK API with applications developed directly on top of it instead > of an afterthought. > > This patch removes it for the following reasons: > > - It has never been updated to track the latest changes in the legacy > filter types and never will. > > - Many provided examples are theoretical and misleading since PMDs do not > implement them. Others are obvious. > > - Upcoming work on the flow API will alter the behavior of several pattern > items, actions and in some cases, flow rules, which will in turn cause > existing examples to be wrong. > > Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> > --- > doc/guides/prog_guide/rte_flow.rst | 298 -------------------------------- > 1 file changed, 298 deletions(-) Acked-by: Andrew Rybchenko <arybchenko@solarflare.com> ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v2 04/15] ethdev: remove DUP action from flow API 2018-04-06 13:25 ` [dpdk-dev] [PATCH v2 00/15] Flow API overhaul for switch offloads Adrien Mazarguil ` (2 preceding siblings ...) 2018-04-06 13:25 ` [dpdk-dev] [PATCH v2 03/15] doc: remove flow API migration section Adrien Mazarguil @ 2018-04-06 13:25 ` Adrien Mazarguil 2018-04-07 9:23 ` Andrew Rybchenko 2018-04-06 13:25 ` [dpdk-dev] [PATCH v2 05/15] ethdev: alter behavior of flow API actions Adrien Mazarguil ` (11 subsequent siblings) 15 siblings, 1 reply; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-06 13:25 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev Upcoming changes in relation to the handling of actions list will make the DUP action redundant as specifying several QUEUE actions will achieve the same behavior. Besides, no PMD implements this action. By removing an entry from enum rte_flow_action_type, this patch breaks ABI compatibility for the following public functions: - rte_flow_copy() - rte_flow_create() - rte_flow_query() - rte_flow_validate() Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> --- app/test-pmd/cmdline_flow.c | 23 ----------------------- app/test-pmd/config.c | 1 - doc/guides/prog_guide/rte_flow.rst | 23 ----------------------- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 8 -------- lib/librte_ether/rte_ethdev_version.map | 2 +- lib/librte_ether/rte_flow.c | 1 - lib/librte_ether/rte_flow.h | 24 ------------------------ 7 files changed, 1 insertion(+), 81 deletions(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 30450f1a4..9702b3ef3 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -164,8 +164,6 @@ enum index { ACTION_QUEUE_INDEX, ACTION_DROP, ACTION_COUNT, - ACTION_DUP, - ACTION_DUP_INDEX, ACTION_RSS, ACTION_RSS_TYPES, ACTION_RSS_TYPE, @@ -625,7 +623,6 @@ static const enum index next_action[] = { ACTION_QUEUE, ACTION_DROP, ACTION_COUNT, - ACTION_DUP, ACTION_RSS, ACTION_PF, ACTION_VF, @@ -645,12 +642,6 @@ static const enum index action_queue[] = { ZERO, }; -static const enum index action_dup[] = { - ACTION_DUP_INDEX, - ACTION_NEXT, - ZERO, -}; - static const enum index action_rss[] = { ACTION_RSS_TYPES, ACTION_RSS_KEY, @@ -1597,20 +1588,6 @@ static const struct token token_list[] = { .next = NEXT(NEXT_ENTRY(ACTION_NEXT)), .call = parse_vc, }, - [ACTION_DUP] = { - .name = "dup", - .help = "duplicate packets to a given queue index", - .priv = PRIV_ACTION(DUP, sizeof(struct rte_flow_action_dup)), - .next = NEXT(action_dup), - .call = parse_vc, - }, - [ACTION_DUP_INDEX] = { - .name = "index", - .help = "queue index to duplicate packets to", - .next = NEXT(action_dup, NEXT_ENTRY(UNSIGNED)), - .args = ARGS(ARGS_ENTRY(struct rte_flow_action_dup, index)), - .call = parse_vc_conf, - }, [ACTION_RSS] = { .name = "rss", .help = "spread packets among several queues", diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 7ae0295f6..8d42ea9a9 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -1049,7 +1049,6 @@ static const struct { MK_FLOW_ACTION(QUEUE, sizeof(struct rte_flow_action_queue)), MK_FLOW_ACTION(DROP, 0), MK_FLOW_ACTION(COUNT, 0), - MK_FLOW_ACTION(DUP, sizeof(struct rte_flow_action_dup)), MK_FLOW_ACTION(RSS, sizeof(struct rte_flow_action_rss)), /* +queue[] */ MK_FLOW_ACTION(PF, 0), MK_FLOW_ACTION(VF, sizeof(struct rte_flow_action_vf)), diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 51826d04c..a237e4fd2 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -1299,26 +1299,6 @@ Query structure to retrieve and reset flow rule counters: | ``bytes`` | out | number of bytes through this rule | +---------------+-----+-----------------------------------+ -Action: ``DUP`` -^^^^^^^^^^^^^^^ - -Duplicates packets to a given queue index. - -This is normally combined with QUEUE, however when used alone, it is -actually similar to QUEUE + PASSTHRU. - -- Non-terminating by default. - -.. _table_rte_flow_action_dup: - -.. table:: DUP - - +-----------+------------------------------------+ - | Field | Value | - +===========+====================================+ - | ``index`` | queue index to duplicate packet to | - +-----------+------------------------------------+ - Action: ``RSS`` ^^^^^^^^^^^^^^^ @@ -2010,9 +1990,6 @@ Unsupported actions and tagging (`Action: MARK`_ or `Action: FLAG`_) may be implemented in software as long as the target queue is used by a single rule. -- A rule specifying both `Action: DUP`_ + `Action: QUEUE`_ may be translated - to two hidden rules combining `Action: QUEUE`_ and `Action: PASSTHRU`_. - - When a single target queue is provided, `Action: RSS`_ can also be implemented through `Action: QUEUE`_. diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index cb6f201e1..a015d02a4 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3363,10 +3363,6 @@ actions can sometimes be combined when the end result is unambiguous:: :: - drop / dup index 6 / end # same as above - -:: - queue index 6 / rss queues 6 7 8 / end # queue has no effect :: @@ -3400,10 +3396,6 @@ This section lists supported actions and their attributes, if any. - ``count``: enable counters for this rule. -- ``dup``: duplicate packets to a given queue index. - - - ``index {unsigned}``: queue index to duplicate packets to. - - ``rss``: spread packets among several queues. - ``types [{RSS hash type} [...]] end``: RSS hash types, allowed tokens diff --git a/lib/librte_ether/rte_ethdev_version.map b/lib/librte_ether/rte_ethdev_version.map index e915e7929..8f1ae5ed2 100644 --- a/lib/librte_ether/rte_ethdev_version.map +++ b/lib/librte_ether/rte_ethdev_version.map @@ -147,7 +147,6 @@ DPDK_17.08 { _rte_eth_dev_callback_process; rte_eth_dev_adjust_nb_rx_tx_desc; - rte_flow_copy; rte_tm_capabilities_get; rte_tm_hierarchy_commit; rte_tm_level_capabilities_get; @@ -199,6 +198,7 @@ DPDK_18.02 { DPDK_18.05 { global: + rte_flow_copy; rte_flow_create; rte_flow_destroy; rte_flow_error_set; diff --git a/lib/librte_ether/rte_flow.c b/lib/librte_ether/rte_flow.c index ba6feddee..db04c4f94 100644 --- a/lib/librte_ether/rte_flow.c +++ b/lib/librte_ether/rte_flow.c @@ -73,7 +73,6 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = { MK_FLOW_ACTION(QUEUE, sizeof(struct rte_flow_action_queue)), MK_FLOW_ACTION(DROP, 0), MK_FLOW_ACTION(COUNT, 0), - MK_FLOW_ACTION(DUP, sizeof(struct rte_flow_action_dup)), MK_FLOW_ACTION(RSS, sizeof(struct rte_flow_action_rss)), /* +queue[] */ MK_FLOW_ACTION(PF, 0), MK_FLOW_ACTION(VF, sizeof(struct rte_flow_action_vf)), diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index 36fd38ffa..aab637a2c 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -961,16 +961,6 @@ enum rte_flow_action_type { RTE_FLOW_ACTION_TYPE_COUNT, /** - * Duplicates packets to a given queue index. - * - * This is normally combined with QUEUE, however when used alone, it - * is actually similar to QUEUE + PASSTHRU. - * - * See struct rte_flow_action_dup. - */ - RTE_FLOW_ACTION_TYPE_DUP, - - /** * Similar to QUEUE, except RSS is additionally performed on packets * to spread them among several queues according to the provided * parameters. @@ -1052,20 +1042,6 @@ struct rte_flow_query_count { }; /** - * RTE_FLOW_ACTION_TYPE_DUP - * - * Duplicates packets to a given queue index. - * - * This is normally combined with QUEUE, however when used alone, it is - * actually similar to QUEUE + PASSTHRU. - * - * Non-terminating by default. - */ -struct rte_flow_action_dup { - uint16_t index; /**< Queue index to duplicate packets to. */ -}; - -/** * RTE_FLOW_ACTION_TYPE_RSS * * Similar to QUEUE, except RSS is additionally performed on packets to -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [dpdk-dev] [PATCH v2 04/15] ethdev: remove DUP action from flow API 2018-04-06 13:25 ` [dpdk-dev] [PATCH v2 04/15] ethdev: remove DUP action from flow API Adrien Mazarguil @ 2018-04-07 9:23 ` Andrew Rybchenko 0 siblings, 0 replies; 157+ messages in thread From: Andrew Rybchenko @ 2018-04-07 9:23 UTC (permalink / raw) To: Adrien Mazarguil, Thomas Monjalon, Ferruh Yigit, dev On 04/06/2018 04:25 PM, Adrien Mazarguil wrote: > Upcoming changes in relation to the handling of actions list will make the > DUP action redundant as specifying several QUEUE actions will achieve the > same behavior. Besides, no PMD implements this action. > > By removing an entry from enum rte_flow_action_type, this patch breaks ABI > compatibility for the following public functions: > > - rte_flow_copy() > - rte_flow_create() > - rte_flow_query() > - rte_flow_validate() > > Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> > --- > app/test-pmd/cmdline_flow.c | 23 ----------------------- > app/test-pmd/config.c | 1 - > doc/guides/prog_guide/rte_flow.rst | 23 ----------------------- > doc/guides/testpmd_app_ug/testpmd_funcs.rst | 8 -------- > lib/librte_ether/rte_ethdev_version.map | 2 +- > lib/librte_ether/rte_flow.c | 1 - > lib/librte_ether/rte_flow.h | 24 ------------------------ > 7 files changed, 1 insertion(+), 81 deletions(-) Acked-by: Andrew Rybchenko <arybchenko@solarflare.com> ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v2 05/15] ethdev: alter behavior of flow API actions 2018-04-06 13:25 ` [dpdk-dev] [PATCH v2 00/15] Flow API overhaul for switch offloads Adrien Mazarguil ` (3 preceding siblings ...) 2018-04-06 13:25 ` [dpdk-dev] [PATCH v2 04/15] ethdev: remove DUP action from flow API Adrien Mazarguil @ 2018-04-06 13:25 ` Adrien Mazarguil 2018-04-06 15:06 ` Andrew Rybchenko 2018-04-06 13:25 ` [dpdk-dev] [PATCH v2 06/15] ethdev: remove C99 flexible arrays from flow API Adrien Mazarguil ` (10 subsequent siblings) 15 siblings, 1 reply; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-06 13:25 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev Cc: Ajit Khaparde, Wenzhuo Lu, John Daley, Gaetan Rivet, Beilei Xing, Konstantin Ananyev, Nelio Laranjeiro, Andrew Rybchenko, Pascal Mazon This patch makes the following changes to flow rule actions: - List order now matters, they are redefined as performed first to last instead of "all simultaneously". - Repeated actions are now supported (e.g. specifying QUEUE multiple times now duplicates traffic among them). Previously only the last action of any given kind was taken into account. - No more distinction between terminating/non-terminating/meta actions. Flow rules themselves are now defined as always terminating unless a PASSTHRU action is specified. These changes alter the behavior of flow rules in corner cases in order to prepare the flow API for actions that modify traffic contents or properties (e.g. encapsulation, compression) and for which order matter when combined. Previously one would have to so through multiple flow rules by combining PASSTRHU with priority levels, however this proved overly complex to implement at the PMD level, hence this simpler approach. This breaks ABI compatibility for the following public functions: - rte_flow_create() - rte_flow_validate() PMDs with rte_flow support are modified accordingly: - bnxt: no change, implementation already forbids multiple actions and does not support PASSTHRU. - e1000: no change, same as bnxt. - enic: modified to forbid redundant actions, no support for default drop. - failsafe: no change needed. - i40e: no change, implementation already forbids multiple actions. - ixgbe: same as i40e. - mlx4: modified to forbid multiple fate-deciding actions and drop when unspecified. - mlx5: same as mlx4, with other redundant actions also forbidden. - sfc: same as mlx4. - tap: implementation already complies with the new behavior except for the default pass-through modified as a default drop. Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Cc: Ajit Khaparde <ajit.khaparde@broadcom.com> Cc: Wenzhuo Lu <wenzhuo.lu@intel.com> Cc: John Daley <johndale@cisco.com> Cc: Gaetan Rivet <gaetan.rivet@6wind.com> Cc: Beilei Xing <beilei.xing@intel.com> Cc: Konstantin Ananyev <konstantin.ananyev@intel.com> Cc: Nelio Laranjeiro <nelio.laranjeiro@6wind.com> Cc: Andrew Rybchenko <arybchenko@solarflare.com> Cc: Pascal Mazon <pascal.mazon@6wind.com> --- doc/guides/prog_guide/rte_flow.rst | 67 +++++++++++++------------------- drivers/net/enic/enic_flow.c | 25 ++++++++++++ drivers/net/mlx4/mlx4_flow.c | 21 +++++++--- drivers/net/mlx5/mlx5_flow.c | 69 ++++++++++++++------------------- drivers/net/sfc/sfc_flow.c | 22 +++++++---- drivers/net/tap/tap_flow.c | 11 ++++++ lib/librte_ether/rte_flow.h | 54 +++++++------------------- 7 files changed, 138 insertions(+), 131 deletions(-) diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index a237e4fd2..80360d068 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -995,28 +995,27 @@ Actions Each possible action is represented by a type. Some have associated configuration structures. Several actions combined in a list can be assigned -to a flow rule. That list is not ordered. +to a flow rule and are performed in order. They fall in three categories: -- Terminating actions that prevent processing matched packets by subsequent - flow rules, unless overridden with PASSTHRU. +- Actions that modify the fate of matching traffic, for instance by dropping + or assigning it a specific destination. -- Non-terminating actions that leave matched packets up for additional - processing by subsequent flow rules. +- Actions that modify matching traffic contents or its properties. This + includes adding/removing encapsulation, encryption, compression and marks. -- Other non-terminating meta actions that do not affect the fate of packets. +- Actions related to the flow rule itself, such as updating counters or + making it non-terminating. -When several actions are combined in a flow rule, they should all have -different types (e.g. dropping a packet twice is not possible). +Flow rules being terminating by default, not specifying any action of the +fate kind results in undefined behavior. This applies to both ingress and +egress. -Only the last action of a given type is taken into account. PMDs still -perform error checking on the entire list. +PASSTHRU, when supported, makes a flow rule non-terminating. Like matching patterns, action lists are terminated by END items. -*Note that PASSTHRU is the only action able to override a terminating rule.* - Example of action that redirects packets to queue index 10: .. _table_rte_flow_action_example: @@ -1029,12 +1028,11 @@ Example of action that redirects packets to queue index 10: | ``index`` | 10 | +-----------+-------+ -Action lists examples, their order is not significant, applications must -consider all actions to be performed simultaneously: +Actions are performed in list order: -.. _table_rte_flow_count_and_drop: +.. _table_rte_flow_count_then_drop: -.. table:: Count and drop +.. table:: Count then drop +-------+--------+ | Index | Action | @@ -1050,7 +1048,7 @@ consider all actions to be performed simultaneously: .. _table_rte_flow_mark_count_redirect: -.. table:: Mark, count and redirect +.. table:: Mark, count then redirect +-------+--------+-----------+-------+ | Index | Action | Field | Value | @@ -1080,12 +1078,15 @@ consider all actions to be performed simultaneously: | 2 | END | +-------+----------------------------+ -In the above example, considering both actions are performed simultaneously, -the end result is that only QUEUE has any effect. +In the above example, while DROP and QUEUE must be performed in order, both +have to happen before reaching END. Only QUEUE has a visible effect. + +Note that such a list may be thought as ambiguous and rejected on that +basis. -.. _table_rte_flow_redirect_queue_3: +.. _table_rte_flow_redirect_queue_5_3: -.. table:: Redirect to queue 3 +.. table:: Redirect to queues 5 and 3 +-------+--------+-----------+-------+ | Index | Action | Field | Value | @@ -1099,9 +1100,9 @@ the end result is that only QUEUE has any effect. | 3 | END | +-------+----------------------------+ -As previously described, only the last action of a given type found in the -list is taken into account. The above example also shows that VOID is -ignored. +As previously described, all actions must be taken into account. This +effectively duplicates traffic to both queues. The above example also shows +that VOID is ignored. Action types ~~~~~~~~~~~~ @@ -1151,9 +1152,8 @@ PMDs. Action: ``PASSTHRU`` ^^^^^^^^^^^^^^^^^^^^ -Leaves packets up for additional processing by subsequent flow rules. This -is the default when a rule does not contain a terminating action, but can be -specified to force a rule to become non-terminating. +Leaves traffic up for additional processing by subsequent flow rules; makes +a flow rule non-terminating. - No configurable properties. @@ -1227,8 +1227,6 @@ Action: ``QUEUE`` Assigns packets to a given queue index. -- Terminating by default. - .. _table_rte_flow_action_queue: .. table:: QUEUE @@ -1245,8 +1243,6 @@ Action: ``DROP`` Drop packets. - No configurable properties. -- Terminating by default. -- PASSTHRU overrides this action if both are specified. .. _table_rte_flow_action_drop: @@ -1309,8 +1305,6 @@ Note: RSS hash result is stored in the ``hash.rss`` mbuf field which overlaps ``hash.fdir.lo``. Since `Action: MARK`_ sets the ``hash.fdir.hi`` field only, both can be requested simultaneously. -- Terminating by default. - .. _table_rte_flow_action_rss: .. table:: RSS @@ -1331,7 +1325,6 @@ Action: ``PF`` Redirects packets to the physical function (PF) of the current device. - No configurable properties. -- Terminating by default. .. _table_rte_flow_action_pf: @@ -1353,8 +1346,6 @@ ID instead of the specified one. This parameter may not be available and is not guaranteed to work properly if the VF part is matched by a prior flow rule or if packets are not addressed to a VF in the first place. -- Terminating by default. - .. _table_rte_flow_action_vf: .. table:: VF @@ -1378,8 +1369,6 @@ action parameter. More than one flow can use the same MTR object through the meter action. The MTR object can be further updated or queried using the rte_mtr* API. -- Non-terminating by default. - .. _table_rte_flow_action_meter: .. table:: METER @@ -1415,8 +1404,6 @@ direction. Multiple flows can be configured to use the same security session. -- Non-terminating by default. - .. _table_rte_flow_action_security: .. table:: SECURITY diff --git a/drivers/net/enic/enic_flow.c b/drivers/net/enic/enic_flow.c index 28923b0e2..c5c98b870 100644 --- a/drivers/net/enic/enic_flow.c +++ b/drivers/net/enic/enic_flow.c @@ -3,6 +3,7 @@ */ #include <errno.h> +#include <stdint.h> #include <rte_log.h> #include <rte_ethdev_driver.h> #include <rte_flow_driver.h> @@ -952,6 +953,9 @@ static int enic_copy_action_v1(const struct rte_flow_action actions[], struct filter_action_v2 *enic_action) { + enum { FATE = 1, }; + uint32_t overlap = 0; + FLOW_TRACE(); for (; actions->type != RTE_FLOW_ACTION_TYPE_END; actions++) { @@ -963,6 +967,10 @@ enic_copy_action_v1(const struct rte_flow_action actions[], const struct rte_flow_action_queue *queue = (const struct rte_flow_action_queue *) actions->conf; + + if (overlap & FATE) + return ENOTSUP; + overlap |= FATE; enic_action->rq_idx = enic_rte_rq_idx_to_sop_idx(queue->index); break; @@ -972,6 +980,8 @@ enic_copy_action_v1(const struct rte_flow_action actions[], break; } } + if (!overlap & FATE) + return ENOTSUP; enic_action->type = FILTER_ACTION_RQ_STEERING; return 0; } @@ -989,6 +999,9 @@ static int enic_copy_action_v2(const struct rte_flow_action actions[], struct filter_action_v2 *enic_action) { + enum { FATE = 1, MARK = 2, }; + uint32_t overlap = 0; + FLOW_TRACE(); for (; actions->type != RTE_FLOW_ACTION_TYPE_END; actions++) { @@ -997,6 +1010,10 @@ enic_copy_action_v2(const struct rte_flow_action actions[], const struct rte_flow_action_queue *queue = (const struct rte_flow_action_queue *) actions->conf; + + if (overlap & FATE) + return ENOTSUP; + overlap |= FATE; enic_action->rq_idx = enic_rte_rq_idx_to_sop_idx(queue->index); enic_action->flags |= FILTER_ACTION_RQ_STEERING_FLAG; @@ -1007,6 +1024,9 @@ enic_copy_action_v2(const struct rte_flow_action actions[], (const struct rte_flow_action_mark *) actions->conf; + if (overlap & MARK) + return ENOTSUP; + overlap |= MARK; /* ENIC_MAGIC_FILTER_ID is reserved and is the highest * in the range of allows mark ids. */ @@ -1017,6 +1037,9 @@ enic_copy_action_v2(const struct rte_flow_action actions[], break; } case RTE_FLOW_ACTION_TYPE_FLAG: { + if (overlap & MARK) + return ENOTSUP; + overlap |= MARK; enic_action->filter_id = ENIC_MAGIC_FILTER_ID; enic_action->flags |= FILTER_ACTION_FILTER_ID_FLAG; break; @@ -1028,6 +1051,8 @@ enic_copy_action_v2(const struct rte_flow_action actions[], break; } } + if (!overlap & FATE) + return ENOTSUP; enic_action->type = FILTER_ACTION_V2; return 0; } diff --git a/drivers/net/mlx4/mlx4_flow.c b/drivers/net/mlx4/mlx4_flow.c index 4d26df326..582483076 100644 --- a/drivers/net/mlx4/mlx4_flow.c +++ b/drivers/net/mlx4/mlx4_flow.c @@ -637,6 +637,7 @@ mlx4_flow_prepare(struct priv *priv, struct rte_flow temp = { .ibv_attr_size = sizeof(*temp.ibv_attr) }; struct rte_flow *flow = &temp; const char *msg = NULL; + int overlap; if (attr->group) return rte_flow_error_set @@ -656,6 +657,7 @@ mlx4_flow_prepare(struct priv *priv, (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, NULL, "only ingress is supported"); fill: + overlap = 0; proc = mlx4_flow_proc_item_list; /* Go over pattern. */ for (item = pattern; item->type; ++item) { @@ -702,6 +704,16 @@ mlx4_flow_prepare(struct priv *priv, } /* Go over actions list. */ for (action = actions; action->type; ++action) { + /* This one may appear anywhere multiple times. */ + if (action->type == RTE_FLOW_ACTION_TYPE_VOID) + continue; + /* Fate-deciding actions may appear exactly once. */ + if (overlap) { + msg = "cannot combine several fate-deciding actions," + " choose between DROP, QUEUE or RSS"; + goto exit_action_not_supported; + } + overlap = 1; switch (action->type) { const struct rte_flow_action_queue *queue; const struct rte_flow_action_rss *rss; @@ -709,8 +721,6 @@ mlx4_flow_prepare(struct priv *priv, uint64_t fields; unsigned int i; - case RTE_FLOW_ACTION_TYPE_VOID: - continue; case RTE_FLOW_ACTION_TYPE_DROP: flow->drop = 1; break; @@ -801,10 +811,9 @@ mlx4_flow_prepare(struct priv *priv, goto exit_action_not_supported; } } - if (!flow->rss && !flow->drop) - return rte_flow_error_set - (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, - NULL, "no valid action"); + /* When fate is unknown, drop traffic. */ + if (!overlap) + flow->drop = 1; /* Validation ends here. */ if (!addr) { if (flow->rss) diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index f051fbef5..84d6f9b92 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -4,6 +4,7 @@ */ #include <sys/queue.h> +#include <stdint.h> #include <string.h> /* Verbs header. */ @@ -638,6 +639,8 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, struct rte_flow_error *error, struct mlx5_flow_parse *parser) { + enum { FATE = 1, MARK = 2, COUNT = 4, }; + uint32_t overlap = 0; struct priv *priv = dev->data->dev_private; int ret; @@ -654,39 +657,31 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, if (actions->type == RTE_FLOW_ACTION_TYPE_VOID) { continue; } else if (actions->type == RTE_FLOW_ACTION_TYPE_DROP) { + if (overlap & FATE) + goto exit_action_overlap; + overlap |= FATE; parser->drop = 1; } else if (actions->type == RTE_FLOW_ACTION_TYPE_QUEUE) { const struct rte_flow_action_queue *queue = (const struct rte_flow_action_queue *) actions->conf; - uint16_t n; - uint16_t found = 0; + if (overlap & FATE) + goto exit_action_overlap; + overlap |= FATE; if (!queue || (queue->index > (priv->rxqs_n - 1))) goto exit_action_not_supported; - for (n = 0; n < parser->queues_n; ++n) { - if (parser->queues[n] == queue->index) { - found = 1; - break; - } - } - if (parser->queues_n > 1 && !found) { - rte_flow_error_set(error, ENOTSUP, - RTE_FLOW_ERROR_TYPE_ACTION, - actions, - "queue action not in RSS queues"); - return -rte_errno; - } - if (!found) { - parser->queues_n = 1; - parser->queues[0] = queue->index; - } + parser->queues_n = 1; + parser->queues[0] = queue->index; } else if (actions->type == RTE_FLOW_ACTION_TYPE_RSS) { const struct rte_flow_action_rss *rss = (const struct rte_flow_action_rss *) actions->conf; uint16_t n; + if (overlap & FATE) + goto exit_action_overlap; + overlap |= FATE; if (!rss || !rss->num) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, @@ -694,26 +689,6 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, "no valid queues"); return -rte_errno; } - if (parser->queues_n == 1) { - uint16_t found = 0; - - assert(parser->queues_n); - for (n = 0; n < rss->num; ++n) { - if (parser->queues[0] == - rss->queue[n]) { - found = 1; - break; - } - } - if (!found) { - rte_flow_error_set(error, ENOTSUP, - RTE_FLOW_ERROR_TYPE_ACTION, - actions, - "queue action not in RSS" - " queues"); - return -rte_errno; - } - } if (rss->num > RTE_DIM(parser->queues)) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, @@ -747,6 +722,9 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, (const struct rte_flow_action_mark *) actions->conf; + if (overlap & MARK) + goto exit_action_overlap; + overlap |= MARK; if (!mark) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, @@ -764,14 +742,23 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, parser->mark = 1; parser->mark_id = mark->id; } else if (actions->type == RTE_FLOW_ACTION_TYPE_FLAG) { + if (overlap & MARK) + goto exit_action_overlap; + overlap |= MARK; parser->mark = 1; } else if (actions->type == RTE_FLOW_ACTION_TYPE_COUNT && priv->config.flow_counter_en) { + if (overlap & COUNT) + goto exit_action_overlap; + overlap |= COUNT; parser->count = 1; } else { goto exit_action_not_supported; } } + /* When fate is unknown, drop traffic. */ + if (!overlap & FATE) + parser->drop = 1; if (parser->drop && parser->mark) parser->mark = 0; if (!parser->queues_n && !parser->drop) { @@ -784,6 +771,10 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, actions, "action not supported"); return -rte_errno; +exit_action_overlap: + rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, + actions, "overlapping actions are not supported"); + return -rte_errno; } /** diff --git a/drivers/net/sfc/sfc_flow.c b/drivers/net/sfc/sfc_flow.c index fe4c0b0c5..056405515 100644 --- a/drivers/net/sfc/sfc_flow.c +++ b/drivers/net/sfc/sfc_flow.c @@ -1467,10 +1467,19 @@ sfc_flow_parse_actions(struct sfc_adapter *sa, } for (; actions->type != RTE_FLOW_ACTION_TYPE_END; actions++) { + /* This one may appear anywhere multiple times. */ + if (actions->type == RTE_FLOW_ACTION_TYPE_VOID) + continue; + /* Fate-deciding actions may appear exactly once. */ + if (is_specified) { + rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, + actions, + "Cannot combine several fate-deciding actions," + "choose between QUEUE, RSS or DROP"); + return -rte_errno; + } switch (actions->type) { - case RTE_FLOW_ACTION_TYPE_VOID: - break; - case RTE_FLOW_ACTION_TYPE_QUEUE: rc = sfc_flow_parse_queue(sa, actions->conf, flow); if (rc != 0) { @@ -1512,11 +1521,10 @@ sfc_flow_parse_actions(struct sfc_adapter *sa, } } + /* When fate is unknown, drop traffic. */ if (!is_specified) { - rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ACTION_NUM, actions, - "Action is unspecified"); - return -rte_errno; + flow->spec.template.efs_dmaq_id = + EFX_FILTER_SPEC_RX_DMAQ_ID_DROP; } return 0; diff --git a/drivers/net/tap/tap_flow.c b/drivers/net/tap/tap_flow.c index 551b2d83d..aea3462a6 100644 --- a/drivers/net/tap/tap_flow.c +++ b/drivers/net/tap/tap_flow.c @@ -1140,6 +1140,7 @@ priv_flow_process(struct pmd_internals *pmd, else goto end; } +actions: for (; actions->type != RTE_FLOW_ACTION_TYPE_END; ++actions) { int err = 0; @@ -1222,6 +1223,16 @@ priv_flow_process(struct pmd_internals *pmd, if (err) goto exit_action_not_supported; } + /* When fate is unknown, drop traffic. */ + if (!action) { + static const struct rte_flow_action drop[] = { + { .type = RTE_FLOW_ACTION_TYPE_DROP, }, + { .type = RTE_FLOW_ACTION_TYPE_END, }, + }; + + actions = drop; + goto actions; + } end: if (flow) tap_nlattr_nested_finish(&flow->msg); /* nested TCA_OPTIONS */ diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index aab637a2c..af9b14a4d 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -859,32 +859,28 @@ struct rte_flow_item { * * Each possible action is represented by a type. Some have associated * configuration structures. Several actions combined in a list can be - * affected to a flow rule. That list is not ordered. + * assigned to a flow rule and are performed in order. * * They fall in three categories: * - * - Terminating actions that prevent processing matched packets by - * subsequent flow rules, unless overridden with PASSTHRU. + * - Actions that modify the fate of matching traffic, for instance by + * dropping or assigning it a specific destination. * - * - Non terminating actions that leave matched packets up for additional - * processing by subsequent flow rules. + * - Actions that modify matching traffic contents or its properties. This + * includes adding/removing encapsulation, encryption, compression and + * marks. * - * - Other non terminating meta actions that do not affect the fate of - * packets. + * - Actions related to the flow rule itself, such as updating counters or + * making it non-terminating. * - * When several actions are combined in a flow rule, they should all have - * different types (e.g. dropping a packet twice is not possible). + * Flow rules being terminating by default, not specifying any action of the + * fate kind results in undefined behavior. This applies to both ingress and + * egress. * - * Only the last action of a given type is taken into account. PMDs still - * perform error checking on the entire list. - * - * Note that PASSTHRU is the only action able to override a terminating - * rule. + * PASSTHRU, when supported, makes a flow rule non-terminating. */ enum rte_flow_action_type { /** - * [META] - * * End marker for action lists. Prevents further processing of * actions, thereby ending the list. * @@ -893,8 +889,6 @@ enum rte_flow_action_type { RTE_FLOW_ACTION_TYPE_END, /** - * [META] - * * Used as a placeholder for convenience. It is ignored and simply * discarded by PMDs. * @@ -903,18 +897,14 @@ enum rte_flow_action_type { RTE_FLOW_ACTION_TYPE_VOID, /** - * Leaves packets up for additional processing by subsequent flow - * rules. This is the default when a rule does not contain a - * terminating action, but can be specified to force a rule to - * become non-terminating. + * Leaves traffic up for additional processing by subsequent flow + * rules; makes a flow rule non-terminating. * * No associated configuration structure. */ RTE_FLOW_ACTION_TYPE_PASSTHRU, /** - * [META] - * * Attaches an integer value to packets and sets PKT_RX_FDIR and * PKT_RX_FDIR_ID mbuf flags. * @@ -923,8 +913,6 @@ enum rte_flow_action_type { RTE_FLOW_ACTION_TYPE_MARK, /** - * [META] - * * Flags packets. Similar to MARK without a specific value; only * sets the PKT_RX_FDIR mbuf flag. * @@ -949,9 +937,7 @@ enum rte_flow_action_type { RTE_FLOW_ACTION_TYPE_DROP, /** - * [META] - * - * Enables counters for this rule. + * Enables counters for this flow rule. * * These counters can be retrieved and reset through rte_flow_query(), * see struct rte_flow_query_count. @@ -1020,8 +1006,6 @@ struct rte_flow_action_mark { * RTE_FLOW_ACTION_TYPE_QUEUE * * Assign packets to a given queue index. - * - * Terminating by default. */ struct rte_flow_action_queue { uint16_t index; /**< Queue index to use. */ @@ -1050,8 +1034,6 @@ struct rte_flow_query_count { * Note: RSS hash result is stored in the hash.rss mbuf field which overlaps * hash.fdir.lo. Since the MARK action sets the hash.fdir.hi field only, * both can be requested simultaneously. - * - * Terminating by default. */ struct rte_flow_action_rss { const struct rte_eth_rss_conf *rss_conf; /**< RSS parameters. */ @@ -1069,8 +1051,6 @@ struct rte_flow_action_rss { * and is not guaranteed to work properly if the VF part is matched by a * prior flow rule or if packets are not addressed to a VF in the first * place. - * - * Terminating by default. */ struct rte_flow_action_vf { uint32_t original:1; /**< Use original VF ID if possible. */ @@ -1085,8 +1065,6 @@ struct rte_flow_action_vf { * * Packets matched by items of this type can be either dropped or passed to the * next item with their color set by the MTR object. - * - * Non-terminating by default. */ struct rte_flow_action_meter { uint32_t mtr_id; /**< MTR object ID created with rte_mtr_create(). */ @@ -1116,8 +1094,6 @@ struct rte_flow_action_meter { * direction. * * Multiple flows can be configured to use the same security session. - * - * Non-terminating by default. */ struct rte_flow_action_security { void *security_session; /**< Pointer to security session structure. */ -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [dpdk-dev] [PATCH v2 05/15] ethdev: alter behavior of flow API actions 2018-04-06 13:25 ` [dpdk-dev] [PATCH v2 05/15] ethdev: alter behavior of flow API actions Adrien Mazarguil @ 2018-04-06 15:06 ` Andrew Rybchenko 0 siblings, 0 replies; 157+ messages in thread From: Andrew Rybchenko @ 2018-04-06 15:06 UTC (permalink / raw) To: Adrien Mazarguil, Thomas Monjalon, Ferruh Yigit, dev Cc: Ajit Khaparde, Wenzhuo Lu, John Daley, Gaetan Rivet, Beilei Xing, Konstantin Ananyev, Nelio Laranjeiro, Pascal Mazon On 04/06/2018 04:25 PM, Adrien Mazarguil wrote: > This patch makes the following changes to flow rule actions: > > - List order now matters, they are redefined as performed first to last > instead of "all simultaneously". > > - Repeated actions are now supported (e.g. specifying QUEUE multiple times > now duplicates traffic among them). Previously only the last action of > any given kind was taken into account. > > - No more distinction between terminating/non-terminating/meta actions. > Flow rules themselves are now defined as always terminating unless a > PASSTHRU action is specified. > > These changes alter the behavior of flow rules in corner cases in order to > prepare the flow API for actions that modify traffic contents or properties > (e.g. encapsulation, compression) and for which order matter when combined. > > Previously one would have to so through multiple flow rules by combining > PASSTRHU with priority levels, however this proved overly complex to > implement at the PMD level, hence this simpler approach. > > This breaks ABI compatibility for the following public functions: > > - rte_flow_create() > - rte_flow_validate() > > PMDs with rte_flow support are modified accordingly: > > - bnxt: no change, implementation already forbids multiple actions and does > not support PASSTHRU. > > - e1000: no change, same as bnxt. > > - enic: modified to forbid redundant actions, no support for default drop. > > - failsafe: no change needed. > > - i40e: no change, implementation already forbids multiple actions. > > - ixgbe: same as i40e. > > - mlx4: modified to forbid multiple fate-deciding actions and drop when > unspecified. > > - mlx5: same as mlx4, with other redundant actions also forbidden. > > - sfc: same as mlx4. > > - tap: implementation already complies with the new behavior except for > the default pass-through modified as a default drop. > > Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> > Cc: Ajit Khaparde <ajit.khaparde@broadcom.com> > Cc: Wenzhuo Lu <wenzhuo.lu@intel.com> > Cc: John Daley <johndale@cisco.com> > Cc: Gaetan Rivet <gaetan.rivet@6wind.com> > Cc: Beilei Xing <beilei.xing@intel.com> > Cc: Konstantin Ananyev <konstantin.ananyev@intel.com> > Cc: Nelio Laranjeiro <nelio.laranjeiro@6wind.com> > Cc: Andrew Rybchenko <arybchenko@solarflare.com> > Cc: Pascal Mazon <pascal.mazon@6wind.com> > --- > doc/guides/prog_guide/rte_flow.rst | 67 +++++++++++++------------------- > drivers/net/enic/enic_flow.c | 25 ++++++++++++ > drivers/net/mlx4/mlx4_flow.c | 21 +++++++--- > drivers/net/mlx5/mlx5_flow.c | 69 ++++++++++++++------------------- > drivers/net/sfc/sfc_flow.c | 22 +++++++---- > drivers/net/tap/tap_flow.c | 11 ++++++ > lib/librte_ether/rte_flow.h | 54 +++++++------------------- > 7 files changed, 138 insertions(+), 131 deletions(-) sfc part Reviewed-by: Andrew Rybchenko <arybchenko@oktetlabs.ru> ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v2 06/15] ethdev: remove C99 flexible arrays from flow API 2018-04-06 13:25 ` [dpdk-dev] [PATCH v2 00/15] Flow API overhaul for switch offloads Adrien Mazarguil ` (4 preceding siblings ...) 2018-04-06 13:25 ` [dpdk-dev] [PATCH v2 05/15] ethdev: alter behavior of flow API actions Adrien Mazarguil @ 2018-04-06 13:25 ` Adrien Mazarguil 2018-04-06 13:25 ` [dpdk-dev] [PATCH v2 07/15] ethdev: flatten RSS configuration in " Adrien Mazarguil ` (9 subsequent siblings) 15 siblings, 0 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-06 13:25 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev This patch replaces C99-style flexible arrays in struct rte_flow_action_rss and struct rte_flow_item_raw with standard pointers to the same data. They proved difficult to use in the field (e.g. no possibility of static initialization) and unsuitable for C++ applications. Affected PMDs and examples are updated accordingly. This breaks ABI compatibility for the following public functions: - rte_flow_copy() - rte_flow_create() - rte_flow_query() - rte_flow_validate() Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> --- app/test-pmd/cmdline_flow.c | 119 +++++++++++++++++--------------- app/test-pmd/config.c | 25 ++++--- doc/guides/prog_guide/rte_flow.rst | 18 ++--- drivers/net/mlx4/mlx4_flow.c | 22 +++--- drivers/net/mlx5/mlx5_flow.c | 20 +++--- examples/ipsec-secgw/ipsec.c | 17 ++--- lib/librte_ether/rte_flow.c | 25 ++++--- lib/librte_ether/rte_flow.h | 8 ++- 8 files changed, 136 insertions(+), 118 deletions(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 9702b3ef3..16227e752 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -179,25 +179,22 @@ enum index { ACTION_METER_ID, }; -/** Size of pattern[] field in struct rte_flow_item_raw. */ -#define ITEM_RAW_PATTERN_SIZE 36 +/** Maximum size for pattern in struct rte_flow_item_raw. */ +#define ITEM_RAW_PATTERN_SIZE 40 /** Storage size for struct rte_flow_item_raw including pattern. */ #define ITEM_RAW_SIZE \ - (offsetof(struct rte_flow_item_raw, pattern) + ITEM_RAW_PATTERN_SIZE) + (sizeof(struct rte_flow_item_raw) + ITEM_RAW_PATTERN_SIZE) /** Maximum number of queue indices in struct rte_flow_action_rss. */ #define ACTION_RSS_QUEUE_NUM 32 /** Storage for struct rte_flow_action_rss including external data. */ -union action_rss_data { +struct action_rss_data { struct rte_flow_action_rss conf; - struct { - uint8_t conf_data[offsetof(struct rte_flow_action_rss, queue)]; - uint16_t queue[ACTION_RSS_QUEUE_NUM]; - struct rte_eth_rss_conf rss_conf; - uint8_t rss_key[RSS_HASH_KEY_LENGTH]; - } s; + uint16_t queue[ACTION_RSS_QUEUE_NUM]; + struct rte_eth_rss_conf rss_conf; + uint8_t rss_key[RSS_HASH_KEY_LENGTH]; }; /** Maximum number of subsequent tokens and arguments on the stack. */ @@ -320,13 +317,6 @@ struct token { .size = sizeof(*((s *)0)->f), \ }) -/** Static initializer for ARGS() with arbitrary size. */ -#define ARGS_ENTRY_USZ(s, f, sz) \ - (&(const struct arg){ \ - .offset = offsetof(s, f), \ - .size = (sz), \ - }) - /** Static initializer for ARGS() with arbitrary offset and size. */ #define ARGS_ENTRY_ARB(o, s) \ (&(const struct arg){ \ @@ -1105,9 +1095,9 @@ static const struct token token_list[] = { NEXT_ENTRY(ITEM_PARAM_IS, ITEM_PARAM_SPEC, ITEM_PARAM_MASK)), - .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, length), - ARGS_ENTRY_USZ(struct rte_flow_item_raw, - pattern, + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, pattern), + ARGS_ENTRY(struct rte_flow_item_raw, length), + ARGS_ENTRY_ARB(sizeof(struct rte_flow_item_raw), ITEM_RAW_PATTERN_SIZE)), }, [ITEM_ETH] = { @@ -1591,7 +1581,7 @@ static const struct token token_list[] = { [ACTION_RSS] = { .name = "rss", .help = "spread packets among several queues", - .priv = PRIV_ACTION(RSS, sizeof(union action_rss_data)), + .priv = PRIV_ACTION(RSS, sizeof(struct action_rss_data)), .next = NEXT(action_rss), .call = parse_vc_action_rss, }, @@ -1610,23 +1600,21 @@ static const struct token token_list[] = { .name = "key", .help = "RSS hash key", .next = NEXT(action_rss, NEXT_ENTRY(STRING)), - .args = ARGS(ARGS_ENTRY_ARB - (((uintptr_t)&((union action_rss_data *)0)-> - s.rss_conf.rss_key_len), + .args = ARGS(ARGS_ENTRY_ARB(0, 0), + ARGS_ENTRY_ARB + (offsetof(struct action_rss_data, rss_conf) + + offsetof(struct rte_eth_rss_conf, rss_key_len), sizeof(((struct rte_eth_rss_conf *)0)-> rss_key_len)), - ARGS_ENTRY_ARB - (((uintptr_t)((union action_rss_data *)0)-> - s.rss_key), - RSS_HASH_KEY_LENGTH)), + ARGS_ENTRY(struct action_rss_data, rss_key)), }, [ACTION_RSS_KEY_LEN] = { .name = "key_len", .help = "RSS hash key length in bytes", .next = NEXT(action_rss, NEXT_ENTRY(UNSIGNED)), .args = ARGS(ARGS_ENTRY_ARB_BOUNDED - (((uintptr_t)&((union action_rss_data *)0)-> - s.rss_conf.rss_key_len), + (offsetof(struct action_rss_data, rss_conf) + + offsetof(struct rte_eth_rss_conf, rss_key_len), sizeof(((struct rte_eth_rss_conf *)0)-> rss_key_len), 0, @@ -2067,7 +2055,7 @@ parse_vc_action_rss(struct context *ctx, const struct token *token, { struct buffer *out = buf; struct rte_flow_action *action; - union action_rss_data *action_rss_data; + struct action_rss_data *action_rss_data; unsigned int i; int ret; @@ -2085,31 +2073,31 @@ parse_vc_action_rss(struct context *ctx, const struct token *token, ctx->objmask = NULL; /* Set up default configuration. */ action_rss_data = ctx->object; - *action_rss_data = (union action_rss_data){ + *action_rss_data = (struct action_rss_data){ .conf = (struct rte_flow_action_rss){ - .rss_conf = &action_rss_data->s.rss_conf, + .rss_conf = &action_rss_data->rss_conf, .num = RTE_MIN(nb_rxq, ACTION_RSS_QUEUE_NUM), + .queue = action_rss_data->queue, }, + .queue = { 0 }, + .rss_conf = (struct rte_eth_rss_conf){ + .rss_key = action_rss_data->rss_key, + .rss_key_len = sizeof(action_rss_data->rss_key), + .rss_hf = rss_hf, + }, + .rss_key = "testpmd's default RSS hash key", }; - action_rss_data->s.rss_conf = (struct rte_eth_rss_conf){ - .rss_key = action_rss_data->s.rss_key, - .rss_key_len = sizeof(action_rss_data->s.rss_key), - .rss_hf = rss_hf, - }; - strncpy((void *)action_rss_data->s.rss_key, - "testpmd's default RSS hash key", - sizeof(action_rss_data->s.rss_key)); for (i = 0; i < action_rss_data->conf.num; ++i) - action_rss_data->conf.queue[i] = i; + action_rss_data->queue[i] = i; if (!port_id_is_invalid(ctx->port, DISABLED_WARN) && ctx->port != (portid_t)RTE_PORT_ALL) { if (rte_eth_dev_rss_hash_conf_get - (ctx->port, &action_rss_data->s.rss_conf) < 0) { + (ctx->port, &action_rss_data->rss_conf) < 0) { struct rte_eth_dev_info info; rte_eth_dev_info_get(ctx->port, &info); - action_rss_data->s.rss_conf.rss_key_len = - RTE_MIN(sizeof(action_rss_data->s.rss_key), + action_rss_data->rss_conf.rss_key_len = + RTE_MIN(sizeof(action_rss_data->rss_key), info.hash_key_size); } } @@ -2128,7 +2116,7 @@ parse_vc_action_rss_type(struct context *ctx, const struct token *token, void *buf, unsigned int size) { static const enum index next[] = NEXT_ENTRY(ACTION_RSS_TYPE); - union action_rss_data *action_rss_data; + struct action_rss_data *action_rss_data; unsigned int i; (void)token; @@ -2138,7 +2126,7 @@ parse_vc_action_rss_type(struct context *ctx, const struct token *token, return -1; if (!(ctx->objdata >> 16) && ctx->object) { action_rss_data = ctx->object; - action_rss_data->s.rss_conf.rss_hf = 0; + action_rss_data->rss_conf.rss_hf = 0; } if (!strcmp_partial("end", str, len)) { ctx->objdata &= 0xffff; @@ -2157,7 +2145,7 @@ parse_vc_action_rss_type(struct context *ctx, const struct token *token, if (!ctx->object) return len; action_rss_data = ctx->object; - action_rss_data->s.rss_conf.rss_hf |= rss_type_table[i].rss_type; + action_rss_data->rss_conf.rss_hf |= rss_type_table[i].rss_type; return len; } @@ -2172,7 +2160,7 @@ parse_vc_action_rss_queue(struct context *ctx, const struct token *token, void *buf, unsigned int size) { static const enum index next[] = NEXT_ENTRY(ACTION_RSS_QUEUE); - union action_rss_data *action_rss_data; + struct action_rss_data *action_rss_data; int ret; int i; @@ -2189,10 +2177,9 @@ parse_vc_action_rss_queue(struct context *ctx, const struct token *token, if (i >= ACTION_RSS_QUEUE_NUM) return -1; if (push_args(ctx, - ARGS_ENTRY_ARB(offsetof(struct rte_flow_action_rss, - queue) + - i * sizeof(action_rss_data->s.queue[i]), - sizeof(action_rss_data->s.queue[i])))) + ARGS_ENTRY_ARB(offsetof(struct action_rss_data, queue) + + i * sizeof(action_rss_data->queue[i]), + sizeof(action_rss_data->queue[i])))) return -1; ret = parse_int(ctx, token, str, len, NULL, 0); if (ret < 0) { @@ -2209,6 +2196,7 @@ parse_vc_action_rss_queue(struct context *ctx, const struct token *token, return len; action_rss_data = ctx->object; action_rss_data->conf.num = i; + action_rss_data->conf.queue = i ? action_rss_data->queue : NULL; return len; } @@ -2486,8 +2474,8 @@ parse_int(struct context *ctx, const struct token *token, /** * Parse a string. * - * Two arguments (ctx->args) are retrieved from the stack to store data and - * its length (in that order). + * Three arguments (ctx->args) are retrieved from the stack to store data, + * its actual length and address (in that order). */ static int parse_string(struct context *ctx, const struct token *token, @@ -2496,6 +2484,7 @@ parse_string(struct context *ctx, const struct token *token, { const struct arg *arg_data = pop_args(ctx); const struct arg *arg_len = pop_args(ctx); + const struct arg *arg_addr = pop_args(ctx); char tmp[16]; /* Ought to be enough. */ int ret; @@ -2506,6 +2495,11 @@ parse_string(struct context *ctx, const struct token *token, push_args(ctx, arg_data); return -1; } + if (!arg_addr) { + push_args(ctx, arg_len); + push_args(ctx, arg_data); + return -1; + } size = arg_data->size; /* Bit-mask fill is not supported. */ if (arg_data->mask || size < len) @@ -2528,8 +2522,23 @@ parse_string(struct context *ctx, const struct token *token, memset((uint8_t *)buf + len, 0x00, size - len); if (ctx->objmask) memset((uint8_t *)ctx->objmask + arg_data->offset, 0xff, len); + /* Save address if requested. */ + if (arg_addr->size) { + memcpy((uint8_t *)ctx->object + arg_addr->offset, + (void *[]){ + (uint8_t *)ctx->object + arg_data->offset + }, + arg_addr->size); + if (ctx->objmask) + memcpy((uint8_t *)ctx->objmask + arg_addr->offset, + (void *[]){ + (uint8_t *)ctx->objmask + arg_data->offset + }, + arg_addr->size); + } return len; error: + push_args(ctx, arg_addr); push_args(ctx, arg_len); push_args(ctx, arg_data); return -1; diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 8d42ea9a9..052163357 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -961,7 +961,7 @@ static const struct { MK_FLOW_ITEM(PF, 0), MK_FLOW_ITEM(VF, sizeof(struct rte_flow_item_vf)), MK_FLOW_ITEM(PORT, sizeof(struct rte_flow_item_port)), - MK_FLOW_ITEM(RAW, sizeof(struct rte_flow_item_raw)), /* +pattern[] */ + MK_FLOW_ITEM(RAW, sizeof(struct rte_flow_item_raw)), MK_FLOW_ITEM(ETH, sizeof(struct rte_flow_item_eth)), MK_FLOW_ITEM(VLAN, sizeof(struct rte_flow_item_vlan)), MK_FLOW_ITEM(IPV4, sizeof(struct rte_flow_item_ipv4)), @@ -1010,14 +1010,20 @@ flow_item_spec_copy(void *buf, const struct rte_flow_item *item, union { struct rte_flow_item_raw *raw; } dst; + size_t off; case RTE_FLOW_ITEM_TYPE_RAW: src.raw = item_spec; dst.raw = buf; - size = offsetof(struct rte_flow_item_raw, pattern) + - src.raw->length * sizeof(*src.raw->pattern); - if (dst.raw) - memcpy(dst.raw, src.raw, size); + off = RTE_ALIGN_CEIL(sizeof(struct rte_flow_item_raw), + sizeof(*src.raw->pattern)); + size = off + src.raw->length * sizeof(*src.raw->pattern); + if (dst.raw) { + memcpy(dst.raw, src.raw, sizeof(*src.raw)); + dst.raw->pattern = memcpy((uint8_t *)dst.raw + off, + src.raw->pattern, + size - off); + } break; default: size = flow_item[item->type].size; @@ -1049,7 +1055,7 @@ static const struct { MK_FLOW_ACTION(QUEUE, sizeof(struct rte_flow_action_queue)), MK_FLOW_ACTION(DROP, 0), MK_FLOW_ACTION(COUNT, 0), - MK_FLOW_ACTION(RSS, sizeof(struct rte_flow_action_rss)), /* +queue[] */ + MK_FLOW_ACTION(RSS, sizeof(struct rte_flow_action_rss)), MK_FLOW_ACTION(PF, 0), MK_FLOW_ACTION(VF, sizeof(struct rte_flow_action_vf)), MK_FLOW_ACTION(METER, sizeof(struct rte_flow_action_meter)), @@ -1080,11 +1086,14 @@ flow_action_conf_copy(void *buf, const struct rte_flow_action *action) *dst.rss = (struct rte_flow_action_rss){ .num = src.rss->num, }; - off += offsetof(struct rte_flow_action_rss, queue); + off += sizeof(*src.rss); if (src.rss->num) { + off = RTE_ALIGN_CEIL(off, sizeof(double)); size = sizeof(*src.rss->queue) * src.rss->num; if (dst.rss) - memcpy(dst.rss->queue, src.rss->queue, size); + dst.rss->queue = memcpy + ((void *)((uintptr_t)dst.rss + off), + src.rss->queue, size); off += size; } off = RTE_ALIGN_CEIL(off, sizeof(double)); diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 80360d068..acbeaacbd 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -1309,15 +1309,15 @@ field only, both can be requested simultaneously. .. table:: RSS - +--------------+------------------------------+ - | Field | Value | - +==============+==============================+ - | ``rss_conf`` | RSS parameters | - +--------------+------------------------------+ - | ``num`` | number of entries in queue[] | - +--------------+------------------------------+ - | ``queue[]`` | queue indices to use | - +--------------+------------------------------+ + +--------------+--------------------------------+ + | Field | Value | + +==============+================================+ + | ``rss_conf`` | RSS parameters | + +--------------+--------------------------------+ + | ``num`` | number of entries in ``queue`` | + +--------------+--------------------------------+ + | ``queue`` | queue indices to use | + +--------------+--------------------------------+ Action: ``PF`` ^^^^^^^^^^^^^^ diff --git a/drivers/net/mlx4/mlx4_flow.c b/drivers/net/mlx4/mlx4_flow.c index 582483076..5a1b7dedd 100644 --- a/drivers/net/mlx4/mlx4_flow.c +++ b/drivers/net/mlx4/mlx4_flow.c @@ -1282,14 +1282,16 @@ mlx4_flow_internal(struct priv *priv, struct rte_flow_error *error) */ uint32_t queues = rte_align32pow2(priv->dev->data->nb_rx_queues + 1) >> 1; - alignas(struct rte_flow_action_rss) uint8_t rss_conf_data - [offsetof(struct rte_flow_action_rss, queue) + - sizeof(((struct rte_flow_action_rss *)0)->queue[0]) * queues]; - struct rte_flow_action_rss *rss_conf = (void *)rss_conf_data; + uint16_t queue[queues]; + struct rte_flow_action_rss action_rss = { + .rss_conf = NULL, /* Rely on default fallback settings. */ + .num = queues, + .queue = queue, + }; struct rte_flow_action actions[] = { { .type = RTE_FLOW_ACTION_TYPE_RSS, - .conf = rss_conf, + .conf = &action_rss, }, { .type = RTE_FLOW_ACTION_TYPE_END, @@ -1311,12 +1313,8 @@ mlx4_flow_internal(struct priv *priv, struct rte_flow_error *error) if (!queues) goto error; /* Prepare default RSS configuration. */ - *rss_conf = (struct rte_flow_action_rss){ - .rss_conf = NULL, /* Rely on default fallback settings. */ - .num = queues, - }; for (i = 0; i != queues; ++i) - rss_conf->queue[i] = i; + queue[i] = i; /* * Set up VLAN item if filtering is enabled and at least one VLAN * filter is configured. @@ -1375,7 +1373,7 @@ mlx4_flow_internal(struct priv *priv, struct rte_flow_error *error) if (j != sizeof(mac->addr_bytes)) continue; if (flow->rss->queues != queues || - memcmp(flow->rss->queue_id, rss_conf->queue, + memcmp(flow->rss->queue_id, action_rss.queue, queues * sizeof(flow->rss->queue_id[0]))) continue; break; @@ -1415,7 +1413,7 @@ mlx4_flow_internal(struct priv *priv, struct rte_flow_error *error) if (flow && flow->internal) { assert(flow->rss); if (flow->rss->queues != queues || - memcmp(flow->rss->queue_id, rss_conf->queue, + memcmp(flow->rss->queue_id, action_rss.queue, queues * sizeof(flow->rss->queue_id[0]))) flow = NULL; } diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 84d6f9b92..a52dcf263 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -2446,9 +2446,16 @@ mlx5_ctrl_flow_vlan(struct rte_eth_dev *dev, .type = RTE_FLOW_ITEM_TYPE_END, }, }; + uint16_t queue[priv->reta_idx_n]; + struct rte_flow_action_rss action_rss = { + .rss_conf = &priv->rss_conf, + .num = priv->reta_idx_n, + .queue = queue, + }; struct rte_flow_action actions[] = { { .type = RTE_FLOW_ACTION_TYPE_RSS, + .conf = &action_rss, }, { .type = RTE_FLOW_ACTION_TYPE_END, @@ -2457,24 +2464,13 @@ mlx5_ctrl_flow_vlan(struct rte_eth_dev *dev, struct rte_flow *flow; struct rte_flow_error error; unsigned int i; - union { - struct rte_flow_action_rss rss; - struct { - const struct rte_eth_rss_conf *rss_conf; - uint16_t num; - uint16_t queue[RTE_MAX_QUEUES_PER_PORT]; - } local; - } action_rss; if (!priv->reta_idx_n) { rte_errno = EINVAL; return -rte_errno; } for (i = 0; i != priv->reta_idx_n; ++i) - action_rss.local.queue[i] = (*priv->reta_idx)[i]; - action_rss.local.rss_conf = &priv->rss_conf; - action_rss.local.num = priv->reta_idx_n; - actions[0].conf = (const void *)&action_rss.rss; + queue[i] = (*priv->reta_idx)[i]; flow = mlx5_flow_list_create(dev, &priv->ctrl_flows, &attr, items, actions, &error); if (!flow) diff --git a/examples/ipsec-secgw/ipsec.c b/examples/ipsec-secgw/ipsec.c index 5fb5bc16e..8b2047adb 100644 --- a/examples/ipsec-secgw/ipsec.c +++ b/examples/ipsec-secgw/ipsec.c @@ -186,14 +186,8 @@ create_session(struct ipsec_ctx *ipsec_ctx, struct ipsec_sa *sa) .rss_key_len = 40, }; struct rte_eth_dev *eth_dev; - union { - struct rte_flow_action_rss rss; - struct { - const struct rte_eth_rss_conf *rss_conf; - uint16_t num; - uint16_t queue[RTE_MAX_QUEUES_PER_PORT]; - } local; - } action_rss; + uint16_t queue[RTE_MAX_QUEUES_PER_PORT]; + struct rte_flow_action_rss action_rss; unsigned int i; unsigned int j; @@ -207,9 +201,10 @@ create_session(struct ipsec_ctx *ipsec_ctx, struct ipsec_sa *sa) for (i = 0, j = 0; i < eth_dev->data->nb_rx_queues; ++i) if (eth_dev->data->rx_queues[i]) - action_rss.local.queue[j++] = i; - action_rss.local.num = j; - action_rss.local.rss_conf = &rss_conf; + queue[j++] = i; + action_rss.rss_conf = &rss_conf; + action_rss.num = j; + action_rss.queue = queue; ret = rte_flow_validate(sa->portid, &sa->attr, sa->pattern, sa->action, &err); diff --git a/lib/librte_ether/rte_flow.c b/lib/librte_ether/rte_flow.c index db04c4f94..550086411 100644 --- a/lib/librte_ether/rte_flow.c +++ b/lib/librte_ether/rte_flow.c @@ -39,7 +39,7 @@ static const struct rte_flow_desc_data rte_flow_desc_item[] = { MK_FLOW_ITEM(PF, 0), MK_FLOW_ITEM(VF, sizeof(struct rte_flow_item_vf)), MK_FLOW_ITEM(PORT, sizeof(struct rte_flow_item_port)), - MK_FLOW_ITEM(RAW, sizeof(struct rte_flow_item_raw)), /* +pattern[] */ + MK_FLOW_ITEM(RAW, sizeof(struct rte_flow_item_raw)), MK_FLOW_ITEM(ETH, sizeof(struct rte_flow_item_eth)), MK_FLOW_ITEM(VLAN, sizeof(struct rte_flow_item_vlan)), MK_FLOW_ITEM(IPV4, sizeof(struct rte_flow_item_ipv4)), @@ -73,7 +73,7 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = { MK_FLOW_ACTION(QUEUE, sizeof(struct rte_flow_action_queue)), MK_FLOW_ACTION(DROP, 0), MK_FLOW_ACTION(COUNT, 0), - MK_FLOW_ACTION(RSS, sizeof(struct rte_flow_action_rss)), /* +queue[] */ + MK_FLOW_ACTION(RSS, sizeof(struct rte_flow_action_rss)), MK_FLOW_ACTION(PF, 0), MK_FLOW_ACTION(VF, sizeof(struct rte_flow_action_vf)), }; @@ -282,14 +282,20 @@ flow_item_spec_copy(void *buf, const struct rte_flow_item *item, union { struct rte_flow_item_raw *raw; } dst; + size_t off; case RTE_FLOW_ITEM_TYPE_RAW: src.raw = item_spec; dst.raw = buf; - size = offsetof(struct rte_flow_item_raw, pattern) + - src.raw->length * sizeof(*src.raw->pattern); - if (dst.raw) - memcpy(dst.raw, src.raw, size); + off = RTE_ALIGN_CEIL(sizeof(struct rte_flow_item_raw), + sizeof(*src.raw->pattern)); + size = off + src.raw->length * sizeof(*src.raw->pattern); + if (dst.raw) { + memcpy(dst.raw, src.raw, sizeof(*src.raw)); + dst.raw->pattern = memcpy((uint8_t *)dst.raw + off, + src.raw->pattern, + size - off); + } break; default: size = rte_flow_desc_item[item->type].size; @@ -326,11 +332,14 @@ flow_action_conf_copy(void *buf, const struct rte_flow_action *action) *dst.rss = (struct rte_flow_action_rss){ .num = src.rss->num, }; - off += offsetof(struct rte_flow_action_rss, queue); + off += sizeof(*src.rss); if (src.rss->num) { + off = RTE_ALIGN_CEIL(off, sizeof(double)); size = sizeof(*src.rss->queue) * src.rss->num; if (dst.rss) - memcpy(dst.rss->queue, src.rss->queue, size); + dst.rss->queue = memcpy + ((void *)((uintptr_t)dst.rss + off), + src.rss->queue, size); off += size; } off = RTE_ALIGN_CEIL(off, sizeof(double)); diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index af9b14a4d..895feb1a3 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -14,6 +14,7 @@ * associated actions in hardware through flow rules. */ +#include <stddef.h> #include <stdint.h> #include <rte_arp.h> @@ -432,7 +433,7 @@ struct rte_flow_item_raw { int32_t offset; /**< Absolute or relative offset for pattern. */ uint16_t limit; /**< Search area limit for start of pattern. */ uint16_t length; /**< Pattern length. */ - uint8_t pattern[]; /**< Byte string to look for. */ + const uint8_t *pattern; /**< Byte string to look for. */ }; /** Default mask for RTE_FLOW_ITEM_TYPE_RAW. */ @@ -444,6 +445,7 @@ static const struct rte_flow_item_raw rte_flow_item_raw_mask = { .offset = 0xffffffff, .limit = 0xffff, .length = 0xffff, + .pattern = NULL, }; #endif @@ -1037,8 +1039,8 @@ struct rte_flow_query_count { */ struct rte_flow_action_rss { const struct rte_eth_rss_conf *rss_conf; /**< RSS parameters. */ - uint16_t num; /**< Number of entries in queue[]. */ - uint16_t queue[]; /**< Queues indices to use. */ + uint16_t num; /**< Number of entries in @p queue. */ + const uint16_t *queue; /**< Queue indices to use. */ }; /** -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v2 07/15] ethdev: flatten RSS configuration in flow API 2018-04-06 13:25 ` [dpdk-dev] [PATCH v2 00/15] Flow API overhaul for switch offloads Adrien Mazarguil ` (5 preceding siblings ...) 2018-04-06 13:25 ` [dpdk-dev] [PATCH v2 06/15] ethdev: remove C99 flexible arrays from flow API Adrien Mazarguil @ 2018-04-06 13:25 ` Adrien Mazarguil 2018-04-07 9:05 ` Andrew Rybchenko 2018-04-06 13:25 ` [dpdk-dev] [PATCH v2 08/15] ethdev: add hash function to RSS flow API action Adrien Mazarguil ` (8 subsequent siblings) 15 siblings, 1 reply; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-06 13:25 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev Cc: Xueming Li, Wenzhuo Lu, Jingjing Wu, Beilei Xing, Qi Zhang, Konstantin Ananyev, Nelio Laranjeiro, Yongseok Koh, Andrew Rybchenko, Pascal Mazon, Radu Nicolau, Akhil Goyal Since its inception, the rte_flow RSS action has been relying in part on external struct rte_eth_rss_conf for compatibility with the legacy RSS API. This structure lacks parameters such as the hash algorithm to use, and more recently, a method to tell which layer RSS should be performed on [1]. Given struct rte_eth_rss_conf will never be flexible enough to represent a complete RSS configuration (e.g. RETA table), this patch supersedes it by extending the rte_flow RSS action directly. A subsequent patch will add a field to use a non-default RSS hash algorithm. To that end, a field named "types" replaces the field formerly known as "rss_hf" and standing for "RSS hash functions" as it was confusing. Actual RSS hash function types are defined by enum rte_eth_hash_function. This patch updates all PMDs and example applications accordingly. It breaks ABI compatibility for the following public functions: - rte_flow_copy() - rte_flow_create() - rte_flow_query() - rte_flow_validate() [1] commit 676b605182a5 ("doc: announce ethdev API change for RSS configuration") Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Cc: Xueming Li <xuemingl@mellanox.com> Cc: Ferruh Yigit <ferruh.yigit@intel.com> Cc: Thomas Monjalon <thomas@monjalon.net> Cc: Wenzhuo Lu <wenzhuo.lu@intel.com> Cc: Jingjing Wu <jingjing.wu@intel.com> Cc: Beilei Xing <beilei.xing@intel.com> Cc: Qi Zhang <qi.z.zhang@intel.com> Cc: Konstantin Ananyev <konstantin.ananyev@intel.com> Cc: Nelio Laranjeiro <nelio.laranjeiro@6wind.com> Cc: Yongseok Koh <yskoh@mellanox.com> Cc: Andrew Rybchenko <arybchenko@solarflare.com> Cc: Pascal Mazon <pascal.mazon@6wind.com> Cc: Radu Nicolau <radu.nicolau@intel.com> Cc: Akhil Goyal <akhil.goyal@nxp.com> --- app/test-pmd/cmdline_flow.c | 59 +++++----- app/test-pmd/config.c | 39 +++---- doc/guides/prog_guide/rte_flow.rst | 22 ++-- drivers/net/e1000/e1000_ethdev.h | 13 ++- drivers/net/e1000/igb_ethdev.c | 4 +- drivers/net/e1000/igb_flow.c | 31 ++--- drivers/net/e1000/igb_rxtx.c | 51 +++++++-- drivers/net/i40e/i40e_ethdev.c | 53 +++++++-- drivers/net/i40e/i40e_ethdev.h | 15 ++- drivers/net/i40e/i40e_flow.c | 47 ++++---- drivers/net/ixgbe/ixgbe_ethdev.c | 4 +- drivers/net/ixgbe/ixgbe_ethdev.h | 13 ++- drivers/net/ixgbe/ixgbe_flow.c | 30 ++--- drivers/net/ixgbe/ixgbe_rxtx.c | 51 +++++++-- drivers/net/mlx4/mlx4.c | 2 +- drivers/net/mlx4/mlx4_flow.c | 61 +++++----- drivers/net/mlx4/mlx4_flow.h | 2 +- drivers/net/mlx4/mlx4_rxq.c | 2 +- drivers/net/mlx4/mlx4_rxtx.h | 2 +- drivers/net/mlx5/mlx5_flow.c | 193 +++++++++++++++----------------- drivers/net/mlx5/mlx5_rxq.c | 22 ++-- drivers/net/mlx5/mlx5_rxtx.h | 26 +++-- drivers/net/sfc/sfc_flow.c | 21 ++-- drivers/net/tap/tap_flow.c | 8 +- examples/ipsec-secgw/ipsec.c | 10 +- lib/librte_ether/rte_flow.c | 39 +++---- lib/librte_ether/rte_flow.h | 6 +- 27 files changed, 473 insertions(+), 353 deletions(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 16227e752..0322f36c4 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -192,9 +192,8 @@ enum index { /** Storage for struct rte_flow_action_rss including external data. */ struct action_rss_data { struct rte_flow_action_rss conf; + uint8_t key[RSS_HASH_KEY_LENGTH]; uint16_t queue[ACTION_RSS_QUEUE_NUM]; - struct rte_eth_rss_conf rss_conf; - uint8_t rss_key[RSS_HASH_KEY_LENGTH]; }; /** Maximum number of subsequent tokens and arguments on the stack. */ @@ -1602,21 +1601,21 @@ static const struct token token_list[] = { .next = NEXT(action_rss, NEXT_ENTRY(STRING)), .args = ARGS(ARGS_ENTRY_ARB(0, 0), ARGS_ENTRY_ARB - (offsetof(struct action_rss_data, rss_conf) + - offsetof(struct rte_eth_rss_conf, rss_key_len), - sizeof(((struct rte_eth_rss_conf *)0)-> - rss_key_len)), - ARGS_ENTRY(struct action_rss_data, rss_key)), + (offsetof(struct action_rss_data, conf) + + offsetof(struct rte_flow_action_rss, key_len), + sizeof(((struct rte_flow_action_rss *)0)-> + key_len)), + ARGS_ENTRY(struct action_rss_data, key)), }, [ACTION_RSS_KEY_LEN] = { .name = "key_len", .help = "RSS hash key length in bytes", .next = NEXT(action_rss, NEXT_ENTRY(UNSIGNED)), .args = ARGS(ARGS_ENTRY_ARB_BOUNDED - (offsetof(struct action_rss_data, rss_conf) + - offsetof(struct rte_eth_rss_conf, rss_key_len), - sizeof(((struct rte_eth_rss_conf *)0)-> - rss_key_len), + (offsetof(struct action_rss_data, conf) + + offsetof(struct rte_flow_action_rss, key_len), + sizeof(((struct rte_flow_action_rss *)0)-> + key_len), 0, RSS_HASH_KEY_LENGTH)), }, @@ -2075,30 +2074,36 @@ parse_vc_action_rss(struct context *ctx, const struct token *token, action_rss_data = ctx->object; *action_rss_data = (struct action_rss_data){ .conf = (struct rte_flow_action_rss){ - .rss_conf = &action_rss_data->rss_conf, - .num = RTE_MIN(nb_rxq, ACTION_RSS_QUEUE_NUM), + .types = rss_hf, + .key_len = sizeof(action_rss_data->key), + .queue_num = RTE_MIN(nb_rxq, ACTION_RSS_QUEUE_NUM), + .key = action_rss_data->key, .queue = action_rss_data->queue, }, + .key = "testpmd's default RSS hash key", .queue = { 0 }, - .rss_conf = (struct rte_eth_rss_conf){ - .rss_key = action_rss_data->rss_key, - .rss_key_len = sizeof(action_rss_data->rss_key), - .rss_hf = rss_hf, - }, - .rss_key = "testpmd's default RSS hash key", }; - for (i = 0; i < action_rss_data->conf.num; ++i) + for (i = 0; i < action_rss_data->conf.queue_num; ++i) action_rss_data->queue[i] = i; if (!port_id_is_invalid(ctx->port, DISABLED_WARN) && ctx->port != (portid_t)RTE_PORT_ALL) { - if (rte_eth_dev_rss_hash_conf_get - (ctx->port, &action_rss_data->rss_conf) < 0) { + struct rte_eth_rss_conf rss_conf = { + .rss_key = action_rss_data->key, + .rss_key_len = sizeof(action_rss_data->key), + }; + + if (rte_eth_dev_rss_hash_conf_get(ctx->port, &rss_conf) < 0) { struct rte_eth_dev_info info; rte_eth_dev_info_get(ctx->port, &info); - action_rss_data->rss_conf.rss_key_len = - RTE_MIN(sizeof(action_rss_data->rss_key), + action_rss_data->conf.key_len = + RTE_MIN(sizeof(action_rss_data->key), info.hash_key_size); + } else { + action_rss_data->conf.types = rss_conf.rss_hf; + action_rss_data->conf.key_len = + RTE_MIN(sizeof(action_rss_data->key), + rss_conf.rss_key_len); } } action->conf = &action_rss_data->conf; @@ -2126,7 +2131,7 @@ parse_vc_action_rss_type(struct context *ctx, const struct token *token, return -1; if (!(ctx->objdata >> 16) && ctx->object) { action_rss_data = ctx->object; - action_rss_data->rss_conf.rss_hf = 0; + action_rss_data->conf.types = 0; } if (!strcmp_partial("end", str, len)) { ctx->objdata &= 0xffff; @@ -2145,7 +2150,7 @@ parse_vc_action_rss_type(struct context *ctx, const struct token *token, if (!ctx->object) return len; action_rss_data = ctx->object; - action_rss_data->rss_conf.rss_hf |= rss_type_table[i].rss_type; + action_rss_data->conf.types |= rss_type_table[i].rss_type; return len; } @@ -2195,7 +2200,7 @@ parse_vc_action_rss_queue(struct context *ctx, const struct token *token, if (!ctx->object) return len; action_rss_data = ctx->object; - action_rss_data->conf.num = i; + action_rss_data->conf.queue_num = i; action_rss_data->conf.queue = i ? action_rss_data->queue : NULL; return len; } diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 052163357..717f31774 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -1084,40 +1084,27 @@ flow_action_conf_copy(void *buf, const struct rte_flow_action *action) off = 0; if (dst.rss) *dst.rss = (struct rte_flow_action_rss){ - .num = src.rss->num, + .types = src.rss->types, + .key_len = src.rss->key_len, + .queue_num = src.rss->queue_num, }; off += sizeof(*src.rss); - if (src.rss->num) { + if (src.rss->key_len) { off = RTE_ALIGN_CEIL(off, sizeof(double)); - size = sizeof(*src.rss->queue) * src.rss->num; + size = sizeof(*src.rss->key) * src.rss->key_len; if (dst.rss) - dst.rss->queue = memcpy + dst.rss->key = memcpy ((void *)((uintptr_t)dst.rss + off), - src.rss->queue, size); + src.rss->key, size); off += size; } - off = RTE_ALIGN_CEIL(off, sizeof(double)); - if (dst.rss) { - dst.rss->rss_conf = (void *)((uintptr_t)dst.rss + off); - *(struct rte_eth_rss_conf *)(uintptr_t) - dst.rss->rss_conf = (struct rte_eth_rss_conf){ - .rss_key_len = src.rss->rss_conf->rss_key_len, - .rss_hf = src.rss->rss_conf->rss_hf, - }; - } - off += sizeof(*src.rss->rss_conf); - if (src.rss->rss_conf->rss_key_len) { + if (src.rss->queue_num) { off = RTE_ALIGN_CEIL(off, sizeof(double)); - size = sizeof(*src.rss->rss_conf->rss_key) * - src.rss->rss_conf->rss_key_len; - if (dst.rss) { - ((struct rte_eth_rss_conf *)(uintptr_t) - dst.rss->rss_conf)->rss_key = - (void *)((uintptr_t)dst.rss + off); - memcpy(dst.rss->rss_conf->rss_key, - src.rss->rss_conf->rss_key, - size); - } + size = sizeof(*src.rss->queue) * src.rss->queue_num; + if (dst.rss) + dst.rss->queue = memcpy + ((void *)((uintptr_t)dst.rss + off), + src.rss->queue, size); off += size; } size = off; diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index acbeaacbd..5ce041d91 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -1309,15 +1309,19 @@ field only, both can be requested simultaneously. .. table:: RSS - +--------------+--------------------------------+ - | Field | Value | - +==============+================================+ - | ``rss_conf`` | RSS parameters | - +--------------+--------------------------------+ - | ``num`` | number of entries in ``queue`` | - +--------------+--------------------------------+ - | ``queue`` | queue indices to use | - +--------------+--------------------------------+ + +---------------+------------------------------------+ + | Field | Value | + +===============+====================================+ + | ``types`` | RSS hash types (see ``ETH_RSS_*``) | + +---------------+------------------------------------+ + | ``key_len`` | hash key length in bytes | + +---------------+------------------------------------+ + | ``queue_num`` | number of entries in ``queue`` | + +---------------+------------------------------------+ + | ``key`` | hash key | + +---------------+------------------------------------+ + | ``queue`` | queue indices to use | + +---------------+------------------------------------+ Action: ``PF`` ^^^^^^^^^^^^^^ diff --git a/drivers/net/e1000/e1000_ethdev.h b/drivers/net/e1000/e1000_ethdev.h index 6354b894a..902001f36 100644 --- a/drivers/net/e1000/e1000_ethdev.h +++ b/drivers/net/e1000/e1000_ethdev.h @@ -4,6 +4,10 @@ #ifndef _E1000_ETHDEV_H_ #define _E1000_ETHDEV_H_ + +#include <stdint.h> + +#include <rte_flow.h> #include <rte_time.h> #include <rte_pci.h> @@ -27,6 +31,7 @@ #define E1000_CTRL_EXT_EXTEND_VLAN (1<<26) /* EXTENDED VLAN */ #define IGB_VFTA_SIZE 128 +#define IGB_HKEY_MAX_INDEX 10 #define IGB_MAX_RX_QUEUE_NUM 8 #define IGB_MAX_RX_QUEUE_NUM_82576 16 @@ -229,8 +234,8 @@ struct igb_ethertype_filter { }; struct igb_rte_flow_rss_conf { - struct rte_eth_rss_conf rss_conf; /**< RSS parameters. */ - uint16_t num; /**< Number of entries in queue[]. */ + struct rte_flow_action_rss conf; /**< RSS parameters. */ + uint8_t key[IGB_HKEY_MAX_INDEX * sizeof(uint32_t)]; /* Hash key. */ uint16_t queue[IGB_MAX_RX_QUEUE_NUM]; /**< Queues indices to use. */ }; @@ -501,6 +506,10 @@ int eth_igb_syn_filter_set(struct rte_eth_dev *dev, int eth_igb_add_del_flex_filter(struct rte_eth_dev *dev, struct rte_eth_flex_filter *filter, bool add); +int igb_rss_conf_init(struct igb_rte_flow_rss_conf *out, + const struct rte_flow_action_rss *in); +int igb_action_rss_same(const struct rte_flow_action_rss *comp, + const struct rte_flow_action_rss *with); int igb_config_rss_filter(struct rte_eth_dev *dev, struct igb_rte_flow_rss_conf *conf, bool add); diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c index 8d4226676..7a431ac33 100644 --- a/drivers/net/e1000/igb_ethdev.c +++ b/drivers/net/e1000/igb_ethdev.c @@ -41,8 +41,6 @@ #define IGB_DEFAULT_TX_HTHRESH 1 #define IGB_DEFAULT_TX_WTHRESH ((hw->mac.type == e1000_82576) ? 1 : 16) -#define IGB_HKEY_MAX_INDEX 10 - /* Bit shift and mask */ #define IGB_4_BIT_WIDTH (CHAR_BIT / 2) #define IGB_4_BIT_MASK RTE_LEN2MASK(IGB_4_BIT_WIDTH, uint8_t) @@ -5576,7 +5574,7 @@ igb_rss_filter_restore(struct rte_eth_dev *dev) struct e1000_filter_info *filter_info = E1000_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private); - if (filter_info->rss_info.num) + if (filter_info->rss_info.conf.queue_num) igb_config_rss_filter(dev, &filter_info->rss_info, TRUE); } diff --git a/drivers/net/e1000/igb_flow.c b/drivers/net/e1000/igb_flow.c index c0f5b5190..8dc5f75f2 100644 --- a/drivers/net/e1000/igb_flow.c +++ b/drivers/net/e1000/igb_flow.c @@ -1292,7 +1292,7 @@ igb_parse_rss_filter(struct rte_eth_dev *dev, rss = (const struct rte_flow_action_rss *)act->conf; - if (!rss || !rss->num) { + if (!rss || !rss->queue_num) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, act, @@ -1300,7 +1300,7 @@ igb_parse_rss_filter(struct rte_eth_dev *dev, return -rte_errno; } - for (n = 0; n < rss->num; n++) { + for (n = 0; n < rss->queue_num; n++) { if (rss->queue[n] >= dev->data->nb_rx_queues) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, @@ -1310,14 +1310,18 @@ igb_parse_rss_filter(struct rte_eth_dev *dev, } } - if (rss->rss_conf) - rss_conf->rss_conf = *rss->rss_conf; - else - rss_conf->rss_conf.rss_hf = IGB_RSS_OFFLOAD_ALL; - - for (n = 0; n < rss->num; ++n) - rss_conf->queue[n] = rss->queue[n]; - rss_conf->num = rss->num; + if (rss->key_len && rss->key_len != RTE_DIM(rss_conf->key)) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, + "RSS hash key must be exactly 40 bytes"); + if (rss->queue_num > RTE_DIM(rss_conf->queue)) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, + "too many queues for RSS context"); + if (igb_rss_conf_init(rss_conf, rss)) + return rte_flow_error_set + (error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, act, + "RSS context initialization failure"); /* check if the next not void item is END */ index++; @@ -1518,9 +1522,8 @@ igb_flow_create(struct rte_eth_dev *dev, PMD_DRV_LOG(ERR, "failed to allocate memory"); goto out; } - rte_memcpy(&rss_filter_ptr->filter_info, - &rss_conf, - sizeof(struct igb_rte_flow_rss_conf)); + igb_rss_conf_init(&rss_filter_ptr->filter_info, + &rss_conf.conf); TAILQ_INSERT_TAIL(&igb_filter_rss_list, rss_filter_ptr, entries); flow->rule = rss_filter_ptr; @@ -1757,7 +1760,7 @@ igb_clear_rss_filter(struct rte_eth_dev *dev) struct e1000_filter_info *filter = E1000_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private); - if (filter->rss_info.num) + if (filter->rss_info.conf.queue_num) igb_config_rss_filter(dev, &filter->rss_info, FALSE); } diff --git a/drivers/net/e1000/igb_rxtx.c b/drivers/net/e1000/igb_rxtx.c index 323913f0d..45bb3455c 100644 --- a/drivers/net/e1000/igb_rxtx.c +++ b/drivers/net/e1000/igb_rxtx.c @@ -2898,12 +2898,47 @@ igb_txq_info_get(struct rte_eth_dev *dev, uint16_t queue_id, } int +igb_rss_conf_init(struct igb_rte_flow_rss_conf *out, + const struct rte_flow_action_rss *in) +{ + if (in->key_len > RTE_DIM(out->key) || + in->queue_num > RTE_DIM(out->queue)) + return -EINVAL; + out->conf = (struct rte_flow_action_rss){ + .types = in->types, + .key_len = in->key_len, + .queue_num = in->queue_num, + .key = memcpy(out->key, in->key, in->key_len), + .queue = memcpy(out->queue, in->queue, + sizeof(*in->queue) * in->queue_num), + }; + return 0; +} + +int +igb_action_rss_same(const struct rte_flow_action_rss *comp, + const struct rte_flow_action_rss *with) +{ + return (comp->types == with->types && + comp->key_len == with->key_len && + comp->queue_num == with->queue_num && + !memcmp(comp->key, with->key, with->key_len) && + !memcmp(comp->queue, with->queue, + sizeof(*with->queue) * with->queue_num)); +} + +int igb_config_rss_filter(struct rte_eth_dev *dev, struct igb_rte_flow_rss_conf *conf, bool add) { uint32_t shift; uint16_t i, j; - struct rte_eth_rss_conf rss_conf = conf->rss_conf; + struct rte_eth_rss_conf rss_conf = { + .rss_key = conf->conf.key_len ? + (void *)(uintptr_t)conf->conf.key : NULL, + .rss_key_len = conf->conf.key_len, + .rss_hf = conf->conf.types, + }; struct e1000_filter_info *filter_info = E1000_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private); struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private); @@ -2911,8 +2946,8 @@ igb_config_rss_filter(struct rte_eth_dev *dev, hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private); if (!add) { - if (memcmp(conf, &filter_info->rss_info, - sizeof(struct igb_rte_flow_rss_conf)) == 0) { + if (igb_action_rss_same(&filter_info->rss_info.conf, + &conf->conf)) { igb_rss_disable(dev); memset(&filter_info->rss_info, 0, sizeof(struct igb_rte_flow_rss_conf)); @@ -2921,7 +2956,7 @@ igb_config_rss_filter(struct rte_eth_dev *dev, return -EINVAL; } - if (filter_info->rss_info.num) + if (filter_info->rss_info.conf.queue_num) return -EINVAL; /* Fill in redirection table. */ @@ -2933,9 +2968,9 @@ igb_config_rss_filter(struct rte_eth_dev *dev, } reta; uint8_t q_idx; - if (j == conf->num) + if (j == conf->conf.queue_num) j = 0; - q_idx = conf->queue[j]; + q_idx = conf->conf.queue[j]; reta.bytes[i & 3] = (uint8_t)(q_idx << shift); if ((i & 3) == 3) E1000_WRITE_REG(hw, E1000_RETA(i >> 2), reta.dword); @@ -2952,8 +2987,8 @@ igb_config_rss_filter(struct rte_eth_dev *dev, rss_conf.rss_key = rss_intel_key; /* Default hash key */ igb_hw_rss_hash_set(hw, &rss_conf); - rte_memcpy(&filter_info->rss_info, - conf, sizeof(struct igb_rte_flow_rss_conf)); + if (igb_rss_conf_init(&filter_info->rss_info, &conf->conf)) + return -EINVAL; return 0; } diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index 6e06f8a2b..0242b5d59 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c @@ -11,6 +11,7 @@ #include <inttypes.h> #include <assert.h> +#include <rte_common.h> #include <rte_eal.h> #include <rte_string_fns.h> #include <rte_pci.h> @@ -11467,7 +11468,7 @@ i40e_rss_filter_restore(struct i40e_pf *pf) { struct i40e_rte_flow_rss_conf *conf = &pf->rss_info; - if (conf->num) + if (conf->conf.queue_num) i40e_config_rss_filter(pf, conf, TRUE); } @@ -11966,18 +11967,52 @@ i40e_cloud_filter_qinq_create(struct i40e_pf *pf) } int +i40e_rss_conf_init(struct i40e_rte_flow_rss_conf *out, + const struct rte_flow_action_rss *in) +{ + if (in->key_len > RTE_DIM(out->key) || + in->queue_num > RTE_DIM(out->queue)) + return -EINVAL; + out->conf = (struct rte_flow_action_rss){ + .types = in->types, + .key_len = in->key_len, + .queue_num = in->queue_num, + .key = memcpy(out->key, in->key, in->key_len), + .queue = memcpy(out->queue, in->queue, + sizeof(*in->queue) * in->queue_num), + }; + return 0; +} + +int +i40e_action_rss_same(const struct rte_flow_action_rss *comp, + const struct rte_flow_action_rss *with) +{ + return (comp->types == with->types && + comp->key_len == with->key_len && + comp->queue_num == with->queue_num && + !memcmp(comp->key, with->key, with->key_len) && + !memcmp(comp->queue, with->queue, + sizeof(*with->queue) * with->queue_num)); +} + +int i40e_config_rss_filter(struct i40e_pf *pf, struct i40e_rte_flow_rss_conf *conf, bool add) { struct i40e_hw *hw = I40E_PF_TO_HW(pf); uint32_t i, lut = 0; uint16_t j, num; - struct rte_eth_rss_conf rss_conf = conf->rss_conf; + struct rte_eth_rss_conf rss_conf = { + .rss_key = conf->conf.key_len ? + (void *)(uintptr_t)conf->conf.key : NULL, + .rss_key_len = conf->conf.key_len, + .rss_hf = conf->conf.types, + }; struct i40e_rte_flow_rss_conf *rss_info = &pf->rss_info; if (!add) { - if (memcmp(conf, rss_info, - sizeof(struct i40e_rte_flow_rss_conf)) == 0) { + if (i40e_action_rss_same(&rss_info->conf, &conf->conf)) { i40e_pf_disable_rss(pf); memset(rss_info, 0, sizeof(struct i40e_rte_flow_rss_conf)); @@ -11986,7 +12021,7 @@ i40e_config_rss_filter(struct i40e_pf *pf, return -EINVAL; } - if (rss_info->num) + if (rss_info->conf.queue_num) return -EINVAL; /* If both VMDQ and RSS enabled, not all of PF queues are configured. @@ -11997,7 +12032,7 @@ i40e_config_rss_filter(struct i40e_pf *pf, else num = pf->dev_data->nb_rx_queues; - num = RTE_MIN(num, conf->num); + num = RTE_MIN(num, conf->conf.queue_num); PMD_DRV_LOG(INFO, "Max of contiguous %u PF queues are configured", num); @@ -12010,7 +12045,7 @@ i40e_config_rss_filter(struct i40e_pf *pf, for (i = 0, j = 0; i < hw->func_caps.rss_table_size; i++, j++) { if (j == num) j = 0; - lut = (lut << 8) | (conf->queue[j] & ((0x1 << + lut = (lut << 8) | (conf->conf.queue[j] & ((0x1 << hw->func_caps.rss_table_entry_width) - 1)); if ((i & 3) == 3) I40E_WRITE_REG(hw, I40E_PFQF_HLUT(i >> 2), lut); @@ -12035,8 +12070,8 @@ i40e_config_rss_filter(struct i40e_pf *pf, i40e_hw_rss_hash_set(pf, &rss_conf); - rte_memcpy(rss_info, - conf, sizeof(struct i40e_rte_flow_rss_conf)); + if (i40e_rss_conf_init(rss_info, &conf->conf)) + return -EINVAL; return 0; } diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h index 151ed1a8c..5c02b37a0 100644 --- a/drivers/net/i40e/i40e_ethdev.h +++ b/drivers/net/i40e/i40e_ethdev.h @@ -5,13 +5,18 @@ #ifndef _I40E_ETHDEV_H_ #define _I40E_ETHDEV_H_ +#include <stdint.h> + #include <rte_eth_ctrl.h> #include <rte_time.h> #include <rte_kvargs.h> #include <rte_hash.h> +#include <rte_flow.h> #include <rte_flow_driver.h> #include <rte_tm_driver.h> +#include "base/i40e_register.h" + #define I40E_VLAN_TAG_SIZE 4 #define I40E_AQ_LEN 32 @@ -877,9 +882,11 @@ struct i40e_customized_pctype { }; struct i40e_rte_flow_rss_conf { - struct rte_eth_rss_conf rss_conf; /**< RSS parameters. */ + struct rte_flow_action_rss conf; /**< RSS parameters. */ uint16_t queue_region_conf; /**< Queue region config flag */ - uint16_t num; /**< Number of entries in queue[]. */ + uint8_t key[(I40E_VFQF_HKEY_MAX_INDEX > I40E_PFQF_HKEY_MAX_INDEX ? + I40E_VFQF_HKEY_MAX_INDEX : I40E_PFQF_HKEY_MAX_INDEX) + 1 * + sizeof(uint32_t)]; /* Hash key. */ uint16_t queue[I40E_MAX_Q_PER_TC]; /**< Queues indices to use. */ }; @@ -1217,6 +1224,10 @@ void i40e_init_queue_region_conf(struct rte_eth_dev *dev); void i40e_flex_payload_reg_set_default(struct i40e_hw *hw); int i40e_set_rss_key(struct i40e_vsi *vsi, uint8_t *key, uint8_t key_len); int i40e_set_rss_lut(struct i40e_vsi *vsi, uint8_t *lut, uint16_t lut_size); +int i40e_rss_conf_init(struct i40e_rte_flow_rss_conf *out, + const struct rte_flow_action_rss *in); +int i40e_action_rss_same(const struct rte_flow_action_rss *comp, + const struct rte_flow_action_rss *with); int i40e_config_rss_filter(struct i40e_pf *pf, struct i40e_rte_flow_rss_conf *conf, bool add); diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c index 79e05c2cc..1c09f8121 100644 --- a/drivers/net/i40e/i40e_flow.c +++ b/drivers/net/i40e/i40e_flow.c @@ -4207,7 +4207,7 @@ i40e_flow_parse_rss_action(struct rte_eth_dev *dev, if (action_flag) { for (n = 0; n < 64; n++) { - if (rss->rss_conf->rss_hf & (hf_bit << n)) { + if (rss->types & (hf_bit << n)) { conf_info->region[0].hw_flowtype[0] = n; conf_info->region[0].flowtype_num = 1; conf_info->queue_region_number = 1; @@ -4219,8 +4219,8 @@ i40e_flow_parse_rss_action(struct rte_eth_dev *dev, for (n = 0; n < conf_info->queue_region_number; n++) { if (conf_info->region[n].user_priority_num || conf_info->region[n].flowtype_num) { - if (!((rte_is_power_of_2(rss->num)) && - rss->num <= 64)) { + if (!((rte_is_power_of_2(rss->queue_num)) && + rss->queue_num <= 64)) { PMD_DRV_LOG(ERR, "The region sizes should be any of the following values: 1, 2, 4, 8, 16, 32, 64 as long as the " "total number of queues do not exceed the VSI allocation"); return -rte_errno; @@ -4238,10 +4238,11 @@ i40e_flow_parse_rss_action(struct rte_eth_dev *dev, return -rte_errno; } - if (rss_info->num < rss->num || - rss_info->queue[0] < rss->queue[0] || - (rss->queue[0] + rss->num > - rss_info->num + rss_info->queue[0])) { + if (rss_info->conf.queue_num < rss->queue_num || + rss_info->conf.queue[0] < rss->queue[0] || + (rss->queue[0] + rss->queue_num > + rss_info->conf.queue_num + + rss_info->queue[0])) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, act, @@ -4250,7 +4251,8 @@ i40e_flow_parse_rss_action(struct rte_eth_dev *dev, } for (i = 0; i < info->queue_region_number; i++) { - if (info->region[i].queue_num == rss->num && + if (info->region[i].queue_num == + rss->queue_num && info->region[i].queue_start_index == rss->queue[0]) break; @@ -4263,7 +4265,7 @@ i40e_flow_parse_rss_action(struct rte_eth_dev *dev, } info->region[i].queue_num = - rss->num; + rss->queue_num; info->region[i].queue_start_index = rss->queue[0]; info->region[i].region_id = @@ -4306,7 +4308,7 @@ i40e_flow_parse_rss_action(struct rte_eth_dev *dev, if (rss_config->queue_region_conf) return 0; - if (!rss || !rss->num) { + if (!rss || !rss->queue_num) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, act, @@ -4314,7 +4316,7 @@ i40e_flow_parse_rss_action(struct rte_eth_dev *dev, return -rte_errno; } - for (n = 0; n < rss->num; n++) { + for (n = 0; n < rss->queue_num; n++) { if (rss->queue[n] >= dev->data->nb_rx_queues) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, @@ -4323,15 +4325,20 @@ i40e_flow_parse_rss_action(struct rte_eth_dev *dev, return -rte_errno; } } - if (rss->rss_conf) - rss_config->rss_conf = *rss->rss_conf; - else - rss_config->rss_conf.rss_hf = - pf->adapter->flow_types_mask; - for (n = 0; n < rss->num; ++n) - rss_config->queue[n] = rss->queue[n]; - rss_config->num = rss->num; + if (rss->key_len && rss->key_len > RTE_DIM(rss_config->key)) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, + "RSS hash key too large"); + if (rss->queue_num > RTE_DIM(rss_config->queue)) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, + "too many queues for RSS context"); + if (i40e_rss_conf_init(rss_config, rss)) + return rte_flow_error_set + (error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, act, + "RSS context initialization failure"); + index++; /* check if the next not void action is END */ @@ -4851,7 +4858,7 @@ i40e_flow_flush_rss_filter(struct rte_eth_dev *dev) ret = i40e_flush_queue_region_all_conf(dev, hw, pf, 0); - if (rss_info->num) + if (rss_info->conf.queue_num) ret = i40e_config_rss_filter(pf, rss_info, FALSE); return ret; } diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c index fbc048f7d..227f4c342 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.c +++ b/drivers/net/ixgbe/ixgbe_ethdev.c @@ -100,8 +100,6 @@ #define IXGBE_QUEUE_STAT_COUNTERS (sizeof(hw_stats->qprc) / sizeof(hw_stats->qprc[0])) -#define IXGBE_HKEY_MAX_INDEX 10 - /* Additional timesync values. */ #define NSEC_PER_SEC 1000000000L #define IXGBE_INCVAL_10GB 0x66666666 @@ -8272,7 +8270,7 @@ ixgbe_rss_filter_restore(struct rte_eth_dev *dev) struct ixgbe_filter_info *filter_info = IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private); - if (filter_info->rss_info.num) + if (filter_info->rss_info.conf.queue_num) ixgbe_config_rss_filter(dev, &filter_info->rss_info, TRUE); } diff --git a/drivers/net/ixgbe/ixgbe_ethdev.h b/drivers/net/ixgbe/ixgbe_ethdev.h index 655077700..9491b03f4 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.h +++ b/drivers/net/ixgbe/ixgbe_ethdev.h @@ -4,6 +4,9 @@ #ifndef _IXGBE_ETHDEV_H_ #define _IXGBE_ETHDEV_H_ + +#include <stdint.h> + #include "base/ixgbe_type.h" #include "base/ixgbe_dcb.h" #include "base/ixgbe_dcb_82599.h" @@ -12,6 +15,7 @@ #ifdef RTE_LIBRTE_SECURITY #include "ixgbe_ipsec.h" #endif +#include <rte_flow.h> #include <rte_time.h> #include <rte_hash.h> #include <rte_pci.h> @@ -39,6 +43,7 @@ #define IXGBE_EXTENDED_VLAN (uint32_t)(1 << 26) /* EXTENDED VLAN ENABLE */ #define IXGBE_VFTA_SIZE 128 #define IXGBE_VLAN_TAG_SIZE 4 +#define IXGBE_HKEY_MAX_INDEX 10 #define IXGBE_MAX_RX_QUEUE_NUM 128 #define IXGBE_MAX_INTR_QUEUE_NUM 15 #define IXGBE_VMDQ_DCB_NB_QUEUES IXGBE_MAX_RX_QUEUE_NUM @@ -196,8 +201,8 @@ struct ixgbe_hw_fdir_info { }; struct ixgbe_rte_flow_rss_conf { - struct rte_eth_rss_conf rss_conf; /**< RSS parameters. */ - uint16_t num; /**< Number of entries in queue[]. */ + struct rte_flow_action_rss conf; /**< RSS parameters. */ + uint8_t key[IXGBE_HKEY_MAX_INDEX * sizeof(uint32_t)]; /* Hash key. */ uint16_t queue[IXGBE_MAX_RX_QUEUE_NUM]; /**< Queues indices to use. */ }; @@ -696,6 +701,10 @@ void ixgbe_tm_conf_init(struct rte_eth_dev *dev); void ixgbe_tm_conf_uninit(struct rte_eth_dev *dev); int ixgbe_set_queue_rate_limit(struct rte_eth_dev *dev, uint16_t queue_idx, uint16_t tx_rate); +int ixgbe_rss_conf_init(struct ixgbe_rte_flow_rss_conf *out, + const struct rte_flow_action_rss *in); +int ixgbe_action_rss_same(const struct rte_flow_action_rss *comp, + const struct rte_flow_action_rss *with); int ixgbe_config_rss_filter(struct rte_eth_dev *dev, struct ixgbe_rte_flow_rss_conf *conf, bool add); diff --git a/drivers/net/ixgbe/ixgbe_flow.c b/drivers/net/ixgbe/ixgbe_flow.c index abdeac28b..4e31c7c56 100644 --- a/drivers/net/ixgbe/ixgbe_flow.c +++ b/drivers/net/ixgbe/ixgbe_flow.c @@ -2761,7 +2761,7 @@ ixgbe_parse_rss_filter(struct rte_eth_dev *dev, rss = (const struct rte_flow_action_rss *)act->conf; - if (!rss || !rss->num) { + if (!rss || !rss->queue_num) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, act, @@ -2769,7 +2769,7 @@ ixgbe_parse_rss_filter(struct rte_eth_dev *dev, return -rte_errno; } - for (n = 0; n < rss->num; n++) { + for (n = 0; n < rss->queue_num; n++) { if (rss->queue[n] >= dev->data->nb_rx_queues) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, @@ -2778,14 +2778,19 @@ ixgbe_parse_rss_filter(struct rte_eth_dev *dev, return -rte_errno; } } - if (rss->rss_conf) - rss_conf->rss_conf = *rss->rss_conf; - else - rss_conf->rss_conf.rss_hf = IXGBE_RSS_OFFLOAD_ALL; - for (n = 0; n < rss->num; ++n) - rss_conf->queue[n] = rss->queue[n]; - rss_conf->num = rss->num; + if (rss->key_len && rss->key_len != RTE_DIM(rss_conf->key)) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, + "RSS hash key must be exactly 40 bytes"); + if (rss->queue_num > RTE_DIM(rss_conf->queue)) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, + "too many queues for RSS context"); + if (ixgbe_rss_conf_init(rss_conf, rss)) + return rte_flow_error_set + (error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, act, + "RSS context initialization failure"); /* check if the next not void item is END */ act = next_no_void_action(actions, act); @@ -2834,7 +2839,7 @@ ixgbe_clear_rss_filter(struct rte_eth_dev *dev) struct ixgbe_filter_info *filter_info = IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private); - if (filter_info->rss_info.num) + if (filter_info->rss_info.conf.queue_num) ixgbe_config_rss_filter(dev, &filter_info->rss_info, FALSE); } @@ -3153,9 +3158,8 @@ ixgbe_flow_create(struct rte_eth_dev *dev, PMD_DRV_LOG(ERR, "failed to allocate memory"); goto out; } - rte_memcpy(&rss_filter_ptr->filter_info, - &rss_conf, - sizeof(struct ixgbe_rte_flow_rss_conf)); + ixgbe_rss_conf_init(&rss_filter_ptr->filter_info, + &rss_conf.conf); TAILQ_INSERT_TAIL(&filter_rss_list, rss_filter_ptr, entries); flow->rule = rss_filter_ptr; diff --git a/drivers/net/ixgbe/ixgbe_rxtx.c b/drivers/net/ixgbe/ixgbe_rxtx.c index 7511e183f..94ea7444d 100644 --- a/drivers/net/ixgbe/ixgbe_rxtx.c +++ b/drivers/net/ixgbe/ixgbe_rxtx.c @@ -5675,6 +5675,36 @@ ixgbevf_dev_rxtx_start(struct rte_eth_dev *dev) } int +ixgbe_rss_conf_init(struct ixgbe_rte_flow_rss_conf *out, + const struct rte_flow_action_rss *in) +{ + if (in->key_len > RTE_DIM(out->key) || + in->queue_num > RTE_DIM(out->queue)) + return -EINVAL; + out->conf = (struct rte_flow_action_rss){ + .types = in->types, + .key_len = in->key_len, + .queue_num = in->queue_num, + .key = memcpy(out->key, in->key, in->key_len), + .queue = memcpy(out->queue, in->queue, + sizeof(*in->queue) * in->queue_num), + }; + return 0; +} + +int +ixgbe_action_rss_same(const struct rte_flow_action_rss *comp, + const struct rte_flow_action_rss *with) +{ + return (comp->types == with->types && + comp->key_len == with->key_len && + comp->queue_num == with->queue_num && + !memcmp(comp->key, with->key, with->key_len) && + !memcmp(comp->queue, with->queue, + sizeof(*with->queue) * with->queue_num)); +} + +int ixgbe_config_rss_filter(struct rte_eth_dev *dev, struct ixgbe_rte_flow_rss_conf *conf, bool add) { @@ -5684,7 +5714,12 @@ ixgbe_config_rss_filter(struct rte_eth_dev *dev, uint16_t j; uint16_t sp_reta_size; uint32_t reta_reg; - struct rte_eth_rss_conf rss_conf = conf->rss_conf; + struct rte_eth_rss_conf rss_conf = { + .rss_key = conf->conf.key_len ? + (void *)(uintptr_t)conf->conf.key : NULL, + .rss_key_len = conf->conf.key_len, + .rss_hf = conf->conf.types, + }; struct ixgbe_filter_info *filter_info = IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private); @@ -5694,8 +5729,8 @@ ixgbe_config_rss_filter(struct rte_eth_dev *dev, sp_reta_size = ixgbe_reta_size_get(hw->mac.type); if (!add) { - if (memcmp(conf, &filter_info->rss_info, - sizeof(struct ixgbe_rte_flow_rss_conf)) == 0) { + if (ixgbe_action_rss_same(&filter_info->rss_info.conf, + &conf->conf)) { ixgbe_rss_disable(dev); memset(&filter_info->rss_info, 0, sizeof(struct ixgbe_rte_flow_rss_conf)); @@ -5704,7 +5739,7 @@ ixgbe_config_rss_filter(struct rte_eth_dev *dev, return -EINVAL; } - if (filter_info->rss_info.num) + if (filter_info->rss_info.conf.queue_num) return -EINVAL; /* Fill in redirection table * The byte-swap is needed because NIC registers are in @@ -5714,9 +5749,9 @@ ixgbe_config_rss_filter(struct rte_eth_dev *dev, for (i = 0, j = 0; i < sp_reta_size; i++, j++) { reta_reg = ixgbe_reta_reg_get(hw->mac.type, i); - if (j == conf->num) + if (j == conf->conf.queue_num) j = 0; - reta = (reta << 8) | conf->queue[j]; + reta = (reta << 8) | conf->conf.queue[j]; if ((i & 3) == 3) IXGBE_WRITE_REG(hw, reta_reg, rte_bswap32(reta)); @@ -5733,8 +5768,8 @@ ixgbe_config_rss_filter(struct rte_eth_dev *dev, rss_conf.rss_key = rss_intel_key; /* Default hash key */ ixgbe_hw_rss_hash_set(hw, &rss_conf); - rte_memcpy(&filter_info->rss_info, - conf, sizeof(struct ixgbe_rte_flow_rss_conf)); + if (ixgbe_rss_conf_init(&filter_info->rss_info, &conf->conf)) + return -EINVAL; return 0; } diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c index fb8a8b848..c7854bead 100644 --- a/drivers/net/mlx4/mlx4.c +++ b/drivers/net/mlx4/mlx4.c @@ -569,7 +569,7 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev) " for UDP RSS and inner VXLAN RSS"); /* Fake support for all possible RSS hash fields. */ priv->hw_rss_sup = ~UINT64_C(0); - priv->hw_rss_sup = mlx4_conv_rss_hf(priv, -1); + priv->hw_rss_sup = mlx4_conv_rss_types(priv, -1); /* Filter out known unsupported fields. */ priv->hw_rss_sup &= ~(uint64_t)(IBV_RX_HASH_SRC_PORT_UDP | diff --git a/drivers/net/mlx4/mlx4_flow.c b/drivers/net/mlx4/mlx4_flow.c index 5a1b7dedd..4dbcaa39c 100644 --- a/drivers/net/mlx4/mlx4_flow.c +++ b/drivers/net/mlx4/mlx4_flow.c @@ -76,22 +76,22 @@ struct mlx4_drop { }; /** - * Convert DPDK RSS hash fields to their Verbs equivalent. + * Convert DPDK RSS hash types to their Verbs equivalent. * - * This function returns the supported (default) set when @p rss_hf has + * This function returns the supported (default) set when @p types has * special value (uint64_t)-1. * * @param priv * Pointer to private structure. - * @param rss_hf - * Hash fields in DPDK format (see struct rte_eth_rss_conf). + * @param types + * Hash types in DPDK format (see struct rte_eth_rss_conf). * * @return * A valid Verbs RSS hash fields mask for mlx4 on success, (uint64_t)-1 * otherwise and rte_errno is set. */ uint64_t -mlx4_conv_rss_hf(struct priv *priv, uint64_t rss_hf) +mlx4_conv_rss_types(struct priv *priv, uint64_t types) { enum { IPV4, IPV6, TCP, UDP, }; const uint64_t in[] = { @@ -126,17 +126,17 @@ mlx4_conv_rss_hf(struct priv *priv, uint64_t rss_hf) unsigned int i; for (i = 0; i != RTE_DIM(in); ++i) - if (rss_hf & in[i]) { - seen |= rss_hf & in[i]; + if (types & in[i]) { + seen |= types & in[i]; conv |= out[i]; } if ((conv & priv->hw_rss_sup) == conv) { - if (rss_hf == (uint64_t)-1) { + if (types == (uint64_t)-1) { /* Include inner RSS by default if supported. */ conv |= priv->hw_rss_sup & IBV_RX_HASH_INNER; return conv; } - if (!(rss_hf & ~seen)) + if (!(types & ~seen)) return conv; } rte_errno = ENOTSUP; @@ -717,7 +717,8 @@ mlx4_flow_prepare(struct priv *priv, switch (action->type) { const struct rte_flow_action_queue *queue; const struct rte_flow_action_rss *rss; - const struct rte_eth_rss_conf *rss_conf; + const uint8_t *rss_key; + uint32_t rss_key_len; uint64_t fields; unsigned int i; @@ -747,58 +748,56 @@ mlx4_flow_prepare(struct priv *priv, break; rss = action->conf; /* Default RSS configuration if none is provided. */ - rss_conf = - rss->rss_conf ? - rss->rss_conf : - &(struct rte_eth_rss_conf){ - .rss_key = mlx4_rss_hash_key_default, - .rss_key_len = MLX4_RSS_HASH_KEY_SIZE, - .rss_hf = -1, - }; + if (rss->key_len) { + rss_key = rss->key; + rss_key_len = rss->key_len; + } else { + rss_key = mlx4_rss_hash_key_default; + rss_key_len = MLX4_RSS_HASH_KEY_SIZE; + } /* Sanity checks. */ - for (i = 0; i < rss->num; ++i) + for (i = 0; i < rss->queue_num; ++i) if (rss->queue[i] >= priv->dev->data->nb_rx_queues) break; - if (i != rss->num) { + if (i != rss->queue_num) { msg = "queue index target beyond number of" " configured Rx queues"; goto exit_action_not_supported; } - if (!rte_is_power_of_2(rss->num)) { + if (!rte_is_power_of_2(rss->queue_num)) { msg = "for RSS, mlx4 requires the number of" " queues to be a power of two"; goto exit_action_not_supported; } - if (rss_conf->rss_key_len != - sizeof(flow->rss->key)) { + if (rss_key_len != sizeof(flow->rss->key)) { msg = "mlx4 supports exactly one RSS hash key" " length: " MLX4_STR_EXPAND(MLX4_RSS_HASH_KEY_SIZE); goto exit_action_not_supported; } - for (i = 1; i < rss->num; ++i) + for (i = 1; i < rss->queue_num; ++i) if (rss->queue[i] - rss->queue[i - 1] != 1) break; - if (i != rss->num) { + if (i != rss->queue_num) { msg = "mlx4 requires RSS contexts to use" " consecutive queue indices only"; goto exit_action_not_supported; } - if (rss->queue[0] % rss->num) { + if (rss->queue[0] % rss->queue_num) { msg = "mlx4 requires the first queue of a RSS" " context to be aligned on a multiple" " of the context size"; goto exit_action_not_supported; } rte_errno = 0; - fields = mlx4_conv_rss_hf(priv, rss_conf->rss_hf); + fields = mlx4_conv_rss_types(priv, rss->types); if (fields == (uint64_t)-1 && rte_errno) { msg = "unsupported RSS hash type requested"; goto exit_action_not_supported; } flow->rss = mlx4_rss_get - (priv, fields, rss_conf->rss_key, rss->num, + (priv, fields, rss_key, rss->queue_num, rss->queue); if (!flow->rss) { msg = "either invalid parameters or not enough" @@ -1284,8 +1283,10 @@ mlx4_flow_internal(struct priv *priv, struct rte_flow_error *error) rte_align32pow2(priv->dev->data->nb_rx_queues + 1) >> 1; uint16_t queue[queues]; struct rte_flow_action_rss action_rss = { - .rss_conf = NULL, /* Rely on default fallback settings. */ - .num = queues, + .types = -1, + .key_len = MLX4_RSS_HASH_KEY_SIZE, + .queue_num = queues, + .key = mlx4_rss_hash_key_default, .queue = queue, }; struct rte_flow_action actions[] = { diff --git a/drivers/net/mlx4/mlx4_flow.h b/drivers/net/mlx4/mlx4_flow.h index 00188a65c..f71078ecc 100644 --- a/drivers/net/mlx4/mlx4_flow.h +++ b/drivers/net/mlx4/mlx4_flow.h @@ -47,7 +47,7 @@ struct rte_flow { /* mlx4_flow.c */ -uint64_t mlx4_conv_rss_hf(struct priv *priv, uint64_t rss_hf); +uint64_t mlx4_conv_rss_types(struct priv *priv, uint64_t rss_hf); int mlx4_flow_sync(struct priv *priv, struct rte_flow_error *error); void mlx4_flow_clean(struct priv *priv); int mlx4_filter_ctrl(struct rte_eth_dev *dev, diff --git a/drivers/net/mlx4/mlx4_rxq.c b/drivers/net/mlx4/mlx4_rxq.c index 7a036ed83..474614e4d 100644 --- a/drivers/net/mlx4/mlx4_rxq.c +++ b/drivers/net/mlx4/mlx4_rxq.c @@ -88,7 +88,7 @@ mlx4_rss_hash_key_default[MLX4_RSS_HASH_KEY_SIZE] = { */ struct mlx4_rss * mlx4_rss_get(struct priv *priv, uint64_t fields, - uint8_t key[MLX4_RSS_HASH_KEY_SIZE], + const uint8_t key[MLX4_RSS_HASH_KEY_SIZE], uint16_t queues, const uint16_t queue_id[]) { struct mlx4_rss *rss; diff --git a/drivers/net/mlx4/mlx4_rxtx.h b/drivers/net/mlx4/mlx4_rxtx.h index dd46ac006..521267724 100644 --- a/drivers/net/mlx4/mlx4_rxtx.h +++ b/drivers/net/mlx4/mlx4_rxtx.h @@ -126,7 +126,7 @@ uint8_t mlx4_rss_hash_key_default[MLX4_RSS_HASH_KEY_SIZE]; int mlx4_rss_init(struct priv *priv); void mlx4_rss_deinit(struct priv *priv); struct mlx4_rss *mlx4_rss_get(struct priv *priv, uint64_t fields, - uint8_t key[MLX4_RSS_HASH_KEY_SIZE], + const uint8_t key[MLX4_RSS_HASH_KEY_SIZE], uint16_t queues, const uint16_t queue_id[]); void mlx4_rss_put(struct mlx4_rss *rss); int mlx4_rss_attach(struct mlx4_rss *rss); diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index a52dcf263..7798052f9 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -214,9 +214,8 @@ struct rte_flow { TAILQ_ENTRY(rte_flow) next; /**< Pointer to the next flow structure. */ uint32_t mark:1; /**< Set if the flow is marked. */ uint32_t drop:1; /**< Drop queue. */ - uint16_t queues_n; /**< Number of entries in queue[]. */ + struct rte_flow_action_rss rss_conf; /**< RSS configuration */ uint16_t (*queues)[]; /**< Queues indexes to use. */ - struct rte_eth_rss_conf rss_conf; /**< RSS configuration */ uint8_t rss_key[40]; /**< copy of the RSS key. */ struct ibv_counter_set *cs; /**< Holds the counters for the rule. */ struct mlx5_flow_counter_stats counter_stats;/**<The counter stats. */ @@ -406,9 +405,8 @@ struct mlx5_flow_parse { uint32_t mark:1; /**< Mark is present in the flow. */ uint32_t count:1; /**< Count is present in the flow. */ uint32_t mark_id; /**< Mark identifier. */ + struct rte_flow_action_rss rss_conf; /**< RSS configuration */ uint16_t queues[RTE_MAX_QUEUES_PER_PORT]; /**< Queues indexes to use. */ - uint16_t queues_n; /**< Number of entries in queue[]. */ - struct rte_eth_rss_conf rss_conf; /**< RSS configuration */ uint8_t rss_key[40]; /**< copy of the RSS key. */ enum hash_rxq_type layer; /**< Last pattern layer detected. */ struct ibv_counter_set *cs; /**< Holds the counter set for the rule */ @@ -532,47 +530,6 @@ mlx5_flow_item_validate(const struct rte_flow_item *item, } /** - * Copy the RSS configuration from the user ones, of the rss_conf is null, - * uses the driver one. - * - * @param parser - * Internal parser structure. - * @param rss_conf - * User RSS configuration to save. - * - * @return - * 0 on success, a negative errno value otherwise and rte_errno is set. - */ -static int -mlx5_flow_convert_rss_conf(struct mlx5_flow_parse *parser, - const struct rte_eth_rss_conf *rss_conf) -{ - /* - * This function is also called at the beginning of - * mlx5_flow_convert_actions() to initialize the parser with the - * device default RSS configuration. - */ - if (rss_conf) { - if (rss_conf->rss_hf & MLX5_RSS_HF_MASK) { - rte_errno = EINVAL; - return -rte_errno; - } - if (rss_conf->rss_key_len != 40) { - rte_errno = EINVAL; - return -rte_errno; - } - if (rss_conf->rss_key_len && rss_conf->rss_key) { - parser->rss_conf.rss_key_len = rss_conf->rss_key_len; - memcpy(parser->rss_key, rss_conf->rss_key, - rss_conf->rss_key_len); - parser->rss_conf.rss_key = parser->rss_key; - } - parser->rss_conf.rss_hf = rss_conf->rss_hf; - } - return 0; -} - -/** * Extract attribute to the parser. * * @param[in] attr @@ -642,17 +599,7 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, enum { FATE = 1, MARK = 2, COUNT = 4, }; uint32_t overlap = 0; struct priv *priv = dev->data->dev_private; - int ret; - /* - * Add default RSS configuration necessary for Verbs to create QP even - * if no RSS is necessary. - */ - ret = mlx5_flow_convert_rss_conf(parser, - (const struct rte_eth_rss_conf *) - &priv->rss_conf); - if (ret) - return ret; for (; actions->type != RTE_FLOW_ACTION_TYPE_END; ++actions) { if (actions->type == RTE_FLOW_ACTION_TYPE_VOID) { continue; @@ -671,25 +618,53 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, overlap |= FATE; if (!queue || (queue->index > (priv->rxqs_n - 1))) goto exit_action_not_supported; - parser->queues_n = 1; parser->queues[0] = queue->index; + parser->rss_conf = (struct rte_flow_action_rss){ + .queue_num = 1, + .queue = parser->queues, + }; } else if (actions->type == RTE_FLOW_ACTION_TYPE_RSS) { const struct rte_flow_action_rss *rss = (const struct rte_flow_action_rss *) actions->conf; + const uint8_t *rss_key; + uint32_t rss_key_len; uint16_t n; if (overlap & FATE) goto exit_action_overlap; overlap |= FATE; - if (!rss || !rss->num) { + if (rss->types & MLX5_RSS_HF_MASK) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION, + actions, + "unsupported RSS type" + " requested"); + return -rte_errno; + } + if (rss->key_len) { + rss_key_len = rss->key_len; + rss_key = rss->key; + } else { + rss_key_len = rss_hash_default_key_len; + rss_key = rss_hash_default_key; + } + if (rss_key_len != RTE_DIM(parser->rss_key)) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION, + actions, + "RSS hash key must be" + " exactly 40 bytes long"); + return -rte_errno; + } + if (!rss->queue_num) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, actions, "no valid queues"); return -rte_errno; } - if (rss->num > RTE_DIM(parser->queues)) { + if (rss->queue_num > RTE_DIM(parser->queues)) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, actions, @@ -697,7 +672,7 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, " context"); return -rte_errno; } - for (n = 0; n < rss->num; ++n) { + for (n = 0; n < rss->queue_num; ++n) { if (rss->queue[n] >= priv->rxqs_n) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, @@ -707,16 +682,16 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, return -rte_errno; } } - for (n = 0; n < rss->num; ++n) - parser->queues[n] = rss->queue[n]; - parser->queues_n = rss->num; - if (mlx5_flow_convert_rss_conf(parser, rss->rss_conf)) { - rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ACTION, - actions, - "wrong RSS configuration"); - return -rte_errno; - } + parser->rss_conf = (struct rte_flow_action_rss){ + .types = rss->types, + .key_len = rss_key_len, + .queue_num = rss->queue_num, + .key = memcpy(parser->rss_key, rss_key, + sizeof(*rss_key) * rss_key_len), + .queue = memcpy(parser->queues, rss->queue, + sizeof(*rss->queue) * + rss->queue_num), + }; } else if (actions->type == RTE_FLOW_ACTION_TYPE_MARK) { const struct rte_flow_action_mark *mark = (const struct rte_flow_action_mark *) @@ -761,7 +736,7 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, parser->drop = 1; if (parser->drop && parser->mark) parser->mark = 0; - if (!parser->queues_n && !parser->drop) { + if (!parser->rss_conf.queue_num && !parser->drop) { rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_HANDLE, NULL, "no valid action"); return -rte_errno; @@ -941,7 +916,7 @@ mlx5_flow_convert_finalise(struct mlx5_flow_parse *parser) unsigned int i; /* Remove any other flow not matching the pattern. */ - if (parser->queues_n == 1 && !parser->rss_conf.rss_hf) { + if (parser->rss_conf.queue_num == 1 && !parser->rss_conf.types) { for (i = 0; i != hash_rxq_init_n; ++i) { if (i == HASH_RXQ_ETH) continue; @@ -969,7 +944,7 @@ mlx5_flow_convert_finalise(struct mlx5_flow_parse *parser) } /* Remove impossible flow according to the RSS configuration. */ if (hash_rxq_init[parser->layer].dpdk_rss_hf & - parser->rss_conf.rss_hf) { + parser->rss_conf.types) { /* Remove any other flow. */ for (i = hmin; i != (hmax + 1); ++i) { if ((i == parser->layer) || @@ -980,7 +955,7 @@ mlx5_flow_convert_finalise(struct mlx5_flow_parse *parser) } } else if (!parser->queue[ip].ibv_attr) { /* no RSS possible with the current configuration. */ - parser->queues_n = 1; + parser->rss_conf.queue_num = 1; return; } fill: @@ -1109,7 +1084,7 @@ mlx5_flow_convert(struct rte_eth_dev *dev, for (i = 0; i != hash_rxq_init_n; ++i) { unsigned int offset; - if (!(parser->rss_conf.rss_hf & + if (!(parser->rss_conf.types & hash_rxq_init[i].dpdk_rss_hf) && (i != HASH_RXQ_ETH)) continue; @@ -1777,20 +1752,20 @@ mlx5_flow_create_action_queue_rss(struct rte_eth_dev *dev, continue; flow->frxq[i].hrxq = mlx5_hrxq_get(dev, - parser->rss_conf.rss_key, - parser->rss_conf.rss_key_len, + parser->rss_conf.key, + parser->rss_conf.key_len, hash_fields, - parser->queues, - parser->queues_n); + parser->rss_conf.queue, + parser->rss_conf.queue_num); if (flow->frxq[i].hrxq) continue; flow->frxq[i].hrxq = mlx5_hrxq_new(dev, - parser->rss_conf.rss_key, - parser->rss_conf.rss_key_len, + parser->rss_conf.key, + parser->rss_conf.key_len, hash_fields, - parser->queues, - parser->queues_n); + parser->rss_conf.queue, + parser->rss_conf.queue_num); if (!flow->frxq[i].hrxq) { return rte_flow_error_set(error, ENOMEM, RTE_FLOW_ERROR_TYPE_HANDLE, @@ -1861,9 +1836,9 @@ mlx5_flow_create_action_queue(struct rte_eth_dev *dev, NULL, "internal error in flow creation"); goto error; } - for (i = 0; i != parser->queues_n; ++i) { + for (i = 0; i != parser->rss_conf.queue_num; ++i) { struct mlx5_rxq_data *q = - (*priv->rxqs)[parser->queues[i]]; + (*priv->rxqs)[parser->rss_conf.queue[i]]; q->mark |= parser->mark; } @@ -1927,7 +1902,8 @@ mlx5_flow_list_create(struct rte_eth_dev *dev, if (ret) goto exit; flow = rte_calloc(__func__, 1, - sizeof(*flow) + parser.queues_n * sizeof(uint16_t), + sizeof(*flow) + + parser.rss_conf.queue_num * sizeof(uint16_t), 0); if (!flow) { rte_flow_error_set(error, ENOMEM, @@ -1936,15 +1912,20 @@ mlx5_flow_list_create(struct rte_eth_dev *dev, "cannot allocate flow memory"); return NULL; } - /* Copy queues configuration. */ + /* Copy configuration. */ flow->queues = (uint16_t (*)[])(flow + 1); - memcpy(flow->queues, parser.queues, parser.queues_n * sizeof(uint16_t)); - flow->queues_n = parser.queues_n; + flow->rss_conf = (struct rte_flow_action_rss){ + .types = parser.rss_conf.types, + .key_len = parser.rss_conf.key_len, + .queue_num = parser.rss_conf.queue_num, + .key = memcpy(flow->rss_key, parser.rss_conf.key, + sizeof(*parser.rss_conf.key) * + parser.rss_conf.key_len), + .queue = memcpy(flow->queues, parser.rss_conf.queue, + sizeof(*parser.rss_conf.queue) * + parser.rss_conf.queue_num), + }; flow->mark = parser.mark; - /* Copy RSS configuration. */ - flow->rss_conf = parser.rss_conf; - flow->rss_conf.rss_key = flow->rss_key; - memcpy(flow->rss_key, parser.rss_key, parser.rss_conf.rss_key_len); /* finalise the flow. */ if (parser.drop) ret = mlx5_flow_create_action_queue_drop(dev, &parser, flow, @@ -2024,7 +2005,7 @@ mlx5_flow_list_destroy(struct rte_eth_dev *dev, struct mlx5_flows *list, if (flow->drop || !flow->mark) goto free; - for (i = 0; i != flow->queues_n; ++i) { + for (i = 0; i != flow->rss_conf.queue_num; ++i) { struct rte_flow *tmp; int mark = 0; @@ -2334,19 +2315,19 @@ mlx5_flow_start(struct rte_eth_dev *dev, struct mlx5_flows *list) if (!flow->frxq[i].ibv_attr) continue; flow->frxq[i].hrxq = - mlx5_hrxq_get(dev, flow->rss_conf.rss_key, - flow->rss_conf.rss_key_len, + mlx5_hrxq_get(dev, flow->rss_conf.key, + flow->rss_conf.key_len, hash_rxq_init[i].hash_fields, - (*flow->queues), - flow->queues_n); + flow->rss_conf.queue, + flow->rss_conf.queue_num); if (flow->frxq[i].hrxq) goto flow_create; flow->frxq[i].hrxq = - mlx5_hrxq_new(dev, flow->rss_conf.rss_key, - flow->rss_conf.rss_key_len, + mlx5_hrxq_new(dev, flow->rss_conf.key, + flow->rss_conf.key_len, hash_rxq_init[i].hash_fields, - (*flow->queues), - flow->queues_n); + flow->rss_conf.queue, + flow->rss_conf.queue_num); if (!flow->frxq[i].hrxq) { DRV_LOG(DEBUG, "port %u flow %p cannot be applied", @@ -2370,8 +2351,8 @@ mlx5_flow_start(struct rte_eth_dev *dev, struct mlx5_flows *list) } if (!flow->mark) continue; - for (i = 0; i != flow->queues_n; ++i) - (*priv->rxqs)[(*flow->queues)[i]]->mark = 1; + for (i = 0; i != flow->rss_conf.queue_num; ++i) + (*priv->rxqs)[flow->rss_conf.queue[i]]->mark = 1; } return 0; } @@ -2448,8 +2429,10 @@ mlx5_ctrl_flow_vlan(struct rte_eth_dev *dev, }; uint16_t queue[priv->reta_idx_n]; struct rte_flow_action_rss action_rss = { - .rss_conf = &priv->rss_conf, - .num = priv->reta_idx_n, + .types = priv->rss_conf.rss_hf, + .key_len = priv->rss_conf.rss_key_len, + .queue_num = priv->reta_idx_n, + .key = priv->rss_conf.rss_key, .queue = queue, }; struct rte_flow_action actions[] = { diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c index 1b4570586..1e4354ab3 100644 --- a/drivers/net/mlx5/mlx5_rxq.c +++ b/drivers/net/mlx5/mlx5_rxq.c @@ -1218,8 +1218,8 @@ mlx5_rxq_verify(struct rte_eth_dev *dev) * The Verbs object initialised, NULL otherwise and rte_errno is set. */ struct mlx5_ind_table_ibv * -mlx5_ind_table_ibv_new(struct rte_eth_dev *dev, uint16_t queues[], - uint16_t queues_n) +mlx5_ind_table_ibv_new(struct rte_eth_dev *dev, const uint16_t *queues, + uint32_t queues_n) { struct priv *priv = dev->data->dev_private; struct mlx5_ind_table_ibv *ind_tbl; @@ -1286,8 +1286,8 @@ mlx5_ind_table_ibv_new(struct rte_eth_dev *dev, uint16_t queues[], * An indirection table if found. */ struct mlx5_ind_table_ibv * -mlx5_ind_table_ibv_get(struct rte_eth_dev *dev, uint16_t queues[], - uint16_t queues_n) +mlx5_ind_table_ibv_get(struct rte_eth_dev *dev, const uint16_t *queues, + uint32_t queues_n) { struct priv *priv = dev->data->dev_private; struct mlx5_ind_table_ibv *ind_tbl; @@ -1391,8 +1391,10 @@ mlx5_ind_table_ibv_verify(struct rte_eth_dev *dev) * The Verbs object initialised, NULL otherwise and rte_errno is set. */ struct mlx5_hrxq * -mlx5_hrxq_new(struct rte_eth_dev *dev, uint8_t *rss_key, uint8_t rss_key_len, - uint64_t hash_fields, uint16_t queues[], uint16_t queues_n) +mlx5_hrxq_new(struct rte_eth_dev *dev, + const uint8_t *rss_key, uint32_t rss_key_len, + uint64_t hash_fields, + const uint16_t *queues, uint32_t queues_n) { struct priv *priv = dev->data->dev_private; struct mlx5_hrxq *hrxq; @@ -1419,7 +1421,7 @@ mlx5_hrxq_new(struct rte_eth_dev *dev, uint8_t *rss_key, uint8_t rss_key_len, .rx_hash_conf = (struct ibv_rx_hash_conf){ .rx_hash_function = IBV_RX_HASH_FUNC_TOEPLITZ, .rx_hash_key_len = rss_key_len, - .rx_hash_key = rss_key, + .rx_hash_key = (void *)(uintptr_t)rss_key, .rx_hash_fields_mask = hash_fields, }, .rwq_ind_tbl = ind_tbl->ind_table, @@ -1469,8 +1471,10 @@ mlx5_hrxq_new(struct rte_eth_dev *dev, uint8_t *rss_key, uint8_t rss_key_len, * An hash Rx queue on success. */ struct mlx5_hrxq * -mlx5_hrxq_get(struct rte_eth_dev *dev, uint8_t *rss_key, uint8_t rss_key_len, - uint64_t hash_fields, uint16_t queues[], uint16_t queues_n) +mlx5_hrxq_get(struct rte_eth_dev *dev, + const uint8_t *rss_key, uint32_t rss_key_len, + uint64_t hash_fields, + const uint16_t *queues, uint32_t queues_n) { struct priv *priv = dev->data->dev_private; struct mlx5_hrxq *hrxq; diff --git a/drivers/net/mlx5/mlx5_rxtx.h b/drivers/net/mlx5/mlx5_rxtx.h index f5af43735..a702cb603 100644 --- a/drivers/net/mlx5/mlx5_rxtx.h +++ b/drivers/net/mlx5/mlx5_rxtx.h @@ -134,7 +134,7 @@ struct mlx5_ind_table_ibv { LIST_ENTRY(mlx5_ind_table_ibv) next; /* Pointer to the next element. */ rte_atomic32_t refcnt; /* Reference counter. */ struct ibv_rwq_ind_table *ind_table; /**< Indirection table. */ - uint16_t queues_n; /**< Number of queues in the list. */ + uint32_t queues_n; /**< Number of queues in the list. */ uint16_t queues[]; /**< Queue list. */ }; @@ -145,7 +145,7 @@ struct mlx5_hrxq { struct mlx5_ind_table_ibv *ind_table; /* Indirection table. */ struct ibv_qp *qp; /* Verbs queue pair. */ uint64_t hash_fields; /* Verbs Hash fields. */ - uint8_t rss_key_len; /* Hash key length in bytes. */ + uint32_t rss_key_len; /* Hash key length in bytes. */ uint8_t rss_key[]; /* Hash key. */ }; @@ -237,20 +237,22 @@ int mlx5_rxq_releasable(struct rte_eth_dev *dev, uint16_t idx); int mlx5_rxq_verify(struct rte_eth_dev *dev); int rxq_alloc_elts(struct mlx5_rxq_ctrl *rxq_ctrl); struct mlx5_ind_table_ibv *mlx5_ind_table_ibv_new(struct rte_eth_dev *dev, - uint16_t queues[], - uint16_t queues_n); + const uint16_t *queues, + uint32_t queues_n); struct mlx5_ind_table_ibv *mlx5_ind_table_ibv_get(struct rte_eth_dev *dev, - uint16_t queues[], - uint16_t queues_n); + const uint16_t *queues, + uint32_t queues_n); int mlx5_ind_table_ibv_release(struct rte_eth_dev *dev, struct mlx5_ind_table_ibv *ind_tbl); int mlx5_ind_table_ibv_verify(struct rte_eth_dev *dev); -struct mlx5_hrxq *mlx5_hrxq_new(struct rte_eth_dev *dev, uint8_t *rss_key, - uint8_t rss_key_len, uint64_t hash_fields, - uint16_t queues[], uint16_t queues_n); -struct mlx5_hrxq *mlx5_hrxq_get(struct rte_eth_dev *dev, uint8_t *rss_key, - uint8_t rss_key_len, uint64_t hash_fields, - uint16_t queues[], uint16_t queues_n); +struct mlx5_hrxq *mlx5_hrxq_new(struct rte_eth_dev *dev, + const uint8_t *rss_key, uint32_t rss_key_len, + uint64_t hash_fields, + const uint16_t *queues, uint32_t queues_n); +struct mlx5_hrxq *mlx5_hrxq_get(struct rte_eth_dev *dev, + const uint8_t *rss_key, uint32_t rss_key_len, + uint64_t hash_fields, + const uint16_t *queues, uint32_t queues_n); int mlx5_hrxq_release(struct rte_eth_dev *dev, struct mlx5_hrxq *hxrq); int mlx5_hrxq_ibv_verify(struct rte_eth_dev *dev); uint64_t mlx5_get_rx_port_offloads(void); diff --git a/drivers/net/sfc/sfc_flow.c b/drivers/net/sfc/sfc_flow.c index 056405515..1a2c0299c 100644 --- a/drivers/net/sfc/sfc_flow.c +++ b/drivers/net/sfc/sfc_flow.c @@ -1234,13 +1234,11 @@ sfc_flow_parse_rss(struct sfc_adapter *sa, struct sfc_rxq *rxq; unsigned int rxq_hw_index_min; unsigned int rxq_hw_index_max; - const struct rte_eth_rss_conf *rss_conf = rss->rss_conf; - uint64_t rss_hf; - uint8_t *rss_key = NULL; + const uint8_t *rss_key; struct sfc_flow_rss *sfc_rss_conf = &flow->rss_conf; unsigned int i; - if (rss->num == 0) + if (rss->queue_num == 0) return -EINVAL; rxq_sw_index = sa->rxq_count - 1; @@ -1248,7 +1246,7 @@ sfc_flow_parse_rss(struct sfc_adapter *sa, rxq_hw_index_min = rxq->hw_index; rxq_hw_index_max = 0; - for (i = 0; i < rss->num; ++i) { + for (i = 0; i < rss->queue_num; ++i) { rxq_sw_index = rss->queue[i]; if (rxq_sw_index >= sa->rxq_count) @@ -1263,15 +1261,14 @@ sfc_flow_parse_rss(struct sfc_adapter *sa, rxq_hw_index_max = rxq->hw_index; } - rss_hf = (rss_conf != NULL) ? rss_conf->rss_hf : SFC_RSS_OFFLOADS; - if ((rss_hf & ~SFC_RSS_OFFLOADS) != 0) + if ((rss->types & ~SFC_RSS_OFFLOADS) != 0) return -EINVAL; - if (rss_conf != NULL) { - if (rss_conf->rss_key_len != sizeof(sa->rss_key)) + if (rss->key_len) { + if (rss->key_len != sizeof(sa->rss_key)) return -EINVAL; - rss_key = rss_conf->rss_key; + rss_key = rss->key; } else { rss_key = sa->rss_key; } @@ -1280,11 +1277,11 @@ sfc_flow_parse_rss(struct sfc_adapter *sa, sfc_rss_conf->rxq_hw_index_min = rxq_hw_index_min; sfc_rss_conf->rxq_hw_index_max = rxq_hw_index_max; - sfc_rss_conf->rss_hash_types = sfc_rte_to_efx_hash_type(rss_hf); + sfc_rss_conf->rss_hash_types = sfc_rte_to_efx_hash_type(rss->types); rte_memcpy(sfc_rss_conf->rss_key, rss_key, sizeof(sa->rss_key)); for (i = 0; i < RTE_DIM(sfc_rss_conf->rss_tbl); ++i) { - unsigned int rxq_sw_index = rss->queue[i % rss->num]; + unsigned int rxq_sw_index = rss->queue[i % rss->queue_num]; struct sfc_rxq *rxq = sa->rxq_info[rxq_sw_index].rxq; sfc_rss_conf->rss_tbl[i] = rxq->hw_index - rxq_hw_index_min; diff --git a/drivers/net/tap/tap_flow.c b/drivers/net/tap/tap_flow.c index aea3462a6..78f20913f 100644 --- a/drivers/net/tap/tap_flow.c +++ b/drivers/net/tap/tap_flow.c @@ -1215,7 +1215,7 @@ priv_flow_process(struct pmd_internals *pmd, if (err) goto exit_action_not_supported; } - if (flow && rss) + if (flow) err = rss_add_actions(flow, pmd, rss, error); } else { goto exit_action_not_supported; @@ -2050,7 +2050,7 @@ static int rss_add_actions(struct rte_flow *flow, struct pmd_internals *pmd, struct rte_flow_error *error) { /* 4096 is the maximum number of instructions for a BPF program */ - int i; + unsigned int i; int err; struct rss_key rss_entry = { .hash_fields = 0, .key_size = 0 }; @@ -2066,8 +2066,8 @@ static int rss_add_actions(struct rte_flow *flow, struct pmd_internals *pmd, } /* Update RSS map entry with queues */ - rss_entry.nb_queues = rss->num; - for (i = 0; i < rss->num; i++) + rss_entry.nb_queues = rss->queue_num; + for (i = 0; i < rss->queue_num; i++) rss_entry.queues[i] = rss->queue[i]; rss_entry.hash_fields = (1 << HASH_FIELD_IPV4_L3_L4) | (1 << HASH_FIELD_IPV6_L3_L4); diff --git a/examples/ipsec-secgw/ipsec.c b/examples/ipsec-secgw/ipsec.c index 8b2047adb..3ce76c413 100644 --- a/examples/ipsec-secgw/ipsec.c +++ b/examples/ipsec-secgw/ipsec.c @@ -202,9 +202,13 @@ create_session(struct ipsec_ctx *ipsec_ctx, struct ipsec_sa *sa) i < eth_dev->data->nb_rx_queues; ++i) if (eth_dev->data->rx_queues[i]) queue[j++] = i; - action_rss.rss_conf = &rss_conf; - action_rss.num = j; - action_rss.queue = queue; + action_rss = (struct rte_flow_action_rss){ + .types = rss_conf.rss_hf, + .key_len = rss_conf.rss_key_len, + .queue_num = j, + .key = rss_key, + .queue = queue, + }; ret = rte_flow_validate(sa->portid, &sa->attr, sa->pattern, sa->action, &err); diff --git a/lib/librte_ether/rte_flow.c b/lib/librte_ether/rte_flow.c index 550086411..2fabc9a29 100644 --- a/lib/librte_ether/rte_flow.c +++ b/lib/librte_ether/rte_flow.c @@ -330,40 +330,27 @@ flow_action_conf_copy(void *buf, const struct rte_flow_action *action) off = 0; if (dst.rss) *dst.rss = (struct rte_flow_action_rss){ - .num = src.rss->num, + .types = src.rss->types, + .key_len = src.rss->key_len, + .queue_num = src.rss->queue_num, }; off += sizeof(*src.rss); - if (src.rss->num) { + if (src.rss->key_len) { off = RTE_ALIGN_CEIL(off, sizeof(double)); - size = sizeof(*src.rss->queue) * src.rss->num; + size = sizeof(*src.rss->key) * src.rss->key_len; if (dst.rss) - dst.rss->queue = memcpy + dst.rss->key = memcpy ((void *)((uintptr_t)dst.rss + off), - src.rss->queue, size); + src.rss->key, size); off += size; } - off = RTE_ALIGN_CEIL(off, sizeof(double)); - if (dst.rss) { - dst.rss->rss_conf = (void *)((uintptr_t)dst.rss + off); - *(struct rte_eth_rss_conf *)(uintptr_t) - dst.rss->rss_conf = (struct rte_eth_rss_conf){ - .rss_key_len = src.rss->rss_conf->rss_key_len, - .rss_hf = src.rss->rss_conf->rss_hf, - }; - } - off += sizeof(*src.rss->rss_conf); - if (src.rss->rss_conf->rss_key_len) { + if (src.rss->queue_num) { off = RTE_ALIGN_CEIL(off, sizeof(double)); - size = sizeof(*src.rss->rss_conf->rss_key) * - src.rss->rss_conf->rss_key_len; - if (dst.rss) { - ((struct rte_eth_rss_conf *)(uintptr_t) - dst.rss->rss_conf)->rss_key = - (void *)((uintptr_t)dst.rss + off); - memcpy(dst.rss->rss_conf->rss_key, - src.rss->rss_conf->rss_key, - size); - } + size = sizeof(*src.rss->queue) * src.rss->queue_num; + if (dst.rss) + dst.rss->queue = memcpy + ((void *)((uintptr_t)dst.rss + off), + src.rss->queue, size); off += size; } size = off; diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index 895feb1a3..e2eba9c26 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -1038,8 +1038,10 @@ struct rte_flow_query_count { * both can be requested simultaneously. */ struct rte_flow_action_rss { - const struct rte_eth_rss_conf *rss_conf; /**< RSS parameters. */ - uint16_t num; /**< Number of entries in @p queue. */ + uint64_t types; /**< RSS hash types (see ETH_RSS_*). */ + uint32_t key_len; /**< Hash key length in bytes. */ + uint32_t queue_num; /**< Number of entries in @p queue. */ + const uint8_t *key; /**< Hash key. */ const uint16_t *queue; /**< Queue indices to use. */ }; -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [dpdk-dev] [PATCH v2 07/15] ethdev: flatten RSS configuration in flow API 2018-04-06 13:25 ` [dpdk-dev] [PATCH v2 07/15] ethdev: flatten RSS configuration in " Adrien Mazarguil @ 2018-04-07 9:05 ` Andrew Rybchenko 2018-04-09 14:42 ` Adrien Mazarguil 0 siblings, 1 reply; 157+ messages in thread From: Andrew Rybchenko @ 2018-04-07 9:05 UTC (permalink / raw) To: Adrien Mazarguil, Thomas Monjalon, Ferruh Yigit, dev Cc: Xueming Li, Wenzhuo Lu, Jingjing Wu, Beilei Xing, Qi Zhang, Konstantin Ananyev, Nelio Laranjeiro, Yongseok Koh, Pascal Mazon, Radu Nicolau, Akhil Goyal, Ivan Malov On 04/06/2018 04:25 PM, Adrien Mazarguil wrote: > Since its inception, the rte_flow RSS action has been relying in part on > external struct rte_eth_rss_conf for compatibility with the legacy RSS API. > This structure lacks parameters such as the hash algorithm to use, and more > recently, a method to tell which layer RSS should be performed on [1]. > > Given struct rte_eth_rss_conf will never be flexible enough to represent a > complete RSS configuration (e.g. RETA table), this patch supersedes it by > extending the rte_flow RSS action directly. > > A subsequent patch will add a field to use a non-default RSS hash > algorithm. To that end, a field named "types" replaces the field formerly > known as "rss_hf" and standing for "RSS hash functions" as it was > confusing. Actual RSS hash function types are defined by enum > rte_eth_hash_function. > This patch updates all PMDs and example applications accordingly. > > It breaks ABI compatibility for the following public functions: > > - rte_flow_copy() > - rte_flow_create() > - rte_flow_query() > - rte_flow_validate() > > [1] commit 676b605182a5 ("doc: announce ethdev API change for RSS > configuration") > > Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> > Cc: Xueming Li <xuemingl@mellanox.com> > Cc: Ferruh Yigit <ferruh.yigit@intel.com> > Cc: Thomas Monjalon <thomas@monjalon.net> > Cc: Wenzhuo Lu <wenzhuo.lu@intel.com> > Cc: Jingjing Wu <jingjing.wu@intel.com> > Cc: Beilei Xing <beilei.xing@intel.com> > Cc: Qi Zhang <qi.z.zhang@intel.com> > Cc: Konstantin Ananyev <konstantin.ananyev@intel.com> > Cc: Nelio Laranjeiro <nelio.laranjeiro@6wind.com> > Cc: Yongseok Koh <yskoh@mellanox.com> > Cc: Andrew Rybchenko <arybchenko@solarflare.com> > Cc: Pascal Mazon <pascal.mazon@6wind.com> > Cc: Radu Nicolau <radu.nicolau@intel.com> > Cc: Akhil Goyal <akhil.goyal@nxp.com> > --- > app/test-pmd/cmdline_flow.c | 59 +++++----- > app/test-pmd/config.c | 39 +++---- > doc/guides/prog_guide/rte_flow.rst | 22 ++-- > drivers/net/e1000/e1000_ethdev.h | 13 ++- > drivers/net/e1000/igb_ethdev.c | 4 +- > drivers/net/e1000/igb_flow.c | 31 ++--- > drivers/net/e1000/igb_rxtx.c | 51 +++++++-- > drivers/net/i40e/i40e_ethdev.c | 53 +++++++-- > drivers/net/i40e/i40e_ethdev.h | 15 ++- > drivers/net/i40e/i40e_flow.c | 47 ++++---- > drivers/net/ixgbe/ixgbe_ethdev.c | 4 +- > drivers/net/ixgbe/ixgbe_ethdev.h | 13 ++- > drivers/net/ixgbe/ixgbe_flow.c | 30 ++--- > drivers/net/ixgbe/ixgbe_rxtx.c | 51 +++++++-- > drivers/net/mlx4/mlx4.c | 2 +- > drivers/net/mlx4/mlx4_flow.c | 61 +++++----- > drivers/net/mlx4/mlx4_flow.h | 2 +- > drivers/net/mlx4/mlx4_rxq.c | 2 +- > drivers/net/mlx4/mlx4_rxtx.h | 2 +- > drivers/net/mlx5/mlx5_flow.c | 193 +++++++++++++++----------------- > drivers/net/mlx5/mlx5_rxq.c | 22 ++-- > drivers/net/mlx5/mlx5_rxtx.h | 26 +++-- > drivers/net/sfc/sfc_flow.c | 21 ++-- > drivers/net/tap/tap_flow.c | 8 +- > examples/ipsec-secgw/ipsec.c | 10 +- > lib/librte_ether/rte_flow.c | 39 +++---- > lib/librte_ether/rte_flow.h | 6 +- > 27 files changed, 473 insertions(+), 353 deletions(-) <...> > diff --git a/drivers/net/sfc/sfc_flow.c b/drivers/net/sfc/sfc_flow.c > index 056405515..1a2c0299c 100644 > --- a/drivers/net/sfc/sfc_flow.c > +++ b/drivers/net/sfc/sfc_flow.c > @@ -1234,13 +1234,11 @@ sfc_flow_parse_rss(struct sfc_adapter *sa, > struct sfc_rxq *rxq; > unsigned int rxq_hw_index_min; > unsigned int rxq_hw_index_max; > - const struct rte_eth_rss_conf *rss_conf = rss->rss_conf; > - uint64_t rss_hf; > - uint8_t *rss_key = NULL; > + const uint8_t *rss_key; > struct sfc_flow_rss *sfc_rss_conf = &flow->rss_conf; > unsigned int i; > > - if (rss->num == 0) > + if (rss->queue_num == 0) > return -EINVAL; > > rxq_sw_index = sa->rxq_count - 1; > @@ -1248,7 +1246,7 @@ sfc_flow_parse_rss(struct sfc_adapter *sa, > rxq_hw_index_min = rxq->hw_index; > rxq_hw_index_max = 0; > > - for (i = 0; i < rss->num; ++i) { > + for (i = 0; i < rss->queue_num; ++i) { > rxq_sw_index = rss->queue[i]; > > if (rxq_sw_index >= sa->rxq_count) > @@ -1263,15 +1261,14 @@ sfc_flow_parse_rss(struct sfc_adapter *sa, > rxq_hw_index_max = rxq->hw_index; > } > > - rss_hf = (rss_conf != NULL) ? rss_conf->rss_hf : SFC_RSS_OFFLOADS; Here we had a fallback to default rss_hf (now types) if rss_conf is unspecified. > - if ((rss_hf & ~SFC_RSS_OFFLOADS) != 0) > + if ((rss->types & ~SFC_RSS_OFFLOADS) != 0) > return -EINVAL; > > - if (rss_conf != NULL) { > - if (rss_conf->rss_key_len != sizeof(sa->rss_key)) > + if (rss->key_len) { > + if (rss->key_len != sizeof(sa->rss_key)) > return -EINVAL; > > - rss_key = rss_conf->rss_key; > + rss_key = rss->key; > } else { > rss_key = sa->rss_key; > } > @@ -1280,11 +1277,11 @@ sfc_flow_parse_rss(struct sfc_adapter *sa, > > sfc_rss_conf->rxq_hw_index_min = rxq_hw_index_min; > sfc_rss_conf->rxq_hw_index_max = rxq_hw_index_max; > - sfc_rss_conf->rss_hash_types = sfc_rte_to_efx_hash_type(rss_hf); > + sfc_rss_conf->rss_hash_types = sfc_rte_to_efx_hash_type(rss->types); Now types go directly to mapping function and unspecified types (0) will result in 0 rss_hash_types. Of course, it is a question how to treat types==0. It is possible to say that it no RSS, but it does not make sense. So, real options are device defaults (regardless configured on device level) or device config (rx_adv.conf.rss_conf.rss_hf). I would prefer the later. Please, document the intended behaviour in rte_flow.rst. If the later is chosen, above we'll have a bug since fallback to fixed default. Just use sa->rss_hash_types as fallback. Something like: if (rss->types) sfc_rss_conf->rss_hash_types = sfc_rte_to_efx_hash_type(rss->types); else sfc_rss_conf->rss_hash_types =sa->rss_hash_types; > rte_memcpy(sfc_rss_conf->rss_key, rss_key, sizeof(sa->rss_key)); > > for (i = 0; i < RTE_DIM(sfc_rss_conf->rss_tbl); ++i) { > - unsigned int rxq_sw_index = rss->queue[i % rss->num]; > + unsigned int rxq_sw_index = rss->queue[i % rss->queue_num]; > struct sfc_rxq *rxq = sa->rxq_info[rxq_sw_index].rxq; > > sfc_rss_conf->rss_tbl[i] = rxq->hw_index - rxq_hw_index_min; <...> ^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [dpdk-dev] [PATCH v2 07/15] ethdev: flatten RSS configuration in flow API 2018-04-07 9:05 ` Andrew Rybchenko @ 2018-04-09 14:42 ` Adrien Mazarguil 2018-04-11 13:21 ` Andrew Rybchenko 0 siblings, 1 reply; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-09 14:42 UTC (permalink / raw) To: Andrew Rybchenko Cc: Thomas Monjalon, Ferruh Yigit, dev, Xueming Li, Wenzhuo Lu, Jingjing Wu, Beilei Xing, Qi Zhang, Konstantin Ananyev, Nelio Laranjeiro, Yongseok Koh, Pascal Mazon, Radu Nicolau, Akhil Goyal, Ivan Malov On Sat, Apr 07, 2018 at 12:05:51PM +0300, Andrew Rybchenko wrote: > On 04/06/2018 04:25 PM, Adrien Mazarguil wrote: > > Since its inception, the rte_flow RSS action has been relying in part on > > external struct rte_eth_rss_conf for compatibility with the legacy RSS API. > > This structure lacks parameters such as the hash algorithm to use, and more > > recently, a method to tell which layer RSS should be performed on [1]. > > > > Given struct rte_eth_rss_conf will never be flexible enough to represent a > > complete RSS configuration (e.g. RETA table), this patch supersedes it by > > extending the rte_flow RSS action directly. > > > > A subsequent patch will add a field to use a non-default RSS hash > > algorithm. To that end, a field named "types" replaces the field formerly > > known as "rss_hf" and standing for "RSS hash functions" as it was > > confusing. Actual RSS hash function types are defined by enum > > rte_eth_hash_function. > > This patch updates all PMDs and example applications accordingly. > > > > It breaks ABI compatibility for the following public functions: > > > > - rte_flow_copy() > > - rte_flow_create() > > - rte_flow_query() > > - rte_flow_validate() > > > > [1] commit 676b605182a5 ("doc: announce ethdev API change for RSS > > configuration") > > > > Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> > > Cc: Xueming Li <xuemingl@mellanox.com> > > Cc: Ferruh Yigit <ferruh.yigit@intel.com> > > Cc: Thomas Monjalon <thomas@monjalon.net> > > Cc: Wenzhuo Lu <wenzhuo.lu@intel.com> > > Cc: Jingjing Wu <jingjing.wu@intel.com> > > Cc: Beilei Xing <beilei.xing@intel.com> > > Cc: Qi Zhang <qi.z.zhang@intel.com> > > Cc: Konstantin Ananyev <konstantin.ananyev@intel.com> > > Cc: Nelio Laranjeiro <nelio.laranjeiro@6wind.com> > > Cc: Yongseok Koh <yskoh@mellanox.com> > > Cc: Andrew Rybchenko <arybchenko@solarflare.com> > > Cc: Pascal Mazon <pascal.mazon@6wind.com> > > Cc: Radu Nicolau <radu.nicolau@intel.com> > > Cc: Akhil Goyal <akhil.goyal@nxp.com> > > --- > > app/test-pmd/cmdline_flow.c | 59 +++++----- > > app/test-pmd/config.c | 39 +++---- > > doc/guides/prog_guide/rte_flow.rst | 22 ++-- > > drivers/net/e1000/e1000_ethdev.h | 13 ++- > > drivers/net/e1000/igb_ethdev.c | 4 +- > > drivers/net/e1000/igb_flow.c | 31 ++--- > > drivers/net/e1000/igb_rxtx.c | 51 +++++++-- > > drivers/net/i40e/i40e_ethdev.c | 53 +++++++-- > > drivers/net/i40e/i40e_ethdev.h | 15 ++- > > drivers/net/i40e/i40e_flow.c | 47 ++++---- > > drivers/net/ixgbe/ixgbe_ethdev.c | 4 +- > > drivers/net/ixgbe/ixgbe_ethdev.h | 13 ++- > > drivers/net/ixgbe/ixgbe_flow.c | 30 ++--- > > drivers/net/ixgbe/ixgbe_rxtx.c | 51 +++++++-- > > drivers/net/mlx4/mlx4.c | 2 +- > > drivers/net/mlx4/mlx4_flow.c | 61 +++++----- > > drivers/net/mlx4/mlx4_flow.h | 2 +- > > drivers/net/mlx4/mlx4_rxq.c | 2 +- > > drivers/net/mlx4/mlx4_rxtx.h | 2 +- > > drivers/net/mlx5/mlx5_flow.c | 193 +++++++++++++++----------------- > > drivers/net/mlx5/mlx5_rxq.c | 22 ++-- > > drivers/net/mlx5/mlx5_rxtx.h | 26 +++-- > > drivers/net/sfc/sfc_flow.c | 21 ++-- > > drivers/net/tap/tap_flow.c | 8 +- > > examples/ipsec-secgw/ipsec.c | 10 +- > > lib/librte_ether/rte_flow.c | 39 +++---- > > lib/librte_ether/rte_flow.h | 6 +- > > 27 files changed, 473 insertions(+), 353 deletions(-) > > <...> > > > diff --git a/drivers/net/sfc/sfc_flow.c b/drivers/net/sfc/sfc_flow.c > > index 056405515..1a2c0299c 100644 > > --- a/drivers/net/sfc/sfc_flow.c > > +++ b/drivers/net/sfc/sfc_flow.c > > @@ -1234,13 +1234,11 @@ sfc_flow_parse_rss(struct sfc_adapter *sa, > > struct sfc_rxq *rxq; > > unsigned int rxq_hw_index_min; > > unsigned int rxq_hw_index_max; > > - const struct rte_eth_rss_conf *rss_conf = rss->rss_conf; > > - uint64_t rss_hf; > > - uint8_t *rss_key = NULL; > > + const uint8_t *rss_key; > > struct sfc_flow_rss *sfc_rss_conf = &flow->rss_conf; > > unsigned int i; > > - if (rss->num == 0) > > + if (rss->queue_num == 0) > > return -EINVAL; > > rxq_sw_index = sa->rxq_count - 1; > > @@ -1248,7 +1246,7 @@ sfc_flow_parse_rss(struct sfc_adapter *sa, > > rxq_hw_index_min = rxq->hw_index; > > rxq_hw_index_max = 0; > > - for (i = 0; i < rss->num; ++i) { > > + for (i = 0; i < rss->queue_num; ++i) { > > rxq_sw_index = rss->queue[i]; > > if (rxq_sw_index >= sa->rxq_count) > > @@ -1263,15 +1261,14 @@ sfc_flow_parse_rss(struct sfc_adapter *sa, > > rxq_hw_index_max = rxq->hw_index; > > } > > - rss_hf = (rss_conf != NULL) ? rss_conf->rss_hf : SFC_RSS_OFFLOADS; > > Here we had a fallback to default rss_hf (now types) if rss_conf is > unspecified. Thing is, rss_action->conf was never supposed to be NULL in the first place. Crashing on a NULL configuration has always been fine, but until recently prevented validation with testpmd's broken implementation. This problem was addressed in a prior series [1][2][3]. Since a value is now always provided, no need for a fallback. [1] "app/testpmd: fix lack of flow action configuration" http://dpdk.org/ml/archives/dev/2018-April/095280.html [2] "app/testpmd: fix RSS flow action configuration" http://dpdk.org/ml/archives/dev/2018-April/095281.html [3] "app/testpmd: fix missing RSS fields in flow action" http://dpdk.org/ml/archives/dev/2018-April/095282.html > > - if ((rss_hf & ~SFC_RSS_OFFLOADS) != 0) > > + if ((rss->types & ~SFC_RSS_OFFLOADS) != 0) > > return -EINVAL; > > - if (rss_conf != NULL) { > > - if (rss_conf->rss_key_len != sizeof(sa->rss_key)) > > + if (rss->key_len) { > > + if (rss->key_len != sizeof(sa->rss_key)) > > return -EINVAL; > > - rss_key = rss_conf->rss_key; > > + rss_key = rss->key; > > } else { > > rss_key = sa->rss_key; > > } > > @@ -1280,11 +1277,11 @@ sfc_flow_parse_rss(struct sfc_adapter *sa, > > sfc_rss_conf->rxq_hw_index_min = rxq_hw_index_min; > > sfc_rss_conf->rxq_hw_index_max = rxq_hw_index_max; > > - sfc_rss_conf->rss_hash_types = sfc_rte_to_efx_hash_type(rss_hf); > > + sfc_rss_conf->rss_hash_types = sfc_rte_to_efx_hash_type(rss->types); > > Now types go directly to mapping function and unspecified types (0) > will result in 0 rss_hash_types. Of course, it is a question how to treat > types==0. It is possible to say that it no RSS, but it does not make sense. > So, real options are device defaults (regardless configured on device level) > or device config (rx_adv.conf.rss_conf.rss_hf). I would prefer the later. > Please, document the intended behaviour in rte_flow.rst. Granted the existing documentation doesn't say much on that topic, but a 0 value for rss_hf does actually mean "no RSS" [4]: "The *rss_hf* field of the *rss_conf* structure indicates the different types of IPv4/IPv6 packets to which the RSS hashing must be applied. Supplying an *rss_hf* equal to zero disables the RSS feature." Now since this action doesn't use struct rte_eth_rss_conf anymore, we could define 0 as a PMD-specific behavior, which could be no RSS. It would make the API easier to use for applications that don't care about the RSS capabilities of each underlying adapter, 0 would just work everywhere as a safe default. [4] https://dpdk.org/doc/api/structrte__eth__rss__conf.html > If the later is chosen, above we'll have a bug since fallback to fixed > default. > Just use sa->rss_hash_types as fallback. Something like: > if (rss->types) > sfc_rss_conf->rss_hash_types = sfc_rte_to_efx_hash_type(rss->types); > else > sfc_rss_conf->rss_hash_types =sa->rss_hash_types; Looks like the previous code didn't provide a fallback when rss_hf was 0, only when rss_conf itself was NULL. So this is not a new issue introduced by this patch. I will update documentation to define 0 as described above for the convenience of application writers and leave the existing code in place. PMD maintainers will be free to enhance it as they wish later. Just remember testpmd now always provides a default value for it after querying the device [2]. > > rte_memcpy(sfc_rss_conf->rss_key, rss_key, sizeof(sa->rss_key)); > > for (i = 0; i < RTE_DIM(sfc_rss_conf->rss_tbl); ++i) { > > - unsigned int rxq_sw_index = rss->queue[i % rss->num]; > > + unsigned int rxq_sw_index = rss->queue[i % rss->queue_num]; > > struct sfc_rxq *rxq = sa->rxq_info[rxq_sw_index].rxq; > > sfc_rss_conf->rss_tbl[i] = rxq->hw_index - rxq_hw_index_min; > > <...> -- Adrien Mazarguil 6WIND ^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [dpdk-dev] [PATCH v2 07/15] ethdev: flatten RSS configuration in flow API 2018-04-09 14:42 ` Adrien Mazarguil @ 2018-04-11 13:21 ` Andrew Rybchenko 0 siblings, 0 replies; 157+ messages in thread From: Andrew Rybchenko @ 2018-04-11 13:21 UTC (permalink / raw) To: Adrien Mazarguil Cc: Thomas Monjalon, Ferruh Yigit, dev, Xueming Li, Wenzhuo Lu, Jingjing Wu, Beilei Xing, Qi Zhang, Konstantin Ananyev, Nelio Laranjeiro, Yongseok Koh, Pascal Mazon, Radu Nicolau, Akhil Goyal, Ivan Malov On 04/09/2018 05:42 PM, Adrien Mazarguil wrote: > On Sat, Apr 07, 2018 at 12:05:51PM +0300, Andrew Rybchenko wrote: >> On 04/06/2018 04:25 PM, Adrien Mazarguil wrote: >>> Since its inception, the rte_flow RSS action has been relying in part on >>> external struct rte_eth_rss_conf for compatibility with the legacy RSS API. >>> This structure lacks parameters such as the hash algorithm to use, and more >>> recently, a method to tell which layer RSS should be performed on [1]. >>> >>> Given struct rte_eth_rss_conf will never be flexible enough to represent a >>> complete RSS configuration (e.g. RETA table), this patch supersedes it by >>> extending the rte_flow RSS action directly. >>> >>> A subsequent patch will add a field to use a non-default RSS hash >>> algorithm. To that end, a field named "types" replaces the field formerly >>> known as "rss_hf" and standing for "RSS hash functions" as it was >>> confusing. Actual RSS hash function types are defined by enum >>> rte_eth_hash_function. >>> This patch updates all PMDs and example applications accordingly. >>> >>> It breaks ABI compatibility for the following public functions: >>> >>> - rte_flow_copy() >>> - rte_flow_create() >>> - rte_flow_query() >>> - rte_flow_validate() >>> >>> [1] commit 676b605182a5 ("doc: announce ethdev API change for RSS >>> configuration") >>> >>> Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> >>> Cc: Xueming Li <xuemingl@mellanox.com> >>> Cc: Ferruh Yigit <ferruh.yigit@intel.com> >>> Cc: Thomas Monjalon <thomas@monjalon.net> >>> Cc: Wenzhuo Lu <wenzhuo.lu@intel.com> >>> Cc: Jingjing Wu <jingjing.wu@intel.com> >>> Cc: Beilei Xing <beilei.xing@intel.com> >>> Cc: Qi Zhang <qi.z.zhang@intel.com> >>> Cc: Konstantin Ananyev <konstantin.ananyev@intel.com> >>> Cc: Nelio Laranjeiro <nelio.laranjeiro@6wind.com> >>> Cc: Yongseok Koh <yskoh@mellanox.com> >>> Cc: Andrew Rybchenko <arybchenko@solarflare.com> >>> Cc: Pascal Mazon <pascal.mazon@6wind.com> >>> Cc: Radu Nicolau <radu.nicolau@intel.com> >>> Cc: Akhil Goyal <akhil.goyal@nxp.com> >>> --- >>> app/test-pmd/cmdline_flow.c | 59 +++++----- >>> app/test-pmd/config.c | 39 +++---- >>> doc/guides/prog_guide/rte_flow.rst | 22 ++-- >>> drivers/net/e1000/e1000_ethdev.h | 13 ++- >>> drivers/net/e1000/igb_ethdev.c | 4 +- >>> drivers/net/e1000/igb_flow.c | 31 ++--- >>> drivers/net/e1000/igb_rxtx.c | 51 +++++++-- >>> drivers/net/i40e/i40e_ethdev.c | 53 +++++++-- >>> drivers/net/i40e/i40e_ethdev.h | 15 ++- >>> drivers/net/i40e/i40e_flow.c | 47 ++++---- >>> drivers/net/ixgbe/ixgbe_ethdev.c | 4 +- >>> drivers/net/ixgbe/ixgbe_ethdev.h | 13 ++- >>> drivers/net/ixgbe/ixgbe_flow.c | 30 ++--- >>> drivers/net/ixgbe/ixgbe_rxtx.c | 51 +++++++-- >>> drivers/net/mlx4/mlx4.c | 2 +- >>> drivers/net/mlx4/mlx4_flow.c | 61 +++++----- >>> drivers/net/mlx4/mlx4_flow.h | 2 +- >>> drivers/net/mlx4/mlx4_rxq.c | 2 +- >>> drivers/net/mlx4/mlx4_rxtx.h | 2 +- >>> drivers/net/mlx5/mlx5_flow.c | 193 +++++++++++++++----------------- >>> drivers/net/mlx5/mlx5_rxq.c | 22 ++-- >>> drivers/net/mlx5/mlx5_rxtx.h | 26 +++-- >>> drivers/net/sfc/sfc_flow.c | 21 ++-- >>> drivers/net/tap/tap_flow.c | 8 +- >>> examples/ipsec-secgw/ipsec.c | 10 +- >>> lib/librte_ether/rte_flow.c | 39 +++---- >>> lib/librte_ether/rte_flow.h | 6 +- >>> 27 files changed, 473 insertions(+), 353 deletions(-) >> <...> >> >>> diff --git a/drivers/net/sfc/sfc_flow.c b/drivers/net/sfc/sfc_flow.c >>> index 056405515..1a2c0299c 100644 >>> --- a/drivers/net/sfc/sfc_flow.c >>> +++ b/drivers/net/sfc/sfc_flow.c >>> @@ -1234,13 +1234,11 @@ sfc_flow_parse_rss(struct sfc_adapter *sa, >>> struct sfc_rxq *rxq; >>> unsigned int rxq_hw_index_min; >>> unsigned int rxq_hw_index_max; >>> - const struct rte_eth_rss_conf *rss_conf = rss->rss_conf; >>> - uint64_t rss_hf; >>> - uint8_t *rss_key = NULL; >>> + const uint8_t *rss_key; >>> struct sfc_flow_rss *sfc_rss_conf = &flow->rss_conf; >>> unsigned int i; >>> - if (rss->num == 0) >>> + if (rss->queue_num == 0) >>> return -EINVAL; >>> rxq_sw_index = sa->rxq_count - 1; >>> @@ -1248,7 +1246,7 @@ sfc_flow_parse_rss(struct sfc_adapter *sa, >>> rxq_hw_index_min = rxq->hw_index; >>> rxq_hw_index_max = 0; >>> - for (i = 0; i < rss->num; ++i) { >>> + for (i = 0; i < rss->queue_num; ++i) { >>> rxq_sw_index = rss->queue[i]; >>> if (rxq_sw_index >= sa->rxq_count) >>> @@ -1263,15 +1261,14 @@ sfc_flow_parse_rss(struct sfc_adapter *sa, >>> rxq_hw_index_max = rxq->hw_index; >>> } >>> - rss_hf = (rss_conf != NULL) ? rss_conf->rss_hf : SFC_RSS_OFFLOADS; >> Here we had a fallback to default rss_hf (now types) if rss_conf is >> unspecified. > Thing is, rss_action->conf was never supposed to be NULL in the first > place. Crashing on a NULL configuration has always been fine, but until > recently prevented validation with testpmd's broken implementation. This > problem was addressed in a prior series [1][2][3]. > > Since a value is now always provided, no need for a fallback. testpmd is not the only application. But in any case I agree that it was possible have rss_hf==0 before. So, no big changes. > [1] "app/testpmd: fix lack of flow action configuration" > http://dpdk.org/ml/archives/dev/2018-April/095280.html > [2] "app/testpmd: fix RSS flow action configuration" > http://dpdk.org/ml/archives/dev/2018-April/095281.html > [3] "app/testpmd: fix missing RSS fields in flow action" > http://dpdk.org/ml/archives/dev/2018-April/095282.html > >>> - if ((rss_hf & ~SFC_RSS_OFFLOADS) != 0) >>> + if ((rss->types & ~SFC_RSS_OFFLOADS) != 0) >>> return -EINVAL; >>> - if (rss_conf != NULL) { >>> - if (rss_conf->rss_key_len != sizeof(sa->rss_key)) >>> + if (rss->key_len) { >>> + if (rss->key_len != sizeof(sa->rss_key)) >>> return -EINVAL; >>> - rss_key = rss_conf->rss_key; >>> + rss_key = rss->key; >>> } else { >>> rss_key = sa->rss_key; >>> } >>> @@ -1280,11 +1277,11 @@ sfc_flow_parse_rss(struct sfc_adapter *sa, >>> sfc_rss_conf->rxq_hw_index_min = rxq_hw_index_min; >>> sfc_rss_conf->rxq_hw_index_max = rxq_hw_index_max; >>> - sfc_rss_conf->rss_hash_types = sfc_rte_to_efx_hash_type(rss_hf); >>> + sfc_rss_conf->rss_hash_types = sfc_rte_to_efx_hash_type(rss->types); >> Now types go directly to mapping function and unspecified types (0) >> will result in 0 rss_hash_types. Of course, it is a question how to treat >> types==0. It is possible to say that it no RSS, but it does not make sense. >> So, real options are device defaults (regardless configured on device level) >> or device config (rx_adv.conf.rss_conf.rss_hf). I would prefer the later. >> Please, document the intended behaviour in rte_flow.rst. > Granted the existing documentation doesn't say much on that topic, but a 0 > value for rss_hf does actually mean "no RSS" [4]: > > "The *rss_hf* field of the *rss_conf* structure indicates the different > types of IPv4/IPv6 packets to which the RSS hashing must be applied. > Supplying an *rss_hf* equal to zero disables the RSS feature." > > Now since this action doesn't use struct rte_eth_rss_conf anymore, we could > define 0 as a PMD-specific behavior, which could be no RSS. It would make > the API easier to use for applications that don't care about the RSS > capabilities of each underlying adapter, 0 would just work everywhere as a > safe default. PMD-specific is fine with some limits. It should be either device RSS config or device defaults. I think it is bad idea to allow types=0 disable RSS as an option of the PMD-specific behaviour. > [4] https://dpdk.org/doc/api/structrte__eth__rss__conf.html > >> If the later is chosen, above we'll have a bug since fallback to fixed >> default. >> Just use sa->rss_hash_types as fallback. Something like: >> if (rss->types) >> sfc_rss_conf->rss_hash_types = sfc_rte_to_efx_hash_type(rss->types); >> else >> sfc_rss_conf->rss_hash_types =sa->rss_hash_types; > Looks like the previous code didn't provide a fallback when rss_hf was 0, > only when rss_conf itself was NULL. So this is not a new issue introduced by > this patch. Yes, I agree. > I will update documentation to define 0 as described above for the > convenience of application writers and leave the existing code in place. > PMD maintainers will be free to enhance it as they wish later. > Just remember testpmd now always provides a default value for it after > querying the device [2]. Many thanks. ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v2 08/15] ethdev: add hash function to RSS flow API action 2018-04-06 13:25 ` [dpdk-dev] [PATCH v2 00/15] Flow API overhaul for switch offloads Adrien Mazarguil ` (6 preceding siblings ...) 2018-04-06 13:25 ` [dpdk-dev] [PATCH v2 07/15] ethdev: flatten RSS configuration in " Adrien Mazarguil @ 2018-04-06 13:25 ` Adrien Mazarguil 2018-04-06 15:41 ` Andrew Rybchenko 2018-04-06 13:25 ` [dpdk-dev] [PATCH v2 09/15] ethdev: add encap level " Adrien Mazarguil ` (7 subsequent siblings) 15 siblings, 1 reply; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-06 13:25 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev Cc: Wenzhuo Lu, Jingjing Wu, Beilei Xing, Qi Zhang, Konstantin Ananyev, Nelio Laranjeiro, Yongseok Koh, Andrew Rybchenko, Pascal Mazon By definition, RSS involves some kind of hash algorithm, usually Toeplitz. Until now it could not be modified on a flow rule basis and PMDs had to always assume RTE_ETH_HASH_FUNCTION_DEFAULT, which remains the default behavior when unspecified (0). This breaks ABI compatibility for the following public functions: - rte_flow_copy() - rte_flow_create() - rte_flow_query() - rte_flow_validate() Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Cc: Ferruh Yigit <ferruh.yigit@intel.com> Cc: Thomas Monjalon <thomas@monjalon.net> Cc: Wenzhuo Lu <wenzhuo.lu@intel.com> Cc: Jingjing Wu <jingjing.wu@intel.com> Cc: Beilei Xing <beilei.xing@intel.com> Cc: Qi Zhang <qi.z.zhang@intel.com> Cc: Konstantin Ananyev <konstantin.ananyev@intel.com> Cc: Nelio Laranjeiro <nelio.laranjeiro@6wind.com> Cc: Yongseok Koh <yskoh@mellanox.com> Cc: Andrew Rybchenko <arybchenko@solarflare.com> Cc: Pascal Mazon <pascal.mazon@6wind.com> --- app/test-pmd/cmdline_flow.c | 72 ++++++++++++++++++++++++ app/test-pmd/config.c | 1 + doc/guides/prog_guide/rte_flow.rst | 2 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 3 + drivers/net/e1000/igb_flow.c | 4 ++ drivers/net/e1000/igb_rxtx.c | 4 +- drivers/net/i40e/i40e_ethdev.c | 4 +- drivers/net/i40e/i40e_flow.c | 4 ++ drivers/net/ixgbe/ixgbe_flow.c | 4 ++ drivers/net/ixgbe/ixgbe_rxtx.c | 4 +- drivers/net/mlx4/mlx4_flow.c | 7 +++ drivers/net/mlx5/mlx5_flow.c | 13 +++++ drivers/net/sfc/sfc_flow.c | 3 + drivers/net/tap/tap_flow.c | 6 ++ lib/librte_ether/rte_flow.c | 1 + lib/librte_ether/rte_flow.h | 2 + 16 files changed, 131 insertions(+), 3 deletions(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 0322f36c4..23e10d623 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -14,6 +14,7 @@ #include <sys/socket.h> #include <rte_common.h> +#include <rte_eth_ctrl.h> #include <rte_ethdev.h> #include <rte_byteorder.h> #include <cmdline_parse.h> @@ -165,6 +166,10 @@ enum index { ACTION_DROP, ACTION_COUNT, ACTION_RSS, + ACTION_RSS_FUNC, + ACTION_RSS_FUNC_DEFAULT, + ACTION_RSS_FUNC_TOEPLITZ, + ACTION_RSS_FUNC_SIMPLE_XOR, ACTION_RSS_TYPES, ACTION_RSS_TYPE, ACTION_RSS_KEY, @@ -632,6 +637,7 @@ static const enum index action_queue[] = { }; static const enum index action_rss[] = { + ACTION_RSS_FUNC, ACTION_RSS_TYPES, ACTION_RSS_KEY, ACTION_RSS_KEY_LEN, @@ -666,6 +672,9 @@ static int parse_vc_conf(struct context *, const struct token *, static int parse_vc_action_rss(struct context *, const struct token *, const char *, unsigned int, void *, unsigned int); +static int parse_vc_action_rss_func(struct context *, const struct token *, + const char *, unsigned int, void *, + unsigned int); static int parse_vc_action_rss_type(struct context *, const struct token *, const char *, unsigned int, void *, unsigned int); @@ -1584,6 +1593,29 @@ static const struct token token_list[] = { .next = NEXT(action_rss), .call = parse_vc_action_rss, }, + [ACTION_RSS_FUNC] = { + .name = "func", + .help = "RSS hash function to apply", + .next = NEXT(action_rss, + NEXT_ENTRY(ACTION_RSS_FUNC_DEFAULT, + ACTION_RSS_FUNC_TOEPLITZ, + ACTION_RSS_FUNC_SIMPLE_XOR)), + }, + [ACTION_RSS_FUNC_DEFAULT] = { + .name = "default", + .help = "default hash function", + .call = parse_vc_action_rss_func, + }, + [ACTION_RSS_FUNC_TOEPLITZ] = { + .name = "toeplitz", + .help = "Toeplitz hash function", + .call = parse_vc_action_rss_func, + }, + [ACTION_RSS_FUNC_SIMPLE_XOR] = { + .name = "simple_xor", + .help = "simple XOR hash function", + .call = parse_vc_action_rss_func, + }, [ACTION_RSS_TYPES] = { .name = "types", .help = "RSS hash types", @@ -2074,6 +2106,7 @@ parse_vc_action_rss(struct context *ctx, const struct token *token, action_rss_data = ctx->object; *action_rss_data = (struct action_rss_data){ .conf = (struct rte_flow_action_rss){ + .func = RTE_ETH_HASH_FUNCTION_DEFAULT, .types = rss_hf, .key_len = sizeof(action_rss_data->key), .queue_num = RTE_MIN(nb_rxq, ACTION_RSS_QUEUE_NUM), @@ -2111,6 +2144,45 @@ parse_vc_action_rss(struct context *ctx, const struct token *token, } /** + * Parse func field for RSS action. + * + * The RTE_ETH_HASH_FUNCTION_* value to assign is derived from the + * ACTION_RSS_FUNC_* index that called this function. + */ +static int +parse_vc_action_rss_func(struct context *ctx, const struct token *token, + const char *str, unsigned int len, + void *buf, unsigned int size) +{ + struct action_rss_data *action_rss_data; + enum rte_eth_hash_function func; + + (void)buf; + (void)size; + /* Token name must match. */ + if (parse_default(ctx, token, str, len, NULL, 0) < 0) + return -1; + switch (ctx->curr) { + case ACTION_RSS_FUNC_DEFAULT: + func = RTE_ETH_HASH_FUNCTION_DEFAULT; + break; + case ACTION_RSS_FUNC_TOEPLITZ: + func = RTE_ETH_HASH_FUNCTION_TOEPLITZ; + break; + case ACTION_RSS_FUNC_SIMPLE_XOR: + func = RTE_ETH_HASH_FUNCTION_SIMPLE_XOR; + break; + default: + return -1; + } + if (!ctx->object) + return len; + action_rss_data = ctx->object; + action_rss_data->conf.func = func; + return len; +} + +/** * Parse type field for RSS action. * * Valid tokens are type field names and the "end" token. diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 717f31774..b258c93e8 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -1084,6 +1084,7 @@ flow_action_conf_copy(void *buf, const struct rte_flow_action *action) off = 0; if (dst.rss) *dst.rss = (struct rte_flow_action_rss){ + .func = src.rss->func, .types = src.rss->types, .key_len = src.rss->key_len, .queue_num = src.rss->queue_num, diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 5ce041d91..7a97ced2a 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -1312,6 +1312,8 @@ field only, both can be requested simultaneously. +---------------+------------------------------------+ | Field | Value | +===============+====================================+ + | ``func`` | RSS hash function to apply | + +---------------+------------------------------------+ | ``types`` | RSS hash types (see ``ETH_RSS_*``) | +---------------+------------------------------------+ | ``key_len`` | hash key length in bytes | diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index a015d02a4..d9d68ad9b 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3398,6 +3398,9 @@ This section lists supported actions and their attributes, if any. - ``rss``: spread packets among several queues. + - ``func {hash function}``: RSS hash function to apply, allowed tokens are + the same as `set_hash_global_config`_. + - ``types [{RSS hash type} [...]] end``: RSS hash types, allowed tokens are the same as `set_hash_input_set`_, an empty list means none (0). diff --git a/drivers/net/e1000/igb_flow.c b/drivers/net/e1000/igb_flow.c index 8dc5f75f2..747c524f5 100644 --- a/drivers/net/e1000/igb_flow.c +++ b/drivers/net/e1000/igb_flow.c @@ -1310,6 +1310,10 @@ igb_parse_rss_filter(struct rte_eth_dev *dev, } } + if (rss->func) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, + "non-default RSS hash functions are not supported"); if (rss->key_len && rss->key_len != RTE_DIM(rss_conf->key)) return rte_flow_error_set (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, diff --git a/drivers/net/e1000/igb_rxtx.c b/drivers/net/e1000/igb_rxtx.c index 45bb3455c..d5c1cd3d3 100644 --- a/drivers/net/e1000/igb_rxtx.c +++ b/drivers/net/e1000/igb_rxtx.c @@ -2905,6 +2905,7 @@ igb_rss_conf_init(struct igb_rte_flow_rss_conf *out, in->queue_num > RTE_DIM(out->queue)) return -EINVAL; out->conf = (struct rte_flow_action_rss){ + .func = in->func, .types = in->types, .key_len = in->key_len, .queue_num = in->queue_num, @@ -2919,7 +2920,8 @@ int igb_action_rss_same(const struct rte_flow_action_rss *comp, const struct rte_flow_action_rss *with) { - return (comp->types == with->types && + return (comp->func == with->func && + comp->types == with->types && comp->key_len == with->key_len && comp->queue_num == with->queue_num && !memcmp(comp->key, with->key, with->key_len) && diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index 0242b5d59..5e313950c 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c @@ -11974,6 +11974,7 @@ i40e_rss_conf_init(struct i40e_rte_flow_rss_conf *out, in->queue_num > RTE_DIM(out->queue)) return -EINVAL; out->conf = (struct rte_flow_action_rss){ + .func = in->func, .types = in->types, .key_len = in->key_len, .queue_num = in->queue_num, @@ -11988,7 +11989,8 @@ int i40e_action_rss_same(const struct rte_flow_action_rss *comp, const struct rte_flow_action_rss *with) { - return (comp->types == with->types && + return (comp->func == with->func && + comp->types == with->types && comp->key_len == with->key_len && comp->queue_num == with->queue_num && !memcmp(comp->key, with->key, with->key_len) && diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c index 1c09f8121..0a6ed0f2e 100644 --- a/drivers/net/i40e/i40e_flow.c +++ b/drivers/net/i40e/i40e_flow.c @@ -4326,6 +4326,10 @@ i40e_flow_parse_rss_action(struct rte_eth_dev *dev, } } + if (rss->func) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, + "non-default RSS hash functions are not supported"); if (rss->key_len && rss->key_len > RTE_DIM(rss_config->key)) return rte_flow_error_set (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, diff --git a/drivers/net/ixgbe/ixgbe_flow.c b/drivers/net/ixgbe/ixgbe_flow.c index 4e31c7c56..10056a0f7 100644 --- a/drivers/net/ixgbe/ixgbe_flow.c +++ b/drivers/net/ixgbe/ixgbe_flow.c @@ -2779,6 +2779,10 @@ ixgbe_parse_rss_filter(struct rte_eth_dev *dev, } } + if (rss->func) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, + "non-default RSS hash functions are not supported"); if (rss->key_len && rss->key_len != RTE_DIM(rss_conf->key)) return rte_flow_error_set (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, diff --git a/drivers/net/ixgbe/ixgbe_rxtx.c b/drivers/net/ixgbe/ixgbe_rxtx.c index 94ea7444d..e17f5a433 100644 --- a/drivers/net/ixgbe/ixgbe_rxtx.c +++ b/drivers/net/ixgbe/ixgbe_rxtx.c @@ -5682,6 +5682,7 @@ ixgbe_rss_conf_init(struct ixgbe_rte_flow_rss_conf *out, in->queue_num > RTE_DIM(out->queue)) return -EINVAL; out->conf = (struct rte_flow_action_rss){ + .func = in->func, .types = in->types, .key_len = in->key_len, .queue_num = in->queue_num, @@ -5696,7 +5697,8 @@ int ixgbe_action_rss_same(const struct rte_flow_action_rss *comp, const struct rte_flow_action_rss *with) { - return (comp->types == with->types && + return (comp->func == with->func && + comp->types == with->types && comp->key_len == with->key_len && comp->queue_num == with->queue_num && !memcmp(comp->key, with->key, with->key_len) && diff --git a/drivers/net/mlx4/mlx4_flow.c b/drivers/net/mlx4/mlx4_flow.c index 4dbcaa39c..dcaf8df44 100644 --- a/drivers/net/mlx4/mlx4_flow.c +++ b/drivers/net/mlx4/mlx4_flow.c @@ -790,6 +790,12 @@ mlx4_flow_prepare(struct priv *priv, " of the context size"; goto exit_action_not_supported; } + if (rss->func && + rss->func != RTE_ETH_HASH_FUNCTION_TOEPLITZ) { + msg = "the only supported RSS hash function" + " is Toeplitz"; + goto exit_action_not_supported; + } rte_errno = 0; fields = mlx4_conv_rss_types(priv, rss->types); if (fields == (uint64_t)-1 && rte_errno) { @@ -1283,6 +1289,7 @@ mlx4_flow_internal(struct priv *priv, struct rte_flow_error *error) rte_align32pow2(priv->dev->data->nb_rx_queues + 1) >> 1; uint16_t queue[queues]; struct rte_flow_action_rss action_rss = { + .func = RTE_ETH_HASH_FUNCTION_DEFAULT, .types = -1, .key_len = MLX4_RSS_HASH_KEY_SIZE, .queue_num = queues, diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 7798052f9..0771ad339 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -18,6 +18,7 @@ #endif #include <rte_common.h> +#include <rte_eth_ctrl.h> #include <rte_ethdev_driver.h> #include <rte_flow.h> #include <rte_flow_driver.h> @@ -634,6 +635,15 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, if (overlap & FATE) goto exit_action_overlap; overlap |= FATE; + if (rss->func && + rss->func != RTE_ETH_HASH_FUNCTION_TOEPLITZ) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION, + actions, + "the only supported RSS hash" + " function is Toeplitz"); + return -rte_errno; + } if (rss->types & MLX5_RSS_HF_MASK) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, @@ -683,6 +693,7 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, } } parser->rss_conf = (struct rte_flow_action_rss){ + .func = RTE_ETH_HASH_FUNCTION_DEFAULT, .types = rss->types, .key_len = rss_key_len, .queue_num = rss->queue_num, @@ -1915,6 +1926,7 @@ mlx5_flow_list_create(struct rte_eth_dev *dev, /* Copy configuration. */ flow->queues = (uint16_t (*)[])(flow + 1); flow->rss_conf = (struct rte_flow_action_rss){ + .func = RTE_ETH_HASH_FUNCTION_DEFAULT, .types = parser.rss_conf.types, .key_len = parser.rss_conf.key_len, .queue_num = parser.rss_conf.queue_num, @@ -2429,6 +2441,7 @@ mlx5_ctrl_flow_vlan(struct rte_eth_dev *dev, }; uint16_t queue[priv->reta_idx_n]; struct rte_flow_action_rss action_rss = { + .func = RTE_ETH_HASH_FUNCTION_DEFAULT, .types = priv->rss_conf.rss_hf, .key_len = priv->rss_conf.rss_key_len, .queue_num = priv->reta_idx_n, diff --git a/drivers/net/sfc/sfc_flow.c b/drivers/net/sfc/sfc_flow.c index 1a2c0299c..dbe4c2baa 100644 --- a/drivers/net/sfc/sfc_flow.c +++ b/drivers/net/sfc/sfc_flow.c @@ -1261,6 +1261,9 @@ sfc_flow_parse_rss(struct sfc_adapter *sa, rxq_hw_index_max = rxq->hw_index; } + if (rss->func) + return -EINVAL; + if ((rss->types & ~SFC_RSS_OFFLOADS) != 0) return -EINVAL; diff --git a/drivers/net/tap/tap_flow.c b/drivers/net/tap/tap_flow.c index 78f20913f..3d91da216 100644 --- a/drivers/net/tap/tap_flow.c +++ b/drivers/net/tap/tap_flow.c @@ -2055,6 +2055,12 @@ static int rss_add_actions(struct rte_flow *flow, struct pmd_internals *pmd, struct rss_key rss_entry = { .hash_fields = 0, .key_size = 0 }; + /* Check supported hash functions */ + if (rss->func) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, + "non-default RSS hash functions are not supported"); + /* Get a new map key for a new RSS rule */ err = bpf_rss_key(KEY_CMD_GET, &flow->key_idx); if (err < 0) { diff --git a/lib/librte_ether/rte_flow.c b/lib/librte_ether/rte_flow.c index 2fabc9a29..0a2c0ac00 100644 --- a/lib/librte_ether/rte_flow.c +++ b/lib/librte_ether/rte_flow.c @@ -330,6 +330,7 @@ flow_action_conf_copy(void *buf, const struct rte_flow_action *action) off = 0; if (dst.rss) *dst.rss = (struct rte_flow_action_rss){ + .func = src.rss->func, .types = src.rss->types, .key_len = src.rss->key_len, .queue_num = src.rss->queue_num, diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index e2eba9c26..66cadc74e 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -19,6 +19,7 @@ #include <rte_arp.h> #include <rte_ether.h> +#include <rte_eth_ctrl.h> #include <rte_icmp.h> #include <rte_ip.h> #include <rte_sctp.h> @@ -1038,6 +1039,7 @@ struct rte_flow_query_count { * both can be requested simultaneously. */ struct rte_flow_action_rss { + enum rte_eth_hash_function func; /**< RSS hash function to apply. */ uint64_t types; /**< RSS hash types (see ETH_RSS_*). */ uint32_t key_len; /**< Hash key length in bytes. */ uint32_t queue_num; /**< Number of entries in @p queue. */ -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [dpdk-dev] [PATCH v2 08/15] ethdev: add hash function to RSS flow API action 2018-04-06 13:25 ` [dpdk-dev] [PATCH v2 08/15] ethdev: add hash function to RSS flow API action Adrien Mazarguil @ 2018-04-06 15:41 ` Andrew Rybchenko 2018-04-09 14:41 ` Adrien Mazarguil 0 siblings, 1 reply; 157+ messages in thread From: Andrew Rybchenko @ 2018-04-06 15:41 UTC (permalink / raw) To: Adrien Mazarguil, Thomas Monjalon, Ferruh Yigit, dev Cc: Wenzhuo Lu, Jingjing Wu, Beilei Xing, Qi Zhang, Konstantin Ananyev, Nelio Laranjeiro, Yongseok Koh, Pascal Mazon On 04/06/2018 04:25 PM, Adrien Mazarguil wrote: > By definition, RSS involves some kind of hash algorithm, usually Toeplitz. > > Until now it could not be modified on a flow rule basis and PMDs had to > always assume RTE_ETH_HASH_FUNCTION_DEFAULT, which remains the default > behavior when unspecified (0). > > This breaks ABI compatibility for the following public functions: > > - rte_flow_copy() > - rte_flow_create() > - rte_flow_query() > - rte_flow_validate() > > Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> > Cc: Ferruh Yigit <ferruh.yigit@intel.com> > Cc: Thomas Monjalon <thomas@monjalon.net> > Cc: Wenzhuo Lu <wenzhuo.lu@intel.com> > Cc: Jingjing Wu <jingjing.wu@intel.com> > Cc: Beilei Xing <beilei.xing@intel.com> > Cc: Qi Zhang <qi.z.zhang@intel.com> > Cc: Konstantin Ananyev <konstantin.ananyev@intel.com> > Cc: Nelio Laranjeiro <nelio.laranjeiro@6wind.com> > Cc: Yongseok Koh <yskoh@mellanox.com> > Cc: Andrew Rybchenko <arybchenko@solarflare.com> > Cc: Pascal Mazon <pascal.mazon@6wind.com> > --- > app/test-pmd/cmdline_flow.c | 72 ++++++++++++++++++++++++ > app/test-pmd/config.c | 1 + > doc/guides/prog_guide/rte_flow.rst | 2 + > doc/guides/testpmd_app_ug/testpmd_funcs.rst | 3 + > drivers/net/e1000/igb_flow.c | 4 ++ > drivers/net/e1000/igb_rxtx.c | 4 +- > drivers/net/i40e/i40e_ethdev.c | 4 +- > drivers/net/i40e/i40e_flow.c | 4 ++ > drivers/net/ixgbe/ixgbe_flow.c | 4 ++ > drivers/net/ixgbe/ixgbe_rxtx.c | 4 +- > drivers/net/mlx4/mlx4_flow.c | 7 +++ > drivers/net/mlx5/mlx5_flow.c | 13 +++++ > drivers/net/sfc/sfc_flow.c | 3 + > drivers/net/tap/tap_flow.c | 6 ++ > lib/librte_ether/rte_flow.c | 1 + > lib/librte_ether/rte_flow.h | 2 + > 16 files changed, 131 insertions(+), 3 deletions(-) <...> > diff --git a/drivers/net/sfc/sfc_flow.c b/drivers/net/sfc/sfc_flow.c > index 1a2c0299c..dbe4c2baa 100644 > --- a/drivers/net/sfc/sfc_flow.c > +++ b/drivers/net/sfc/sfc_flow.c > @@ -1261,6 +1261,9 @@ sfc_flow_parse_rss(struct sfc_adapter *sa, > rxq_hw_index_max = rxq->hw_index; > } > > + if (rss->func) May be it is better to compare with RTE_ETH_HASH_FUNCTION_DEFAULT explicitly? I think it is more readable. If so, it is applicable to all similar checks in the patch. In the case of sfc, please, allow RTE_ETH_HASH_FUNCTION_TOEPLITZ as well. I'd suggest: switch (rss->func) { case RTE_ETH_HASH_FUNCTION_DEFAULT: case RTE_ETH_HASH_FUNCTION_TOEPLITZ: break; default: return -EINVAL; } > + return -EINVAL; > + > if ((rss->types & ~SFC_RSS_OFFLOADS) != 0) > return -EINVAL; > <...> ^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [dpdk-dev] [PATCH v2 08/15] ethdev: add hash function to RSS flow API action 2018-04-06 15:41 ` Andrew Rybchenko @ 2018-04-09 14:41 ` Adrien Mazarguil 0 siblings, 0 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-09 14:41 UTC (permalink / raw) To: Andrew Rybchenko Cc: Thomas Monjalon, Ferruh Yigit, dev, Wenzhuo Lu, Jingjing Wu, Beilei Xing, Qi Zhang, Konstantin Ananyev, Nelio Laranjeiro, Yongseok Koh, Pascal Mazon On Fri, Apr 06, 2018 at 06:41:35PM +0300, Andrew Rybchenko wrote: > On 04/06/2018 04:25 PM, Adrien Mazarguil wrote: > > By definition, RSS involves some kind of hash algorithm, usually Toeplitz. > > > > Until now it could not be modified on a flow rule basis and PMDs had to > > always assume RTE_ETH_HASH_FUNCTION_DEFAULT, which remains the default > > behavior when unspecified (0). > > > > This breaks ABI compatibility for the following public functions: > > > > - rte_flow_copy() > > - rte_flow_create() > > - rte_flow_query() > > - rte_flow_validate() > > > > Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> > > Cc: Ferruh Yigit <ferruh.yigit@intel.com> > > Cc: Thomas Monjalon <thomas@monjalon.net> > > Cc: Wenzhuo Lu <wenzhuo.lu@intel.com> > > Cc: Jingjing Wu <jingjing.wu@intel.com> > > Cc: Beilei Xing <beilei.xing@intel.com> > > Cc: Qi Zhang <qi.z.zhang@intel.com> > > Cc: Konstantin Ananyev <konstantin.ananyev@intel.com> > > Cc: Nelio Laranjeiro <nelio.laranjeiro@6wind.com> > > Cc: Yongseok Koh <yskoh@mellanox.com> > > Cc: Andrew Rybchenko <arybchenko@solarflare.com> > > Cc: Pascal Mazon <pascal.mazon@6wind.com> > > --- > > app/test-pmd/cmdline_flow.c | 72 ++++++++++++++++++++++++ > > app/test-pmd/config.c | 1 + > > doc/guides/prog_guide/rte_flow.rst | 2 + > > doc/guides/testpmd_app_ug/testpmd_funcs.rst | 3 + > > drivers/net/e1000/igb_flow.c | 4 ++ > > drivers/net/e1000/igb_rxtx.c | 4 +- > > drivers/net/i40e/i40e_ethdev.c | 4 +- > > drivers/net/i40e/i40e_flow.c | 4 ++ > > drivers/net/ixgbe/ixgbe_flow.c | 4 ++ > > drivers/net/ixgbe/ixgbe_rxtx.c | 4 +- > > drivers/net/mlx4/mlx4_flow.c | 7 +++ > > drivers/net/mlx5/mlx5_flow.c | 13 +++++ > > drivers/net/sfc/sfc_flow.c | 3 + > > drivers/net/tap/tap_flow.c | 6 ++ > > lib/librte_ether/rte_flow.c | 1 + > > lib/librte_ether/rte_flow.h | 2 + > > 16 files changed, 131 insertions(+), 3 deletions(-) > > <...> > > > diff --git a/drivers/net/sfc/sfc_flow.c b/drivers/net/sfc/sfc_flow.c > > index 1a2c0299c..dbe4c2baa 100644 > > --- a/drivers/net/sfc/sfc_flow.c > > +++ b/drivers/net/sfc/sfc_flow.c > > @@ -1261,6 +1261,9 @@ sfc_flow_parse_rss(struct sfc_adapter *sa, > > rxq_hw_index_max = rxq->hw_index; > > } > > + if (rss->func) > > May be it is better to compare with RTE_ETH_HASH_FUNCTION_DEFAULT > explicitly? I think it is more readable. If so, it is applicable to all > similar checks > in the patch. Good suggestion, although RTE_ETH_HASH_FUNCTION_DEFAULT can't be anything other than 0 for various reasons, I'll clarify (most of) the code in my next update. > In the case of sfc, please, allow RTE_ETH_HASH_FUNCTION_TOEPLITZ as well. > I'd suggest: > switch (rss->func) { > case RTE_ETH_HASH_FUNCTION_DEFAULT: > case RTE_ETH_HASH_FUNCTION_TOEPLITZ: > break; > default: > return -EINVAL; > } I'll add it, thanks. -- Adrien Mazarguil 6WIND ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v2 09/15] ethdev: add encap level to RSS flow API action 2018-04-06 13:25 ` [dpdk-dev] [PATCH v2 00/15] Flow API overhaul for switch offloads Adrien Mazarguil ` (7 preceding siblings ...) 2018-04-06 13:25 ` [dpdk-dev] [PATCH v2 08/15] ethdev: add hash function to RSS flow API action Adrien Mazarguil @ 2018-04-06 13:25 ` Adrien Mazarguil 2018-04-07 8:27 ` Andrew Rybchenko 2018-04-06 13:25 ` [dpdk-dev] [PATCH v2 10/15] ethdev: refine TPID handling in flow API Adrien Mazarguil ` (6 subsequent siblings) 15 siblings, 1 reply; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-06 13:25 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev Cc: Xueming Li, Wenzhuo Lu, Jingjing Wu, Beilei Xing, Qi Zhang, Konstantin Ananyev, Nelio Laranjeiro, Yongseok Koh, Andrew Rybchenko, Pascal Mazon RSS hash types (ETH_RSS_* macros defined in rte_ethdev.h) describe the protocol header fields of a packet that must be taken into account while computing RSS. When facing encapsulated (e.g. tunneled) packets, there is an ambiguity as to whether these should apply to inner or outer packets. Applications need the ability to tell exactly "where" RSS must be performed. This is addressed by adding encapsulation level information to the RSS flow action. Its default value is 0 and stands for the usual unspecified behavior. Other values provide a specific encapsulation level. Contrary to the change announced by commit 676b605182a5 ("doc: announce ethdev API change for RSS configuration"), this patch does not affect struct rte_eth_rss_conf but struct rte_flow_action_rss as the former is not used anymore by the RSS flow action. ABI impact is therefore limited to rte_flow. This breaks ABI compatibility for the following public functions: - rte_flow_copy() - rte_flow_create() - rte_flow_query() - rte_flow_validate() Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Cc: Xueming Li <xuemingl@mellanox.com> Cc: Ferruh Yigit <ferruh.yigit@intel.com> Cc: Thomas Monjalon <thomas@monjalon.net> Cc: Wenzhuo Lu <wenzhuo.lu@intel.com> Cc: Jingjing Wu <jingjing.wu@intel.com> Cc: Beilei Xing <beilei.xing@intel.com> Cc: Qi Zhang <qi.z.zhang@intel.com> Cc: Konstantin Ananyev <konstantin.ananyev@intel.com> Cc: Nelio Laranjeiro <nelio.laranjeiro@6wind.com> Cc: Yongseok Koh <yskoh@mellanox.com> Cc: Andrew Rybchenko <arybchenko@solarflare.com> Cc: Pascal Mazon <pascal.mazon@6wind.com> --- app/test-pmd/cmdline_flow.c | 13 ++++++++++++ app/test-pmd/config.c | 1 + doc/guides/prog_guide/rte_flow.rst | 24 ++++++++++++++++++++++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 2 ++ drivers/net/e1000/igb_flow.c | 4 ++++ drivers/net/e1000/igb_rxtx.c | 2 ++ drivers/net/i40e/i40e_ethdev.c | 2 ++ drivers/net/i40e/i40e_flow.c | 4 ++++ drivers/net/ixgbe/ixgbe_flow.c | 4 ++++ drivers/net/ixgbe/ixgbe_rxtx.c | 2 ++ drivers/net/mlx4/mlx4_flow.c | 6 ++++++ drivers/net/mlx5/mlx5_flow.c | 11 ++++++++++ drivers/net/sfc/sfc_flow.c | 3 +++ drivers/net/tap/tap_flow.c | 6 +++++- lib/librte_ether/rte_flow.c | 1 + lib/librte_ether/rte_flow.h | 26 ++++++++++++++++++++++++ 16 files changed, 110 insertions(+), 1 deletion(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 23e10d623..2fbd3d8ef 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -167,6 +167,7 @@ enum index { ACTION_COUNT, ACTION_RSS, ACTION_RSS_FUNC, + ACTION_RSS_LEVEL, ACTION_RSS_FUNC_DEFAULT, ACTION_RSS_FUNC_TOEPLITZ, ACTION_RSS_FUNC_SIMPLE_XOR, @@ -638,6 +639,7 @@ static const enum index action_queue[] = { static const enum index action_rss[] = { ACTION_RSS_FUNC, + ACTION_RSS_LEVEL, ACTION_RSS_TYPES, ACTION_RSS_KEY, ACTION_RSS_KEY_LEN, @@ -1616,6 +1618,16 @@ static const struct token token_list[] = { .help = "simple XOR hash function", .call = parse_vc_action_rss_func, }, + [ACTION_RSS_LEVEL] = { + .name = "level", + .help = "encapsulation level for \"types\"", + .next = NEXT(action_rss, NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY_ARB + (offsetof(struct action_rss_data, conf) + + offsetof(struct rte_flow_action_rss, level), + sizeof(((struct rte_flow_action_rss *)0)-> + level))), + }, [ACTION_RSS_TYPES] = { .name = "types", .help = "RSS hash types", @@ -2107,6 +2119,7 @@ parse_vc_action_rss(struct context *ctx, const struct token *token, *action_rss_data = (struct action_rss_data){ .conf = (struct rte_flow_action_rss){ .func = RTE_ETH_HASH_FUNCTION_DEFAULT, + .level = 0, .types = rss_hf, .key_len = sizeof(action_rss_data->key), .queue_num = RTE_MIN(nb_rxq, ACTION_RSS_QUEUE_NUM), diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index b258c93e8..c0fefe475 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -1085,6 +1085,7 @@ flow_action_conf_copy(void *buf, const struct rte_flow_action *action) if (dst.rss) *dst.rss = (struct rte_flow_action_rss){ .func = src.rss->func, + .level = src.rss->level, .types = src.rss->types, .key_len = src.rss->key_len, .queue_num = src.rss->queue_num, diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 7a97ced2a..97d429ee5 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -1305,6 +1305,28 @@ Note: RSS hash result is stored in the ``hash.rss`` mbuf field which overlaps ``hash.fdir.lo``. Since `Action: MARK`_ sets the ``hash.fdir.hi`` field only, both can be requested simultaneously. +Also, regarding packet encapsulation ``level``: + +- ``0`` requests the default behavior. Depending on the packet type, it can + mean outermost, innermost, anything in between or even no RSS. + + It basically stands for the innermost encapsulation level RSS can be + performed on according to PMD and device capabilities. + +- ``1`` requests RSS to be performed on the outermost packet encapsulation + level. + +- ``2`` and subsequent values request RSS to be performed on the specified + inner packet encapsulation level, from outermost to innermost (lower to + higher values). + +Values other than ``0`` are not necessarily supported. + +Requesting a specific RSS level on unrecognized traffic results in undefined +behavior. For predictable results, it is recommended to make the flow rule +pattern match packet headers up to the requested encapsulation level so that +only matching traffic goes through. + .. _table_rte_flow_action_rss: .. table:: RSS @@ -1314,6 +1336,8 @@ field only, both can be requested simultaneously. +===============+====================================+ | ``func`` | RSS hash function to apply | +---------------+------------------------------------+ + | ``level`` | encapsulation level for ``types`` | + +---------------+------------------------------------+ | ``types`` | RSS hash types (see ``ETH_RSS_*``) | +---------------+------------------------------------+ | ``key_len`` | hash key length in bytes | diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index d9d68ad9b..738461f44 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3401,6 +3401,8 @@ This section lists supported actions and their attributes, if any. - ``func {hash function}``: RSS hash function to apply, allowed tokens are the same as `set_hash_global_config`_. + - ``level {unsigned}``: encapsulation level for ``types``. + - ``types [{RSS hash type} [...]] end``: RSS hash types, allowed tokens are the same as `set_hash_input_set`_, an empty list means none (0). diff --git a/drivers/net/e1000/igb_flow.c b/drivers/net/e1000/igb_flow.c index 747c524f5..13f6f2a28 100644 --- a/drivers/net/e1000/igb_flow.c +++ b/drivers/net/e1000/igb_flow.c @@ -1314,6 +1314,10 @@ igb_parse_rss_filter(struct rte_eth_dev *dev, return rte_flow_error_set (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, "non-default RSS hash functions are not supported"); + if (rss->level) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, + "a nonzero RSS encapsulation level is not supported"); if (rss->key_len && rss->key_len != RTE_DIM(rss_conf->key)) return rte_flow_error_set (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, diff --git a/drivers/net/e1000/igb_rxtx.c b/drivers/net/e1000/igb_rxtx.c index d5c1cd3d3..a3776a0d7 100644 --- a/drivers/net/e1000/igb_rxtx.c +++ b/drivers/net/e1000/igb_rxtx.c @@ -2906,6 +2906,7 @@ igb_rss_conf_init(struct igb_rte_flow_rss_conf *out, return -EINVAL; out->conf = (struct rte_flow_action_rss){ .func = in->func, + .level = in->level, .types = in->types, .key_len = in->key_len, .queue_num = in->queue_num, @@ -2921,6 +2922,7 @@ igb_action_rss_same(const struct rte_flow_action_rss *comp, const struct rte_flow_action_rss *with) { return (comp->func == with->func && + comp->level == with->level && comp->types == with->types && comp->key_len == with->key_len && comp->queue_num == with->queue_num && diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index 5e313950c..b104b551c 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c @@ -11975,6 +11975,7 @@ i40e_rss_conf_init(struct i40e_rte_flow_rss_conf *out, return -EINVAL; out->conf = (struct rte_flow_action_rss){ .func = in->func, + .level = in->level, .types = in->types, .key_len = in->key_len, .queue_num = in->queue_num, @@ -11990,6 +11991,7 @@ i40e_action_rss_same(const struct rte_flow_action_rss *comp, const struct rte_flow_action_rss *with) { return (comp->func == with->func && + comp->level == with->level && comp->types == with->types && comp->key_len == with->key_len && comp->queue_num == with->queue_num && diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c index 0a6ed0f2e..c0a2bc4a6 100644 --- a/drivers/net/i40e/i40e_flow.c +++ b/drivers/net/i40e/i40e_flow.c @@ -4330,6 +4330,10 @@ i40e_flow_parse_rss_action(struct rte_eth_dev *dev, return rte_flow_error_set (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, "non-default RSS hash functions are not supported"); + if (rss->level) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, + "a nonzero RSS encapsulation level is not supported"); if (rss->key_len && rss->key_len > RTE_DIM(rss_config->key)) return rte_flow_error_set (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, diff --git a/drivers/net/ixgbe/ixgbe_flow.c b/drivers/net/ixgbe/ixgbe_flow.c index 10056a0f7..67d22b382 100644 --- a/drivers/net/ixgbe/ixgbe_flow.c +++ b/drivers/net/ixgbe/ixgbe_flow.c @@ -2783,6 +2783,10 @@ ixgbe_parse_rss_filter(struct rte_eth_dev *dev, return rte_flow_error_set (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, "non-default RSS hash functions are not supported"); + if (rss->level) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, + "a nonzero RSS encapsulation level is not supported"); if (rss->key_len && rss->key_len != RTE_DIM(rss_conf->key)) return rte_flow_error_set (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, diff --git a/drivers/net/ixgbe/ixgbe_rxtx.c b/drivers/net/ixgbe/ixgbe_rxtx.c index e17f5a433..23af21712 100644 --- a/drivers/net/ixgbe/ixgbe_rxtx.c +++ b/drivers/net/ixgbe/ixgbe_rxtx.c @@ -5683,6 +5683,7 @@ ixgbe_rss_conf_init(struct ixgbe_rte_flow_rss_conf *out, return -EINVAL; out->conf = (struct rte_flow_action_rss){ .func = in->func, + .level = in->level, .types = in->types, .key_len = in->key_len, .queue_num = in->queue_num, @@ -5698,6 +5699,7 @@ ixgbe_action_rss_same(const struct rte_flow_action_rss *comp, const struct rte_flow_action_rss *with) { return (comp->func == with->func && + comp->level == with->level && comp->types == with->types && comp->key_len == with->key_len && comp->queue_num == with->queue_num && diff --git a/drivers/net/mlx4/mlx4_flow.c b/drivers/net/mlx4/mlx4_flow.c index dcaf8df44..779641e11 100644 --- a/drivers/net/mlx4/mlx4_flow.c +++ b/drivers/net/mlx4/mlx4_flow.c @@ -796,6 +796,11 @@ mlx4_flow_prepare(struct priv *priv, " is Toeplitz"; goto exit_action_not_supported; } + if (rss->level) { + msg = "a nonzero RSS encapsulation level is" + " not supported"; + goto exit_action_not_supported; + } rte_errno = 0; fields = mlx4_conv_rss_types(priv, rss->types); if (fields == (uint64_t)-1 && rte_errno) { @@ -1290,6 +1295,7 @@ mlx4_flow_internal(struct priv *priv, struct rte_flow_error *error) uint16_t queue[queues]; struct rte_flow_action_rss action_rss = { .func = RTE_ETH_HASH_FUNCTION_DEFAULT, + .level = 0, .types = -1, .key_len = MLX4_RSS_HASH_KEY_SIZE, .queue_num = queues, diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 0771ad339..bc1176819 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -644,6 +644,14 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, " function is Toeplitz"); return -rte_errno; } + if (rss->level) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION, + actions, + "a nonzero RSS encapsulation" + " level is not supported"); + return -rte_errno; + } if (rss->types & MLX5_RSS_HF_MASK) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, @@ -694,6 +702,7 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, } parser->rss_conf = (struct rte_flow_action_rss){ .func = RTE_ETH_HASH_FUNCTION_DEFAULT, + .level = 0, .types = rss->types, .key_len = rss_key_len, .queue_num = rss->queue_num, @@ -1927,6 +1936,7 @@ mlx5_flow_list_create(struct rte_eth_dev *dev, flow->queues = (uint16_t (*)[])(flow + 1); flow->rss_conf = (struct rte_flow_action_rss){ .func = RTE_ETH_HASH_FUNCTION_DEFAULT, + .level = 0, .types = parser.rss_conf.types, .key_len = parser.rss_conf.key_len, .queue_num = parser.rss_conf.queue_num, @@ -2442,6 +2452,7 @@ mlx5_ctrl_flow_vlan(struct rte_eth_dev *dev, uint16_t queue[priv->reta_idx_n]; struct rte_flow_action_rss action_rss = { .func = RTE_ETH_HASH_FUNCTION_DEFAULT, + .level = 0, .types = priv->rss_conf.rss_hf, .key_len = priv->rss_conf.rss_key_len, .queue_num = priv->reta_idx_n, diff --git a/drivers/net/sfc/sfc_flow.c b/drivers/net/sfc/sfc_flow.c index dbe4c2baa..bc4974edf 100644 --- a/drivers/net/sfc/sfc_flow.c +++ b/drivers/net/sfc/sfc_flow.c @@ -1264,6 +1264,9 @@ sfc_flow_parse_rss(struct sfc_adapter *sa, if (rss->func) return -EINVAL; + if (rss->level) + return -EINVAL; + if ((rss->types & ~SFC_RSS_OFFLOADS) != 0) return -EINVAL; diff --git a/drivers/net/tap/tap_flow.c b/drivers/net/tap/tap_flow.c index 3d91da216..e5eb50fc5 100644 --- a/drivers/net/tap/tap_flow.c +++ b/drivers/net/tap/tap_flow.c @@ -2055,11 +2055,15 @@ static int rss_add_actions(struct rte_flow *flow, struct pmd_internals *pmd, struct rss_key rss_entry = { .hash_fields = 0, .key_size = 0 }; - /* Check supported hash functions */ + /* Check supported RSS features */ if (rss->func) return rte_flow_error_set (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, "non-default RSS hash functions are not supported"); + if (rss->level) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, + "a nonzero RSS encapsulation level is not supported"); /* Get a new map key for a new RSS rule */ err = bpf_rss_key(KEY_CMD_GET, &flow->key_idx); diff --git a/lib/librte_ether/rte_flow.c b/lib/librte_ether/rte_flow.c index 0a2c0ac00..1f247d656 100644 --- a/lib/librte_ether/rte_flow.c +++ b/lib/librte_ether/rte_flow.c @@ -331,6 +331,7 @@ flow_action_conf_copy(void *buf, const struct rte_flow_action *action) if (dst.rss) *dst.rss = (struct rte_flow_action_rss){ .func = src.rss->func, + .level = src.rss->level, .types = src.rss->types, .key_len = src.rss->key_len, .queue_num = src.rss->queue_num, diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index 66cadc74e..fc7e6705d 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -1040,6 +1040,32 @@ struct rte_flow_query_count { */ struct rte_flow_action_rss { enum rte_eth_hash_function func; /**< RSS hash function to apply. */ + /** + * Packet encapsulation level RSS hash @p types apply to. + * + * - @p 0 requests the default behavior. Depending on the packet + * type, it can mean outermost, innermost, anything in between or + * even no RSS. + * + * It basically stands for the innermost encapsulation level RSS + * can be performed on according to PMD and device capabilities. + * + * - @p 1 requests RSS to be performed on the outermost packet + * encapsulation level. + * + * - @p 2 and subsequent values request RSS to be performed on the + * specified inner packet encapsulation level, from outermost to + * innermost (lower to higher values). + * + * Values other than @p 0 are not necessarily supported. + * + * Requesting a specific RSS level on unrecognized traffic results + * in undefined behavior. For predictable results, it is recommended + * to make the flow rule pattern match packet headers up to the + * requested encapsulation level so that only matching traffic goes + * through. + */ + uint32_t level; uint64_t types; /**< RSS hash types (see ETH_RSS_*). */ uint32_t key_len; /**< Hash key length in bytes. */ uint32_t queue_num; /**< Number of entries in @p queue. */ -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [dpdk-dev] [PATCH v2 09/15] ethdev: add encap level to RSS flow API action 2018-04-06 13:25 ` [dpdk-dev] [PATCH v2 09/15] ethdev: add encap level " Adrien Mazarguil @ 2018-04-07 8:27 ` Andrew Rybchenko 0 siblings, 0 replies; 157+ messages in thread From: Andrew Rybchenko @ 2018-04-07 8:27 UTC (permalink / raw) To: Adrien Mazarguil, Thomas Monjalon, Ferruh Yigit, dev Cc: Xueming Li, Wenzhuo Lu, Jingjing Wu, Beilei Xing, Qi Zhang, Konstantin Ananyev, Nelio Laranjeiro, Yongseok Koh, Pascal Mazon On 04/06/2018 04:25 PM, Adrien Mazarguil wrote: > RSS hash types (ETH_RSS_* macros defined in rte_ethdev.h) describe the > protocol header fields of a packet that must be taken into account while > computing RSS. > > When facing encapsulated (e.g. tunneled) packets, there is an ambiguity as > to whether these should apply to inner or outer packets. Applications need > the ability to tell exactly "where" RSS must be performed. > > This is addressed by adding encapsulation level information to the RSS flow > action. Its default value is 0 and stands for the usual unspecified > behavior. Other values provide a specific encapsulation level. > > Contrary to the change announced by commit 676b605182a5 ("doc: announce > ethdev API change for RSS configuration"), this patch does not affect > struct rte_eth_rss_conf but struct rte_flow_action_rss as the former is not > used anymore by the RSS flow action. ABI impact is therefore limited to > rte_flow. > > This breaks ABI compatibility for the following public functions: > > - rte_flow_copy() > - rte_flow_create() > - rte_flow_query() > - rte_flow_validate() > > Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> > Cc: Xueming Li <xuemingl@mellanox.com> > Cc: Ferruh Yigit <ferruh.yigit@intel.com> > Cc: Thomas Monjalon <thomas@monjalon.net> > Cc: Wenzhuo Lu <wenzhuo.lu@intel.com> > Cc: Jingjing Wu <jingjing.wu@intel.com> > Cc: Beilei Xing <beilei.xing@intel.com> > Cc: Qi Zhang <qi.z.zhang@intel.com> > Cc: Konstantin Ananyev <konstantin.ananyev@intel.com> > Cc: Nelio Laranjeiro <nelio.laranjeiro@6wind.com> > Cc: Yongseok Koh <yskoh@mellanox.com> > Cc: Andrew Rybchenko <arybchenko@solarflare.com> > Cc: Pascal Mazon <pascal.mazon@6wind.com> > --- > app/test-pmd/cmdline_flow.c | 13 ++++++++++++ > app/test-pmd/config.c | 1 + > doc/guides/prog_guide/rte_flow.rst | 24 ++++++++++++++++++++++ > doc/guides/testpmd_app_ug/testpmd_funcs.rst | 2 ++ > drivers/net/e1000/igb_flow.c | 4 ++++ > drivers/net/e1000/igb_rxtx.c | 2 ++ > drivers/net/i40e/i40e_ethdev.c | 2 ++ > drivers/net/i40e/i40e_flow.c | 4 ++++ > drivers/net/ixgbe/ixgbe_flow.c | 4 ++++ > drivers/net/ixgbe/ixgbe_rxtx.c | 2 ++ > drivers/net/mlx4/mlx4_flow.c | 6 ++++++ > drivers/net/mlx5/mlx5_flow.c | 11 ++++++++++ > drivers/net/sfc/sfc_flow.c | 3 +++ > drivers/net/tap/tap_flow.c | 6 +++++- > lib/librte_ether/rte_flow.c | 1 + > lib/librte_ether/rte_flow.h | 26 ++++++++++++++++++++++++ > 16 files changed, 110 insertions(+), 1 deletion(-) Generic and sfc parts Acked-by: Andrew Rybchenko <arybchenko@solarflare.com> ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v2 10/15] ethdev: refine TPID handling in flow API 2018-04-06 13:25 ` [dpdk-dev] [PATCH v2 00/15] Flow API overhaul for switch offloads Adrien Mazarguil ` (8 preceding siblings ...) 2018-04-06 13:25 ` [dpdk-dev] [PATCH v2 09/15] ethdev: add encap level " Adrien Mazarguil @ 2018-04-06 13:25 ` Adrien Mazarguil 2018-04-06 17:11 ` Andrew Rybchenko 2018-04-06 13:25 ` [dpdk-dev] [PATCH v2 11/15] ethdev: add transfer attribute to " Adrien Mazarguil ` (5 subsequent siblings) 15 siblings, 1 reply; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-06 13:25 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev Cc: Wenzhuo Lu, Jingjing Wu, Ajit Khaparde, Somnath Kotur, John Daley, Hyong Youb Kim, Beilei Xing, Qi Zhang, Konstantin Ananyev, Nelio Laranjeiro, Yongseok Koh, Tomasz Duszynski, Dmitri Epshtein, Natalie Samsonov, Jianbo Liu, Andrew Rybchenko, Pascal Mazon TPID handling in rte_flow VLAN and E_TAG pattern item definitions is not consistent with the normal stacking order of pattern items, which is confusing to applications. Problem is that when followed by one of these layers, the EtherType field of the preceding layer keeps its "inner" definition, and the "outer" TPID is provided by the subsequent layer, the reverse of how a packet looks like on the wire: Wire: [ ETH TPID = A | VLAN EtherType = B | B DATA ] rte_flow: [ ETH EtherType = B | VLAN TPID = A | B DATA ] Worse, when QinQ is involved, the stacking order of VLAN layers is unspecified. It is unclear whether it should be reversed (innermost to outermost) as well given TPID applies to the previous layer: Wire: [ ETH TPID = A | VLAN TPID = B | VLAN EtherType = C | C DATA ] rte_flow 1: [ ETH EtherType = C | VLAN TPID = B | VLAN TPID = A | C DATA ] rte_flow 2: [ ETH EtherType = C | VLAN TPID = A | VLAN TPID = B | C DATA ] While specifying EtherType/TPID is hopefully rarely necessary, the stacking order in case of QinQ and the lack of documentation remain an issue. This patch replaces TPID in the VLAN pattern item with an inner EtherType/TPID as is usually done everywhere else (e.g. struct vlan_hdr), clarifies documentation and updates all relevant code. It breaks ABI compatibility for the following public functions: - rte_flow_copy() - rte_flow_create() - rte_flow_query() - rte_flow_validate() Summary of changes for PMDs that implement ETH, VLAN or E_TAG pattern items: - bnxt: EtherType matching is supported, and vlan->inner_type overrides eth->type if the latter has standard TPID value 0x8100, otherwise an error is triggered. - e1000: EtherType matching is only supported with the ETHERTYPE filter, which does not support VLAN matching, therefore no impact. - enic: same as bnxt. - i40e: same as bnxt with a configurable TPID value for the FDIR filter, with existing limitations on allowed EtherType values. The remaining filter types (VXLAN, NVGRE, QINQ) do not support EtherType matching. - ixgbe: same as e1000, with additional minor change to rely on the new E-Tag macro definition. - mlx4: EtherType/TPID matching is not supported, no impact. - mlx5: same as bnxt. - mrvl: EtherType matching is supported but eth->type cannot be specified when a VLAN item is present. However vlan->inner_type is used if specified. - sfc: same as bnxt with QinQ TPID value 0x88a8 additionally supported. - tap: same as bnxt. Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Cc: Ferruh Yigit <ferruh.yigit@intel.com> Cc: Thomas Monjalon <thomas@monjalon.net> Cc: Wenzhuo Lu <wenzhuo.lu@intel.com> Cc: Jingjing Wu <jingjing.wu@intel.com> Cc: Ajit Khaparde <ajit.khaparde@broadcom.com> Cc: Somnath Kotur <somnath.kotur@broadcom.com> Cc: John Daley <johndale@cisco.com> Cc: Hyong Youb Kim <hyonkim@cisco.com> Cc: Beilei Xing <beilei.xing@intel.com> Cc: Qi Zhang <qi.z.zhang@intel.com> Cc: Konstantin Ananyev <konstantin.ananyev@intel.com> Cc: Nelio Laranjeiro <nelio.laranjeiro@6wind.com> Cc: Yongseok Koh <yskoh@mellanox.com> Cc: Tomasz Duszynski <tdu@semihalf.com> Cc: Dmitri Epshtein <dima@marvell.com> Cc: Natalie Samsonov <nsamsono@marvell.com> Cc: Jianbo Liu <jianbo.liu@arm.com> Cc: Andrew Rybchenko <arybchenko@solarflare.com> Cc: Pascal Mazon <pascal.mazon@6wind.com> --- Hi PMD maintainers, while I'm pretty confident in these changes, I could not validate them with all devices. It would be great if you could apply this patch, run testpmd, create VLAN flow rules with/without inner EtherType as described and send matching traffic while making sure nothing was broken in the process. Thanks! --- app/test-pmd/cmdline_flow.c | 17 +++--- doc/guides/nics/tap.rst | 2 +- doc/guides/prog_guide/rte_flow.rst | 21 ++++++-- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 4 +- drivers/net/bnxt/bnxt_filter.c | 39 +++++++++++--- drivers/net/enic/enic_flow.c | 22 +++++--- drivers/net/i40e/i40e_flow.c | 69 +++++++++++++++++++----- drivers/net/ixgbe/ixgbe_ethdev.c | 3 +- drivers/net/mlx5/mlx5_flow.c | 16 +++++- drivers/net/mvpp2/mrvl_flow.c | 27 +++++++--- drivers/net/sfc/sfc_flow.c | 28 ++++++++++ drivers/net/tap/tap_flow.c | 16 ++++-- lib/librte_ether/rte_flow.h | 24 ++++++--- lib/librte_net/rte_ether.h | 1 + 14 files changed, 229 insertions(+), 60 deletions(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 2fbd3d8ef..3a486032d 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -99,11 +99,11 @@ enum index { ITEM_ETH_SRC, ITEM_ETH_TYPE, ITEM_VLAN, - ITEM_VLAN_TPID, ITEM_VLAN_TCI, ITEM_VLAN_PCP, ITEM_VLAN_DEI, ITEM_VLAN_VID, + ITEM_VLAN_INNER_TYPE, ITEM_IPV4, ITEM_IPV4_TOS, ITEM_IPV4_TTL, @@ -505,11 +505,11 @@ static const enum index item_eth[] = { }; static const enum index item_vlan[] = { - ITEM_VLAN_TPID, ITEM_VLAN_TCI, ITEM_VLAN_PCP, ITEM_VLAN_DEI, ITEM_VLAN_VID, + ITEM_VLAN_INNER_TYPE, ITEM_NEXT, ZERO, }; @@ -1142,12 +1142,6 @@ static const struct token token_list[] = { .next = NEXT(item_vlan), .call = parse_vc, }, - [ITEM_VLAN_TPID] = { - .name = "tpid", - .help = "tag protocol identifier", - .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param), - .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vlan, tpid)), - }, [ITEM_VLAN_TCI] = { .name = "tci", .help = "tag control information", @@ -1175,6 +1169,13 @@ static const struct token token_list[] = { .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan, tci, "\x0f\xff")), }, + [ITEM_VLAN_INNER_TYPE] = { + .name = "inner_type", + .help = "inner EtherType", + .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vlan, + inner_type)), + }, [ITEM_IPV4] = { .name = "ipv4", .help = "match IPv4 header", diff --git a/doc/guides/nics/tap.rst b/doc/guides/nics/tap.rst index 76eb0bde4..bcf3efe9e 100644 --- a/doc/guides/nics/tap.rst +++ b/doc/guides/nics/tap.rst @@ -97,7 +97,7 @@ The kernel support can be checked with this command:: Supported items: - eth: src and dst (with variable masks), and eth_type (0xffff mask). -- vlan: vid, pcp, tpid, but not eid. (requires kernel 4.9) +- vlan: vid, pcp, but not eid. (requires kernel 4.9) - ipv4/6: src and dst (with variable masks), and ip_proto (0xffff mask). - udp/tcp: src and dst port (0xffff) mask. diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 97d429ee5..c6f16d444 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -784,9 +784,15 @@ Item: ``ETH`` Matches an Ethernet header. +The ``type`` field either stands for "EtherType" or "TPID" when followed by +so-called layer 2.5 pattern items such as ``RTE_FLOW_ITEM_TYPE_VLAN``. In +the latter case, ``type`` refers to that of the outer header, with the inner +EtherType/TPID provided by the subsequent pattern item. This is the same +order as on the wire. + - ``dst``: destination MAC. - ``src``: source MAC. -- ``type``: EtherType. +- ``type``: EtherType or TPID. - Default ``mask`` matches destination and source addresses only. Item: ``VLAN`` @@ -794,9 +800,13 @@ Item: ``VLAN`` Matches an 802.1Q/ad VLAN tag. -- ``tpid``: tag protocol identifier. +The corresponding standard outer EtherType (TPID) values are +``ETHER_TYPE_VLAN`` or ``ETHER_TYPE_QINQ``. It can be overridden by the +preceding pattern item. + - ``tci``: tag control information. -- Default ``mask`` matches TCI only. +- ``inner_type``: inner EtherType or TPID. +- Default ``mask`` matches the VID part of TCI only (lower 12 bits). Item: ``IPV4`` ^^^^^^^^^^^^^^ @@ -866,12 +876,15 @@ Item: ``E_TAG`` Matches an IEEE 802.1BR E-Tag header. -- ``tpid``: tag protocol identifier (0x893F) +The corresponding standard outer EtherType (TPID) value is +``ETHER_TYPE_ETAG``. It can be overridden by the preceding pattern item. + - ``epcp_edei_in_ecid_b``: E-Tag control information (E-TCI), E-PCP (3b), E-DEI (1b), ingress E-CID base (12b). - ``rsvd_grp_ecid_b``: reserved (2b), GRP (2b), E-CID base (12b). - ``in_ecid_e``: ingress E-CID ext. - ``ecid_e``: E-CID ext. +- ``inner_type``: inner EtherType or TPID. - Default ``mask`` simultaneously matches GRP and E-CID base. Item: ``NVGRE`` diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index 738461f44..25fac8430 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3223,15 +3223,15 @@ This section lists supported pattern items and their attributes, if any. - ``dst {MAC-48}``: destination MAC. - ``src {MAC-48}``: source MAC. - - ``type {unsigned}``: EtherType. + - ``type {unsigned}``: EtherType or TPID. - ``vlan``: match 802.1Q/ad VLAN tag. - - ``tpid {unsigned}``: tag protocol identifier. - ``tci {unsigned}``: tag control information. - ``pcp {unsigned}``: priority code point. - ``dei {unsigned}``: drop eligible indicator. - ``vid {unsigned}``: VLAN identifier. + - ``inner_type {unsigned}``: inner EtherType or TPID. - ``ipv4``: match IPv4 header. diff --git a/drivers/net/bnxt/bnxt_filter.c b/drivers/net/bnxt/bnxt_filter.c index 0f9c1c9ae..51e3e8de4 100644 --- a/drivers/net/bnxt/bnxt_filter.c +++ b/drivers/net/bnxt/bnxt_filter.c @@ -6,6 +6,7 @@ #include <sys/queue.h> #include <rte_byteorder.h> +#include <rte_ether.h> #include <rte_log.h> #include <rte_malloc.h> #include <rte_flow.h> @@ -299,6 +300,7 @@ bnxt_validate_and_parse_flow_type(struct bnxt *bp, uint32_t vf = 0; int use_ntuple; uint32_t en = 0; + uint32_t en_ethertype; int dflt_vnic; use_ntuple = bnxt_filter_type_check(pattern, error); @@ -308,6 +310,9 @@ bnxt_validate_and_parse_flow_type(struct bnxt *bp, filter->filter_type = use_ntuple ? HWRM_CFA_NTUPLE_FILTER : HWRM_CFA_EM_FILTER; + en_ethertype = use_ntuple ? + NTUPLE_FLTR_ALLOC_INPUT_EN_ETHERTYPE : + EM_FLOW_ALLOC_INPUT_EN_ETHERTYPE; while (item->type != RTE_FLOW_ITEM_TYPE_END) { if (item->last) { @@ -377,30 +382,52 @@ bnxt_validate_and_parse_flow_type(struct bnxt *bp, if (eth_mask->type) { filter->ethertype = rte_be_to_cpu_16(eth_spec->type); - en |= use_ntuple ? - NTUPLE_FLTR_ALLOC_INPUT_EN_ETHERTYPE : - EM_FLOW_ALLOC_INPUT_EN_ETHERTYPE; + en |= en_ethertype; } break; case RTE_FLOW_ITEM_TYPE_VLAN: vlan_spec = item->spec; vlan_mask = item->mask; + if (en & en_ethertype && + filter->ethertype != RTE_BE16(ETHER_TYPE_VLAN)) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, + item, + "unsupported outer TPID"); + return -rte_errno; + } if (vlan_mask->tci && - vlan_mask->tci == RTE_BE16(0x0fff) && - !vlan_mask->tpid) { + vlan_mask->tci == RTE_BE16(0x0fff)) { /* Only the VLAN ID can be matched. */ filter->l2_ovlan = rte_be_to_cpu_16(vlan_spec->tci & RTE_BE16(0x0fff)); en |= EM_FLOW_ALLOC_INPUT_EN_OVLAN_VID; - } else if (vlan_mask->tci || vlan_mask->tpid) { + } else if (vlan_mask->tci) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM, item, "VLAN mask is invalid"); return -rte_errno; } + if (vlan_mask->inner_type && + vlan_mask->inner_type != RTE_BE16(0xffff)) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, + item, + "inner ethertype mask not" + " valid"); + return -rte_errno; + } + if (vlan_mask->inner_type) { + filter->ethertype = + rte_be_to_cpu_16(vlan_spec->inner_type); + en |= en_ethertype; + } else { + filter->ethertype = RTE_BE16(0x0000); + en &= ~en_ethertype; + } break; case RTE_FLOW_ITEM_TYPE_IPV4: diff --git a/drivers/net/enic/enic_flow.c b/drivers/net/enic/enic_flow.c index c5c98b870..d645dfb63 100644 --- a/drivers/net/enic/enic_flow.c +++ b/drivers/net/enic/enic_flow.c @@ -4,6 +4,8 @@ #include <errno.h> #include <stdint.h> +#include <rte_byteorder.h> +#include <rte_ether.h> #include <rte_log.h> #include <rte_ethdev_driver.h> #include <rte_flow_driver.h> @@ -545,16 +547,22 @@ enic_copy_item_vlan_v2(const struct rte_flow_item *item, if (!spec) return 0; - /* Don't support filtering in tpid */ - if (mask) { - if (mask->tpid != 0) - return ENOTSUP; - } else { + if (!mask) mask = &rte_flow_item_vlan_mask; - RTE_ASSERT(mask->tpid == 0); - } if (*inner_ofst == 0) { + struct ether_hdr *eth_mask = + (void *)gp->layer[FILTER_GENERIC_1_L2].mask; + struct ether_hdr *eth_val = + (void *)gp->layer[FILTER_GENERIC_1_L2].val; + + /* Exactly one TPID value is allowed if specified */ + if ((eth_val->ether_type & eth_mask->ether_type) != + (RTE_BE16(ETHER_TYPE_VLAN) & eth_mask->ether_type)) + return ENOTSUP; + eth_mask->ether_type = mask->inner_type; + eth_val->ether_type = spec->inner_type; + /* Outer header. Use the vlan mask/val fields */ gp->mask_vlan = mask->tci; gp->val_vlan = spec->tci; diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c index c0a2bc4a6..e9550b0ce 100644 --- a/drivers/net/i40e/i40e_flow.c +++ b/drivers/net/i40e/i40e_flow.c @@ -10,6 +10,7 @@ #include <unistd.h> #include <stdarg.h> +#include <rte_debug.h> #include <rte_ether.h> #include <rte_ethdev_driver.h> #include <rte_log.h> @@ -2491,24 +2492,36 @@ i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev, "Invalid MAC_addr mask."); return -rte_errno; } + } + if (eth_spec && eth_mask && eth_mask->type) { + enum rte_flow_item_type next = (item + 1)->type; - if ((eth_mask->type & UINT16_MAX) == - UINT16_MAX) { - input_set |= I40E_INSET_LAST_ETHER_TYPE; - filter->input.flow.l2_flow.ether_type = - eth_spec->type; + if (eth_mask->type != RTE_BE16(0xffff)) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, + item, + "Invalid type mask."); + return -rte_errno; } ether_type = rte_be_to_cpu_16(eth_spec->type); - if (ether_type == ETHER_TYPE_IPv4 || - ether_type == ETHER_TYPE_IPv6 || - ether_type == ETHER_TYPE_ARP || - ether_type == outer_tpid) { + + if ((next == RTE_FLOW_ITEM_TYPE_VLAN && + ether_type != outer_tpid) || + (next != RTE_FLOW_ITEM_TYPE_VLAN && + (ether_type == ETHER_TYPE_IPv4 || + ether_type == ETHER_TYPE_IPv6 || + ether_type == ETHER_TYPE_ARP || + ether_type == outer_tpid))) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM, item, "Unsupported ether_type."); return -rte_errno; + } else if (next != RTE_FLOW_ITEM_TYPE_VLAN) { + input_set |= I40E_INSET_LAST_ETHER_TYPE; + filter->input.flow.l2_flow.ether_type = + eth_spec->type; } } @@ -2519,6 +2532,8 @@ i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev, case RTE_FLOW_ITEM_TYPE_VLAN: vlan_spec = item->spec; vlan_mask = item->mask; + + RTE_ASSERT(!(input_set & I40E_INSET_LAST_ETHER_TYPE)); if (vlan_spec && vlan_mask) { if (vlan_mask->tci == rte_cpu_to_be_16(I40E_TCI_MASK)) { @@ -2527,6 +2542,33 @@ i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev, vlan_spec->tci; } } + if (vlan_spec && vlan_mask && vlan_mask->inner_type) { + if (vlan_mask->inner_type != RTE_BE16(0xffff)) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, + item, + "Invalid inner_type" + " mask."); + return -rte_errno; + } + + ether_type = + rte_be_to_cpu_16(vlan_spec->inner_type); + + if (ether_type == ETHER_TYPE_IPv4 || + ether_type == ETHER_TYPE_IPv6 || + ether_type == ETHER_TYPE_ARP || + ether_type == outer_tpid) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, + item, + "Unsupported inner_type."); + return -rte_errno; + } + input_set |= I40E_INSET_LAST_ETHER_TYPE; + filter->input.flow.l2_flow.ether_type = + vlan_spec->inner_type; + } pctype = I40E_FILTER_PCTYPE_L2_PAYLOAD; layer_idx = I40E_FLXPLD_L2_IDX; @@ -3285,7 +3327,8 @@ i40e_flow_parse_vxlan_pattern(__rte_unused struct rte_eth_dev *dev, case RTE_FLOW_ITEM_TYPE_VLAN: vlan_spec = item->spec; vlan_mask = item->mask; - if (!(vlan_spec && vlan_mask)) { + if (!(vlan_spec && vlan_mask) || + vlan_mask->inner_type) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM, item, @@ -3515,7 +3558,8 @@ i40e_flow_parse_nvgre_pattern(__rte_unused struct rte_eth_dev *dev, case RTE_FLOW_ITEM_TYPE_VLAN: vlan_spec = item->spec; vlan_mask = item->mask; - if (!(vlan_spec && vlan_mask)) { + if (!(vlan_spec && vlan_mask) || + vlan_mask->inner_type) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM, item, @@ -4023,7 +4067,8 @@ i40e_flow_parse_qinq_pattern(__rte_unused struct rte_eth_dev *dev, vlan_spec = item->spec; vlan_mask = item->mask; - if (!(vlan_spec && vlan_mask)) { + if (!(vlan_spec && vlan_mask) || + vlan_mask->inner_type) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM, item, diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c index 227f4c342..0d2726115 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.c +++ b/drivers/net/ixgbe/ixgbe_ethdev.c @@ -115,7 +115,6 @@ #define IXGBE_VT_CTL_POOLING_MODE_MASK 0x00030000 #define IXGBE_VT_CTL_POOLING_MODE_ETAG 0x00010000 -#define DEFAULT_ETAG_ETYPE 0x893f #define IXGBE_ETAG_ETYPE 0x00005084 #define IXGBE_ETAG_ETYPE_MASK 0x0000ffff #define IXGBE_ETAG_ETYPE_VALID 0x80000000 @@ -1481,7 +1480,7 @@ static int ixgbe_l2_tn_filter_init(struct rte_eth_dev *eth_dev) } l2_tn_info->e_tag_en = FALSE; l2_tn_info->e_tag_fwd_en = FALSE; - l2_tn_info->e_tag_ether_type = DEFAULT_ETAG_ETYPE; + l2_tn_info->e_tag_ether_type = ETHER_TYPE_ETAG; return 0; } diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index bc1176819..8863e451c 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -17,7 +17,9 @@ #pragma GCC diagnostic error "-Wpedantic" #endif +#include <rte_byteorder.h> #include <rte_common.h> +#include <rte_ether.h> #include <rte_eth_ctrl.h> #include <rte_ethdev_driver.h> #include <rte_flow.h> @@ -306,6 +308,7 @@ static const struct mlx5_flow_items mlx5_flow_items[] = { .actions = valid_actions, .mask = &(const struct rte_flow_item_vlan){ .tci = -1, + .inner_type = -1, }, .default_mask = &rte_flow_item_vlan_mask, .mask_sz = sizeof(struct rte_flow_item_vlan), @@ -1285,6 +1288,7 @@ mlx5_flow_create_vlan(const struct rte_flow_item *item, struct mlx5_flow_parse *parser = data->parser; struct ibv_flow_spec_eth *eth; const unsigned int eth_size = sizeof(struct ibv_flow_spec_eth); + const char *msg = "VLAN cannot be empty"; if (spec) { unsigned int i; @@ -1306,12 +1310,22 @@ mlx5_flow_create_vlan(const struct rte_flow_item *item, */ if (!eth->mask.vlan_tag) goto error; + /* Exactly one TPID value is allowed if specified. */ + if ((eth->val.ether_type & eth->mask.ether_type) != + (RTE_BE16(ETHER_TYPE_VLAN) & + eth->mask.ether_type)) { + msg = "unsupported outer TPID"; + goto error; + } + eth->val.ether_type = spec->inner_type; + eth->mask.ether_type = mask->inner_type; + eth->val.ether_type &= eth->mask.ether_type; } return 0; } error: return rte_flow_error_set(data->error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM, - item, "VLAN cannot be empty"); + item, msg); } /** diff --git a/drivers/net/mvpp2/mrvl_flow.c b/drivers/net/mvpp2/mrvl_flow.c index 8fd4dbfb1..6604a411f 100644 --- a/drivers/net/mvpp2/mrvl_flow.c +++ b/drivers/net/mvpp2/mrvl_flow.c @@ -1091,12 +1091,6 @@ mrvl_parse_vlan(const struct rte_flow_item *item, if (ret) return ret; - if (mask->tpid) { - rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM, - NULL, "Not supported by classifier\n"); - return -rte_errno; - } - m = rte_be_to_cpu_16(mask->tci); if (m & MRVL_VLAN_ID_MASK) { RTE_LOG(WARNING, PMD, "vlan id mask is ignored\n"); @@ -1112,6 +1106,27 @@ mrvl_parse_vlan(const struct rte_flow_item *item, goto out; } + if (flow->pattern & F_TYPE) { + rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ITEM, item, + "outer TPID cannot be explicitly matched" + " when VLAN item is also specified\n"); + return -rte_errno; + } + if (mask->inner_type) { + struct rte_flow_item_eth spec_eth = { + .type = spec->inner_type, + }; + struct rte_flow_item_eth mask_eth = { + .type = mask->inner_type, + }; + + RTE_LOG(WARNING, PMD, "inner eth type mask is ignored\n"); + ret = mrvl_parse_type(spec_eth, mask_eth, flow); + if (ret) + goto out; + } + return 0; out: rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, diff --git a/drivers/net/sfc/sfc_flow.c b/drivers/net/sfc/sfc_flow.c index bc4974edf..f61d4ec92 100644 --- a/drivers/net/sfc/sfc_flow.c +++ b/drivers/net/sfc/sfc_flow.c @@ -7,6 +7,7 @@ * for Solarflare) and Solarflare Communications, Inc. */ +#include <rte_byteorder.h> #include <rte_tailq.h> #include <rte_common.h> #include <rte_ethdev_driver.h> @@ -351,6 +352,7 @@ sfc_flow_parse_vlan(const struct rte_flow_item *item, const struct rte_flow_item_vlan *mask = NULL; const struct rte_flow_item_vlan supp_mask = { .tci = rte_cpu_to_be_16(ETH_VLAN_ID_MAX), + .inner_type = RTE_BE16(0xffff), }; rc = sfc_flow_parse_init(item, @@ -393,6 +395,32 @@ sfc_flow_parse_vlan(const struct rte_flow_item *item, return -rte_errno; } + /* + * If an EtherType was already specified, make sure it is a valid + * TPID for the current VLAN layer before overwriting it with the + * specified inner type. + */ + if (efx_spec->efs_match_flags & EFX_FILTER_MATCH_ETHER_TYPE && + efx_spec->efs_ether_type != RTE_BE16(ETHER_TYPE_VLAN) && + efx_spec->efs_ether_type != RTE_BE16(ETHER_TYPE_QINQ)) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, item, + "Unsupported outer TPID"); + return -rte_errno; + } + if (!mask->inner_type) { + efx_spec->efs_match_flags &= ~EFX_FILTER_MATCH_ETHER_TYPE; + efx_spec->efs_ether_type = RTE_BE16(0x0000); + } else if (mask->inner_type == supp_mask.inner_type) { + efx_spec->efs_match_flags |= EFX_FILTER_MATCH_ETHER_TYPE; + efx_spec->efs_ether_type = rte_bswap16(spec->inner_type); + } else { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, item, + "Bad mask for VLAN inner_type"); + return -rte_errno; + } + return 0; } diff --git a/drivers/net/tap/tap_flow.c b/drivers/net/tap/tap_flow.c index e5eb50fc5..e53eff6ce 100644 --- a/drivers/net/tap/tap_flow.c +++ b/drivers/net/tap/tap_flow.c @@ -270,13 +270,13 @@ static const struct tap_flow_items tap_flow_items[] = { .items = ITEMS(RTE_FLOW_ITEM_TYPE_IPV4, RTE_FLOW_ITEM_TYPE_IPV6), .mask = &(const struct rte_flow_item_vlan){ - .tpid = -1, /* DEI matching is not supported */ #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN .tci = 0xffef, #else .tci = 0xefff, #endif + .inner_type = -1, }, .mask_sz = sizeof(struct rte_flow_item_vlan), .default_mask = &rte_flow_item_vlan_mask, @@ -578,13 +578,21 @@ tap_flow_create_vlan(const struct rte_flow_item *item, void *data) /* use default mask if none provided */ if (!mask) mask = tap_flow_items[RTE_FLOW_ITEM_TYPE_VLAN].default_mask; - /* TC does not support tpid masking. Only accept if exact match. */ - if (mask->tpid && mask->tpid != 0xffff) + /* check that previous eth type is compatible with VLAN */ + if (info->eth_type && info->eth_type != RTE_BE16(ETH_P_8021Q)) return -1; /* Double-tagging not supported. */ - if (spec && mask->tpid && spec->tpid != htons(ETH_P_8021Q)) + if (info->vlan) return -1; info->vlan = 1; + if (mask->inner_type) { + /* TC does not support partial eth_type masking */ + if (mask->inner_type != RTE_BE16(0xffff)) + return -1; + info->eth_type = spec->inner_type; + } else { + info->eth_type = 0; + } if (!flow) return 0; msg = &flow->msg; diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index fc7e6705d..b13b0e2e6 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -454,11 +454,17 @@ static const struct rte_flow_item_raw rte_flow_item_raw_mask = { * RTE_FLOW_ITEM_TYPE_ETH * * Matches an Ethernet header. + * + * The @p type field either stands for "EtherType" or "TPID" when followed + * by so-called layer 2.5 pattern items such as RTE_FLOW_ITEM_TYPE_VLAN. In + * the latter case, @p type refers to that of the outer header, with the + * inner EtherType/TPID provided by the subsequent pattern item. This is the + * same order as on the wire. */ struct rte_flow_item_eth { struct ether_addr dst; /**< Destination MAC. */ struct ether_addr src; /**< Source MAC. */ - rte_be16_t type; /**< EtherType. */ + rte_be16_t type; /**< EtherType or TPID. */ }; /** Default mask for RTE_FLOW_ITEM_TYPE_ETH. */ @@ -475,19 +481,20 @@ static const struct rte_flow_item_eth rte_flow_item_eth_mask = { * * Matches an 802.1Q/ad VLAN tag. * - * This type normally follows either RTE_FLOW_ITEM_TYPE_ETH or - * RTE_FLOW_ITEM_TYPE_VLAN. + * The corresponding standard outer EtherType (TPID) values are + * ETHER_TYPE_VLAN or ETHER_TYPE_QINQ. It can be overridden by the preceding + * pattern item. */ struct rte_flow_item_vlan { - rte_be16_t tpid; /**< Tag protocol identifier. */ rte_be16_t tci; /**< Tag control information. */ + rte_be16_t inner_type; /**< Inner EtherType or TPID. */ }; /** Default mask for RTE_FLOW_ITEM_TYPE_VLAN. */ #ifndef __cplusplus static const struct rte_flow_item_vlan rte_flow_item_vlan_mask = { - .tpid = RTE_BE16(0x0000), - .tci = RTE_BE16(0xffff), + .tci = RTE_BE16(0x0fff), + .inner_type = RTE_BE16(0x0000), }; #endif @@ -636,9 +643,11 @@ static const struct rte_flow_item_vxlan rte_flow_item_vxlan_mask = { * RTE_FLOW_ITEM_TYPE_E_TAG. * * Matches a E-tag header. + * + * The corresponding standard outer EtherType (TPID) value is + * ETHER_TYPE_ETAG. It can be overridden by the preceding pattern item. */ struct rte_flow_item_e_tag { - rte_be16_t tpid; /**< Tag protocol identifier (0x893F). */ /** * E-Tag control information (E-TCI). * E-PCP (3b), E-DEI (1b), ingress E-CID base (12b). @@ -648,6 +657,7 @@ struct rte_flow_item_e_tag { rte_be16_t rsvd_grp_ecid_b; uint8_t in_ecid_e; /**< Ingress E-CID ext. */ uint8_t ecid_e; /**< E-CID ext. */ + rte_be16_t inner_type; /**< Inner EtherType or TPID. */ }; /** Default mask for RTE_FLOW_ITEM_TYPE_E_TAG. */ diff --git a/lib/librte_net/rte_ether.h b/lib/librte_net/rte_ether.h index 45daa911a..a271d1c86 100644 --- a/lib/librte_net/rte_ether.h +++ b/lib/librte_net/rte_ether.h @@ -301,6 +301,7 @@ struct vxlan_hdr { #define ETHER_TYPE_RARP 0x8035 /**< Reverse Arp Protocol. */ #define ETHER_TYPE_VLAN 0x8100 /**< IEEE 802.1Q VLAN tagging. */ #define ETHER_TYPE_QINQ 0x88A8 /**< IEEE 802.1ad QinQ tagging. */ +#define ETHER_TYPE_ETAG 0x893F /**< IEEE 802.1BR E-Tag. */ #define ETHER_TYPE_1588 0x88F7 /**< IEEE 802.1AS 1588 Precise Time Protocol. */ #define ETHER_TYPE_SLOW 0x8809 /**< Slow protocols (LACP and Marker). */ #define ETHER_TYPE_TEB 0x6558 /**< Transparent Ethernet Bridging. */ -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [dpdk-dev] [PATCH v2 10/15] ethdev: refine TPID handling in flow API 2018-04-06 13:25 ` [dpdk-dev] [PATCH v2 10/15] ethdev: refine TPID handling in flow API Adrien Mazarguil @ 2018-04-06 17:11 ` Andrew Rybchenko 2018-04-09 14:42 ` Adrien Mazarguil 0 siblings, 1 reply; 157+ messages in thread From: Andrew Rybchenko @ 2018-04-06 17:11 UTC (permalink / raw) To: Adrien Mazarguil, Thomas Monjalon, Ferruh Yigit, dev Cc: Wenzhuo Lu, Jingjing Wu, Ajit Khaparde, Somnath Kotur, John Daley, Hyong Youb Kim, Beilei Xing, Qi Zhang, Konstantin Ananyev, Nelio Laranjeiro, Yongseok Koh, Tomasz Duszynski, Dmitri Epshtein, Natalie Samsonov, Jianbo Liu, Pascal Mazon On 04/06/2018 04:25 PM, Adrien Mazarguil wrote: > TPID handling in rte_flow VLAN and E_TAG pattern item definitions is not > consistent with the normal stacking order of pattern items, which is > confusing to applications. > > Problem is that when followed by one of these layers, the EtherType field > of the preceding layer keeps its "inner" definition, and the "outer" TPID > is provided by the subsequent layer, the reverse of how a packet looks like > on the wire: > > Wire: [ ETH TPID = A | VLAN EtherType = B | B DATA ] > rte_flow: [ ETH EtherType = B | VLAN TPID = A | B DATA ] > > Worse, when QinQ is involved, the stacking order of VLAN layers is > unspecified. It is unclear whether it should be reversed (innermost to > outermost) as well given TPID applies to the previous layer: > > Wire: [ ETH TPID = A | VLAN TPID = B | VLAN EtherType = C | C DATA ] > rte_flow 1: [ ETH EtherType = C | VLAN TPID = B | VLAN TPID = A | C DATA ] > rte_flow 2: [ ETH EtherType = C | VLAN TPID = A | VLAN TPID = B | C DATA ] > > While specifying EtherType/TPID is hopefully rarely necessary, the stacking > order in case of QinQ and the lack of documentation remain an issue. > > This patch replaces TPID in the VLAN pattern item with an inner > EtherType/TPID as is usually done everywhere else (e.g. struct vlan_hdr), > clarifies documentation and updates all relevant code. > > It breaks ABI compatibility for the following public functions: > > - rte_flow_copy() > - rte_flow_create() > - rte_flow_query() > - rte_flow_validate() > > Summary of changes for PMDs that implement ETH, VLAN or E_TAG pattern > items: > > - bnxt: EtherType matching is supported, and vlan->inner_type overrides > eth->type if the latter has standard TPID value 0x8100, otherwise an > error is triggered. > > - e1000: EtherType matching is only supported with the ETHERTYPE filter, > which does not support VLAN matching, therefore no impact. > > - enic: same as bnxt. > > - i40e: same as bnxt with a configurable TPID value for the FDIR filter, > with existing limitations on allowed EtherType values. The remaining > filter types (VXLAN, NVGRE, QINQ) do not support EtherType matching. > > - ixgbe: same as e1000, with additional minor change to rely on the new > E-Tag macro definition. > > - mlx4: EtherType/TPID matching is not supported, no impact. > > - mlx5: same as bnxt. > > - mrvl: EtherType matching is supported but eth->type cannot be specified > when a VLAN item is present. However vlan->inner_type is used if > specified. > > - sfc: same as bnxt with QinQ TPID value 0x88a8 additionally supported. > > - tap: same as bnxt. > > Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> > Cc: Ferruh Yigit <ferruh.yigit@intel.com> > Cc: Thomas Monjalon <thomas@monjalon.net> > Cc: Wenzhuo Lu <wenzhuo.lu@intel.com> > Cc: Jingjing Wu <jingjing.wu@intel.com> > Cc: Ajit Khaparde <ajit.khaparde@broadcom.com> > Cc: Somnath Kotur <somnath.kotur@broadcom.com> > Cc: John Daley <johndale@cisco.com> > Cc: Hyong Youb Kim <hyonkim@cisco.com> > Cc: Beilei Xing <beilei.xing@intel.com> > Cc: Qi Zhang <qi.z.zhang@intel.com> > Cc: Konstantin Ananyev <konstantin.ananyev@intel.com> > Cc: Nelio Laranjeiro <nelio.laranjeiro@6wind.com> > Cc: Yongseok Koh <yskoh@mellanox.com> > Cc: Tomasz Duszynski <tdu@semihalf.com> > Cc: Dmitri Epshtein <dima@marvell.com> > Cc: Natalie Samsonov <nsamsono@marvell.com> > Cc: Jianbo Liu <jianbo.liu@arm.com> > Cc: Andrew Rybchenko <arybchenko@solarflare.com> > Cc: Pascal Mazon <pascal.mazon@6wind.com> > > --- > > Hi PMD maintainers, while I'm pretty confident in these changes, I could > not validate them with all devices. > > It would be great if you could apply this patch, run testpmd, create VLAN > flow rules with/without inner EtherType as described and send matching > traffic while making sure nothing was broken in the process. > > Thanks! > --- > app/test-pmd/cmdline_flow.c | 17 +++--- > doc/guides/nics/tap.rst | 2 +- > doc/guides/prog_guide/rte_flow.rst | 21 ++++++-- > doc/guides/testpmd_app_ug/testpmd_funcs.rst | 4 +- > drivers/net/bnxt/bnxt_filter.c | 39 +++++++++++--- > drivers/net/enic/enic_flow.c | 22 +++++--- > drivers/net/i40e/i40e_flow.c | 69 +++++++++++++++++++----- > drivers/net/ixgbe/ixgbe_ethdev.c | 3 +- > drivers/net/mlx5/mlx5_flow.c | 16 +++++- > drivers/net/mvpp2/mrvl_flow.c | 27 +++++++--- > drivers/net/sfc/sfc_flow.c | 28 ++++++++++ > drivers/net/tap/tap_flow.c | 16 ++++-- > lib/librte_ether/rte_flow.h | 24 ++++++--- > lib/librte_net/rte_ether.h | 1 + > 14 files changed, 229 insertions(+), 60 deletions(-) <...> > diff --git a/drivers/net/sfc/sfc_flow.c b/drivers/net/sfc/sfc_flow.c > index bc4974edf..f61d4ec92 100644 > --- a/drivers/net/sfc/sfc_flow.c > +++ b/drivers/net/sfc/sfc_flow.c > @@ -7,6 +7,7 @@ > * for Solarflare) and Solarflare Communications, Inc. > */ > > +#include <rte_byteorder.h> > #include <rte_tailq.h> > #include <rte_common.h> > #include <rte_ethdev_driver.h> > @@ -351,6 +352,7 @@ sfc_flow_parse_vlan(const struct rte_flow_item *item, > const struct rte_flow_item_vlan *mask = NULL; > const struct rte_flow_item_vlan supp_mask = { > .tci = rte_cpu_to_be_16(ETH_VLAN_ID_MAX), > + .inner_type = RTE_BE16(0xffff), > }; > > rc = sfc_flow_parse_init(item, > @@ -393,6 +395,32 @@ sfc_flow_parse_vlan(const struct rte_flow_item *item, > return -rte_errno; > } > > + /* > + * If an EtherType was already specified, make sure it is a valid > + * TPID for the current VLAN layer before overwriting it with the > + * specified inner type. > + */ > + if (efx_spec->efs_match_flags & EFX_FILTER_MATCH_ETHER_TYPE && > + efx_spec->efs_ether_type != RTE_BE16(ETHER_TYPE_VLAN) && > + efx_spec->efs_ether_type != RTE_BE16(ETHER_TYPE_QINQ)) { 1. efs_ether_type is host-endian 2. HW recognizes more TPIDs (0x9100, 0x9200, 0x9300) as VLAN 3. However, if some TPID is specified, user may expect that only VLAN packets with specified TPID match. It is false expectation since the information is not passed to HW to match (and there is no way to match). So, it is safer to deny TPID specification (i.e. keep the first condition only). From the flexibility point of view it is possible to allow any, but it should be documented that exact match is not checked in fact. > + rte_flow_error_set(error, EINVAL, > + RTE_FLOW_ERROR_TYPE_ITEM, item, > + "Unsupported outer TPID"); > + return -rte_errno; > + } > + if (!mask->inner_type) { > + efx_spec->efs_match_flags &= ~EFX_FILTER_MATCH_ETHER_TYPE; > + efx_spec->efs_ether_type = RTE_BE16(0x0000); Nothing should be done here if above is done. > + } else if (mask->inner_type == supp_mask.inner_type) { > + efx_spec->efs_match_flags |= EFX_FILTER_MATCH_ETHER_TYPE; > + efx_spec->efs_ether_type = rte_bswap16(spec->inner_type); > + } else { > + rte_flow_error_set(error, EINVAL, > + RTE_FLOW_ERROR_TYPE_ITEM, item, > + "Bad mask for VLAN inner_type"); > + return -rte_errno; > + } > + > return 0; > } <...> > diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h > index fc7e6705d..b13b0e2e6 100644 > --- a/lib/librte_ether/rte_flow.h > +++ b/lib/librte_ether/rte_flow.h > @@ -475,19 +481,20 @@ static const struct rte_flow_item_eth rte_flow_item_eth_mask = { > * > * Matches an 802.1Q/ad VLAN tag. > * > - * This type normally follows either RTE_FLOW_ITEM_TYPE_ETH or > - * RTE_FLOW_ITEM_TYPE_VLAN. > + * The corresponding standard outer EtherType (TPID) values are > + * ETHER_TYPE_VLAN or ETHER_TYPE_QINQ. It can be overridden by the preceding > + * pattern item. > */ > struct rte_flow_item_vlan { > - rte_be16_t tpid; /**< Tag protocol identifier. */ > rte_be16_t tci; /**< Tag control information. */ > + rte_be16_t inner_type; /**< Inner EtherType or TPID. */ > }; > > /** Default mask for RTE_FLOW_ITEM_TYPE_VLAN. */ > #ifndef __cplusplus > static const struct rte_flow_item_vlan rte_flow_item_vlan_mask = { > - .tpid = RTE_BE16(0x0000), > - .tci = RTE_BE16(0xffff), > + .tci = RTE_BE16(0x0fff), It looks like unrelated change. > + .inner_type = RTE_BE16(0x0000), > }; > #endif <...> ^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [dpdk-dev] [PATCH v2 10/15] ethdev: refine TPID handling in flow API 2018-04-06 17:11 ` Andrew Rybchenko @ 2018-04-09 14:42 ` Adrien Mazarguil 0 siblings, 0 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-09 14:42 UTC (permalink / raw) To: Andrew Rybchenko Cc: Thomas Monjalon, Ferruh Yigit, dev, Wenzhuo Lu, Jingjing Wu, Ajit Khaparde, Somnath Kotur, John Daley, Hyong Youb Kim, Beilei Xing, Qi Zhang, Konstantin Ananyev, Nelio Laranjeiro, Yongseok Koh, Tomasz Duszynski, Dmitri Epshtein, Natalie Samsonov, Jianbo Liu, Pascal Mazon On Fri, Apr 06, 2018 at 08:11:38PM +0300, Andrew Rybchenko wrote: > On 04/06/2018 04:25 PM, Adrien Mazarguil wrote: > > TPID handling in rte_flow VLAN and E_TAG pattern item definitions is not > > consistent with the normal stacking order of pattern items, which is > > confusing to applications. > > > > Problem is that when followed by one of these layers, the EtherType field > > of the preceding layer keeps its "inner" definition, and the "outer" TPID > > is provided by the subsequent layer, the reverse of how a packet looks like > > on the wire: > > > > Wire: [ ETH TPID = A | VLAN EtherType = B | B DATA ] > > rte_flow: [ ETH EtherType = B | VLAN TPID = A | B DATA ] > > > > Worse, when QinQ is involved, the stacking order of VLAN layers is > > unspecified. It is unclear whether it should be reversed (innermost to > > outermost) as well given TPID applies to the previous layer: > > > > Wire: [ ETH TPID = A | VLAN TPID = B | VLAN EtherType = C | C DATA ] > > rte_flow 1: [ ETH EtherType = C | VLAN TPID = B | VLAN TPID = A | C DATA ] > > rte_flow 2: [ ETH EtherType = C | VLAN TPID = A | VLAN TPID = B | C DATA ] > > > > While specifying EtherType/TPID is hopefully rarely necessary, the stacking > > order in case of QinQ and the lack of documentation remain an issue. > > > > This patch replaces TPID in the VLAN pattern item with an inner > > EtherType/TPID as is usually done everywhere else (e.g. struct vlan_hdr), > > clarifies documentation and updates all relevant code. > > > > It breaks ABI compatibility for the following public functions: > > > > - rte_flow_copy() > > - rte_flow_create() > > - rte_flow_query() > > - rte_flow_validate() > > > > Summary of changes for PMDs that implement ETH, VLAN or E_TAG pattern > > items: > > > > - bnxt: EtherType matching is supported, and vlan->inner_type overrides > > eth->type if the latter has standard TPID value 0x8100, otherwise an > > error is triggered. > > > > - e1000: EtherType matching is only supported with the ETHERTYPE filter, > > which does not support VLAN matching, therefore no impact. > > > > - enic: same as bnxt. > > > > - i40e: same as bnxt with a configurable TPID value for the FDIR filter, > > with existing limitations on allowed EtherType values. The remaining > > filter types (VXLAN, NVGRE, QINQ) do not support EtherType matching. > > > > - ixgbe: same as e1000, with additional minor change to rely on the new > > E-Tag macro definition. > > > > - mlx4: EtherType/TPID matching is not supported, no impact. > > > > - mlx5: same as bnxt. > > > > - mrvl: EtherType matching is supported but eth->type cannot be specified > > when a VLAN item is present. However vlan->inner_type is used if > > specified. > > > > - sfc: same as bnxt with QinQ TPID value 0x88a8 additionally supported. > > > > - tap: same as bnxt. > > > > Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> > > Cc: Ferruh Yigit <ferruh.yigit@intel.com> > > Cc: Thomas Monjalon <thomas@monjalon.net> > > Cc: Wenzhuo Lu <wenzhuo.lu@intel.com> > > Cc: Jingjing Wu <jingjing.wu@intel.com> > > Cc: Ajit Khaparde <ajit.khaparde@broadcom.com> > > Cc: Somnath Kotur <somnath.kotur@broadcom.com> > > Cc: John Daley <johndale@cisco.com> > > Cc: Hyong Youb Kim <hyonkim@cisco.com> > > Cc: Beilei Xing <beilei.xing@intel.com> > > Cc: Qi Zhang <qi.z.zhang@intel.com> > > Cc: Konstantin Ananyev <konstantin.ananyev@intel.com> > > Cc: Nelio Laranjeiro <nelio.laranjeiro@6wind.com> > > Cc: Yongseok Koh <yskoh@mellanox.com> > > Cc: Tomasz Duszynski <tdu@semihalf.com> > > Cc: Dmitri Epshtein <dima@marvell.com> > > Cc: Natalie Samsonov <nsamsono@marvell.com> > > Cc: Jianbo Liu <jianbo.liu@arm.com> > > Cc: Andrew Rybchenko <arybchenko@solarflare.com> > > Cc: Pascal Mazon <pascal.mazon@6wind.com> > > > > --- > > > > Hi PMD maintainers, while I'm pretty confident in these changes, I could > > not validate them with all devices. > > > > It would be great if you could apply this patch, run testpmd, create VLAN > > flow rules with/without inner EtherType as described and send matching > > traffic while making sure nothing was broken in the process. > > > > Thanks! > > --- > > app/test-pmd/cmdline_flow.c | 17 +++--- > > doc/guides/nics/tap.rst | 2 +- > > doc/guides/prog_guide/rte_flow.rst | 21 ++++++-- > > doc/guides/testpmd_app_ug/testpmd_funcs.rst | 4 +- > > drivers/net/bnxt/bnxt_filter.c | 39 +++++++++++--- > > drivers/net/enic/enic_flow.c | 22 +++++--- > > drivers/net/i40e/i40e_flow.c | 69 +++++++++++++++++++----- > > drivers/net/ixgbe/ixgbe_ethdev.c | 3 +- > > drivers/net/mlx5/mlx5_flow.c | 16 +++++- > > drivers/net/mvpp2/mrvl_flow.c | 27 +++++++--- > > drivers/net/sfc/sfc_flow.c | 28 ++++++++++ > > drivers/net/tap/tap_flow.c | 16 ++++-- > > lib/librte_ether/rte_flow.h | 24 ++++++--- > > lib/librte_net/rte_ether.h | 1 + > > 14 files changed, 229 insertions(+), 60 deletions(-) > > <...> > > > diff --git a/drivers/net/sfc/sfc_flow.c b/drivers/net/sfc/sfc_flow.c > > index bc4974edf..f61d4ec92 100644 > > --- a/drivers/net/sfc/sfc_flow.c > > +++ b/drivers/net/sfc/sfc_flow.c > > @@ -7,6 +7,7 @@ > > * for Solarflare) and Solarflare Communications, Inc. > > */ > > +#include <rte_byteorder.h> > > #include <rte_tailq.h> > > #include <rte_common.h> > > #include <rte_ethdev_driver.h> > > @@ -351,6 +352,7 @@ sfc_flow_parse_vlan(const struct rte_flow_item *item, > > const struct rte_flow_item_vlan *mask = NULL; > > const struct rte_flow_item_vlan supp_mask = { > > .tci = rte_cpu_to_be_16(ETH_VLAN_ID_MAX), > > + .inner_type = RTE_BE16(0xffff), > > }; > > rc = sfc_flow_parse_init(item, > > @@ -393,6 +395,32 @@ sfc_flow_parse_vlan(const struct rte_flow_item *item, > > return -rte_errno; > > } > > + /* > > + * If an EtherType was already specified, make sure it is a valid > > + * TPID for the current VLAN layer before overwriting it with the > > + * specified inner type. > > + */ > > + if (efx_spec->efs_match_flags & EFX_FILTER_MATCH_ETHER_TYPE && > > + efx_spec->efs_ether_type != RTE_BE16(ETHER_TYPE_VLAN) && > > + efx_spec->efs_ether_type != RTE_BE16(ETHER_TYPE_QINQ)) { > > 1. efs_ether_type is host-endian Whoops, looks like I only half-fixed that endian issue in v2. > 2. HW recognizes more TPIDs (0x9100, 0x9200, 0x9300) as VLAN > 3. However, if some TPID is specified, user may expect that only VLAN > packets > with specified TPID match. It is false expectation since the information > is not > passed to HW to match (and there is no way to match). > So, it is safer to deny TPID specification (i.e. keep the first > condition only). > From the flexibility point of view it is possible to allow any, but it > should be > documented that exact match is not checked in fact. Thanks for pointing this out. I've decided to update all PMDs to disallow TPID matching because many devices support multiple concurrent TPIDs and there's no way to match a given one explicitly. This should make the patch simpler as well. > > + rte_flow_error_set(error, EINVAL, > > + RTE_FLOW_ERROR_TYPE_ITEM, item, > > + "Unsupported outer TPID"); > > + return -rte_errno; > > + } > > + if (!mask->inner_type) { > > + efx_spec->efs_match_flags &= ~EFX_FILTER_MATCH_ETHER_TYPE; > > + efx_spec->efs_ether_type = RTE_BE16(0x0000); > > Nothing should be done here if above is done. > > > + } else if (mask->inner_type == supp_mask.inner_type) { > > + efx_spec->efs_match_flags |= EFX_FILTER_MATCH_ETHER_TYPE; > > + efx_spec->efs_ether_type = rte_bswap16(spec->inner_type); > > + } else { > > + rte_flow_error_set(error, EINVAL, > > + RTE_FLOW_ERROR_TYPE_ITEM, item, > > + "Bad mask for VLAN inner_type"); > > + return -rte_errno; > > + } > > + > > return 0; > > } > > <...> > > > diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h > > index fc7e6705d..b13b0e2e6 100644 > > --- a/lib/librte_ether/rte_flow.h > > +++ b/lib/librte_ether/rte_flow.h > > @@ -475,19 +481,20 @@ static const struct rte_flow_item_eth rte_flow_item_eth_mask = { > > * > > * Matches an 802.1Q/ad VLAN tag. > > * > > - * This type normally follows either RTE_FLOW_ITEM_TYPE_ETH or > > - * RTE_FLOW_ITEM_TYPE_VLAN. > > + * The corresponding standard outer EtherType (TPID) values are > > + * ETHER_TYPE_VLAN or ETHER_TYPE_QINQ. It can be overridden by the preceding > > + * pattern item. > > */ > > struct rte_flow_item_vlan { > > - rte_be16_t tpid; /**< Tag protocol identifier. */ > > rte_be16_t tci; /**< Tag control information. */ > > + rte_be16_t inner_type; /**< Inner EtherType or TPID. */ > > }; > > /** Default mask for RTE_FLOW_ITEM_TYPE_VLAN. */ > > #ifndef __cplusplus > > static const struct rte_flow_item_vlan rte_flow_item_vlan_mask = { > > - .tpid = RTE_BE16(0x0000), > > - .tci = RTE_BE16(0xffff), > > + .tci = RTE_BE16(0x0fff), > > It looks like unrelated change. Yep, it should have been in a separate patch. I'll split it in my next update. Thanks for reviewing. > > > + .inner_type = RTE_BE16(0x0000), > > }; > > #endif > > <...> > -- Adrien Mazarguil 6WIND ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v2 11/15] ethdev: add transfer attribute to flow API 2018-04-06 13:25 ` [dpdk-dev] [PATCH v2 00/15] Flow API overhaul for switch offloads Adrien Mazarguil ` (9 preceding siblings ...) 2018-04-06 13:25 ` [dpdk-dev] [PATCH v2 10/15] ethdev: refine TPID handling in flow API Adrien Mazarguil @ 2018-04-06 13:25 ` Adrien Mazarguil 2018-04-06 13:25 ` [dpdk-dev] [PATCH v2 12/15] ethdev: update behavior of VF/PF in " Adrien Mazarguil ` (4 subsequent siblings) 15 siblings, 0 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-06 13:25 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev This new attribute enables applications to create flow rules that do not simply match traffic whose origin is specified in the pattern (e.g. some non-default physical port or VF), but actively affect it by applying the flow rule at the lowest possible level in the underlying device. It breaks ABI compatibility for the following public functions: - rte_flow_copy() - rte_flow_create() - rte_flow_validate() Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> --- app/test-pmd/cmdline_flow.c | 11 +++++ app/test-pmd/config.c | 6 ++- doc/guides/prog_guide/rte_flow.rst | 14 +++++++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 11 ++--- drivers/net/bnxt/bnxt_filter.c | 8 ++++ drivers/net/e1000/igb_flow.c | 44 ++++++++++++++++++++ drivers/net/enic/enic_flow.c | 6 +++ drivers/net/i40e/i40e_flow.c | 8 ++++ drivers/net/ixgbe/ixgbe_flow.c | 53 ++++++++++++++++++++++++ drivers/net/mlx4/mlx4_flow.c | 4 ++ drivers/net/mlx5/mlx5_flow.c | 7 ++++ drivers/net/mvpp2/mrvl_flow.c | 6 +++ drivers/net/sfc/sfc_flow.c | 6 +++ drivers/net/tap/tap_flow.c | 6 +++ lib/librte_ether/rte_flow.h | 18 +++++++- 15 files changed, 200 insertions(+), 8 deletions(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 3a486032d..122e9d50b 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -69,6 +69,7 @@ enum index { PRIORITY, INGRESS, EGRESS, + TRANSFER, /* Validate/create pattern. */ PATTERN, @@ -407,6 +408,7 @@ static const enum index next_vc_attr[] = { PRIORITY, INGRESS, EGRESS, + TRANSFER, PATTERN, ZERO, }; @@ -960,6 +962,12 @@ static const struct token token_list[] = { .next = NEXT(next_vc_attr), .call = parse_vc, }, + [TRANSFER] = { + .name = "transfer", + .help = "apply rule directly to endpoints found in pattern", + .next = NEXT(next_vc_attr), + .call = parse_vc, + }, /* Validate/create pattern. */ [PATTERN] = { .name = "pattern", @@ -1945,6 +1953,9 @@ parse_vc(struct context *ctx, const struct token *token, case EGRESS: out->args.vc.attr.egress = 1; return len; + case TRANSFER: + out->args.vc.attr.transfer = 1; + return len; case PATTERN: out->args.vc.pattern = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1), diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index c0fefe475..49ef87782 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -1223,6 +1223,7 @@ port_flow_complain(struct rte_flow_error *error) [RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY] = "priority field", [RTE_FLOW_ERROR_TYPE_ATTR_INGRESS] = "ingress field", [RTE_FLOW_ERROR_TYPE_ATTR_EGRESS] = "egress field", + [RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER] = "transfer field", [RTE_FLOW_ERROR_TYPE_ATTR] = "attributes structure", [RTE_FLOW_ERROR_TYPE_ITEM_NUM] = "pattern length", [RTE_FLOW_ERROR_TYPE_ITEM_SPEC] = "item specification", @@ -1488,12 +1489,13 @@ port_flow_list(portid_t port_id, uint32_t n, const uint32_t group[n]) const struct rte_flow_item *item = pf->pattern; const struct rte_flow_action *action = pf->actions; - printf("%" PRIu32 "\t%" PRIu32 "\t%" PRIu32 "\t%c%c\t", + printf("%" PRIu32 "\t%" PRIu32 "\t%" PRIu32 "\t%c%c%c\t", pf->id, pf->attr.group, pf->attr.priority, pf->attr.ingress ? 'i' : '-', - pf->attr.egress ? 'e' : '-'); + pf->attr.egress ? 'e' : '-', + pf->attr.transfer ? 't' : '-'); while (item->type != RTE_FLOW_ITEM_TYPE_END) { if (item->type != RTE_FLOW_ITEM_TYPE_VOID) printf("%s ", flow_item[item->type].name); diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index c6f16d444..735ce6323 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -178,6 +178,20 @@ directions. At least one direction must be specified. Specifying both directions at once for a given rule is not recommended but may be valid in a few cases (e.g. shared counters). +Attribute: Transfer +^^^^^^^^^^^^^^^^^^^ + +Instead of simply matching the properties of traffic as it would appear on a +given DPDK port ID, enabling this attribute transfers a flow rule to the +lowest possible level of any device endpoints found in the pattern. + +When supported, this effectively enables an application to re-route traffic +not necessarily intended for it (e.g. coming from or addressed to different +physical ports, VFs or applications) at the device level. + +It complements the behavior of some pattern items such as `Item: PORT`_ and +is meaningless without them. + Pattern item ~~~~~~~~~~~~ diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index 25fac8430..a87cd1542 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -2970,14 +2970,14 @@ following sections. - Check whether a flow rule can be created:: flow validate {port_id} - [group {group_id}] [priority {level}] [ingress] [egress] + [group {group_id}] [priority {level}] [ingress] [egress] [transfer] pattern {item} [/ {item} [...]] / end actions {action} [/ {action} [...]] / end - Create a flow rule:: flow create {port_id} - [group {group_id}] [priority {level}] [ingress] [egress] + [group {group_id}] [priority {level}] [ingress] [egress] [transfer] pattern {item} [/ {item} [...]] / end actions {action} [/ {action} [...]] / end @@ -3010,7 +3010,7 @@ underlying device in its current state but stops short of creating it. It is bound to ``rte_flow_validate()``:: flow validate {port_id} - [group {group_id}] [priority {level}] [ingress] [egress] + [group {group_id}] [priority {level}] [ingress] [egress] [transfer] pattern {item} [/ {item} [...]] / end actions {action} [/ {action} [...]] / end @@ -3047,7 +3047,7 @@ Creating flow rules to ``rte_flow_create()``:: flow create {port_id} - [group {group_id}] [priority {level}] [ingress] [egress] + [group {group_id}] [priority {level}] [ingress] [egress] [transfer] pattern {item} [/ {item} [...]] / end actions {action} [/ {action} [...]] / end @@ -3061,7 +3061,7 @@ Otherwise it will show an error message of the form:: Parameters describe in the following order: -- Attributes (*group*, *priority*, *ingress*, *egress* tokens). +- Attributes (*group*, *priority*, *ingress*, *egress*, *transfer* tokens). - A matching pattern, starting with the *pattern* token and terminated by an *end* pattern item. - Actions, starting with the *actions* token and terminated by an *end* @@ -3089,6 +3089,7 @@ specified before the ``pattern`` token. - ``priority {level}``: priority level within group. - ``ingress``: rule applies to ingress traffic. - ``egress``: rule applies to egress traffic. +- ``transfer``: apply rule directly to endpoints found in pattern. Each instance of an attribute specified several times overrides the previous value as shown below (group 4 is used):: diff --git a/drivers/net/bnxt/bnxt_filter.c b/drivers/net/bnxt/bnxt_filter.c index 51e3e8de4..862e03188 100644 --- a/drivers/net/bnxt/bnxt_filter.c +++ b/drivers/net/bnxt/bnxt_filter.c @@ -750,6 +750,14 @@ bnxt_flow_parse_attr(const struct rte_flow_attr *attr, } /* Not supported */ + if (attr->transfer) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + attr, "No support for transfer."); + return -rte_errno; + } + + /* Not supported */ if (attr->priority) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, diff --git a/drivers/net/e1000/igb_flow.c b/drivers/net/e1000/igb_flow.c index 13f6f2a28..ac0d05bfa 100644 --- a/drivers/net/e1000/igb_flow.c +++ b/drivers/net/e1000/igb_flow.c @@ -379,6 +379,15 @@ cons_parse_ntuple_filter(const struct rte_flow_attr *attr, return -rte_errno; } + /* not supported */ + if (attr->transfer) { + memset(filter, 0, sizeof(struct rte_eth_ntuple_filter)); + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + attr, "No support for transfer."); + return -rte_errno; + } + if (attr->priority > 0xFFFF) { memset(filter, 0, sizeof(struct rte_eth_ntuple_filter)); rte_flow_error_set(error, EINVAL, @@ -624,6 +633,14 @@ cons_parse_ethertype_filter(const struct rte_flow_attr *attr, } /* Not supported */ + if (attr->transfer) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + attr, "No support for transfer."); + return -rte_errno; + } + + /* Not supported */ if (attr->priority) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, @@ -923,6 +940,15 @@ cons_parse_syn_filter(const struct rte_flow_attr *attr, return -rte_errno; } + /* not supported */ + if (attr->transfer) { + memset(filter, 0, sizeof(struct rte_eth_syn_filter)); + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + attr, "No support for transfer."); + return -rte_errno; + } + /* Support 2 priorities, the lowest or highest. */ if (!attr->priority) { filter->hig_pri = 0; @@ -1211,6 +1237,15 @@ cons_parse_flex_filter(const struct rte_flow_attr *attr, return -rte_errno; } + /* not supported */ + if (attr->transfer) { + memset(filter, 0, sizeof(struct rte_eth_flex_filter)); + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + attr, "No support for transfer."); + return -rte_errno; + } + if (attr->priority > 0xFFFF) { memset(filter, 0, sizeof(struct rte_eth_flex_filter)); rte_flow_error_set(error, EINVAL, @@ -1361,6 +1396,15 @@ igb_parse_rss_filter(struct rte_eth_dev *dev, return -rte_errno; } + /* not supported */ + if (attr->transfer) { + memset(rss_conf, 0, sizeof(struct igb_rte_flow_rss_conf)); + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + attr, "No support for transfer."); + return -rte_errno; + } + if (attr->priority > 0xFFFF) { memset(rss_conf, 0, sizeof(struct igb_rte_flow_rss_conf)); rte_flow_error_set(error, EINVAL, diff --git a/drivers/net/enic/enic_flow.c b/drivers/net/enic/enic_flow.c index d645dfb63..b575d0365 100644 --- a/drivers/net/enic/enic_flow.c +++ b/drivers/net/enic/enic_flow.c @@ -1301,6 +1301,12 @@ enic_flow_parse(struct rte_eth_dev *dev, NULL, "egress is not supported"); return -rte_errno; + } else if (attrs->transfer) { + rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + NULL, + "transfer is not supported"); + return -rte_errno; } else if (!attrs->ingress) { rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c index e9550b0ce..0a3f93fad 100644 --- a/drivers/net/i40e/i40e_flow.c +++ b/drivers/net/i40e/i40e_flow.c @@ -1918,6 +1918,14 @@ i40e_flow_parse_attr(const struct rte_flow_attr *attr, } /* Not supported */ + if (attr->transfer) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + attr, "No support for transfer."); + return -rte_errno; + } + + /* Not supported */ if (attr->priority) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, diff --git a/drivers/net/ixgbe/ixgbe_flow.c b/drivers/net/ixgbe/ixgbe_flow.c index 67d22b382..1f1fa9dc4 100644 --- a/drivers/net/ixgbe/ixgbe_flow.c +++ b/drivers/net/ixgbe/ixgbe_flow.c @@ -557,6 +557,15 @@ cons_parse_ntuple_filter(const struct rte_flow_attr *attr, return -rte_errno; } + /* not supported */ + if (attr->transfer) { + memset(filter, 0, sizeof(struct rte_eth_ntuple_filter)); + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + attr, "No support for transfer."); + return -rte_errno; + } + if (attr->priority > 0xFFFF) { memset(filter, 0, sizeof(struct rte_eth_ntuple_filter)); rte_flow_error_set(error, EINVAL, @@ -787,6 +796,14 @@ cons_parse_ethertype_filter(const struct rte_flow_attr *attr, } /* Not supported */ + if (attr->transfer) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + attr, "No support for transfer."); + return -rte_errno; + } + + /* Not supported */ if (attr->priority) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, @@ -1078,6 +1095,15 @@ cons_parse_syn_filter(const struct rte_flow_attr *attr, return -rte_errno; } + /* not supported */ + if (attr->transfer) { + memset(filter, 0, sizeof(struct rte_eth_syn_filter)); + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + attr, "No support for transfer."); + return -rte_errno; + } + /* Support 2 priorities, the lowest or highest. */ if (!attr->priority) { filter->hig_pri = 0; @@ -1250,6 +1276,15 @@ cons_parse_l2_tn_filter(struct rte_eth_dev *dev, } /* not supported */ + if (attr->transfer) { + memset(filter, 0, sizeof(struct rte_eth_l2_tunnel_conf)); + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + attr, "No support for transfer."); + return -rte_errno; + } + + /* not supported */ if (attr->priority) { memset(filter, 0, sizeof(struct rte_eth_l2_tunnel_conf)); rte_flow_error_set(error, EINVAL, @@ -1354,6 +1389,15 @@ ixgbe_parse_fdir_act_attr(const struct rte_flow_attr *attr, } /* not supported */ + if (attr->transfer) { + memset(rule, 0, sizeof(struct ixgbe_fdir_rule)); + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + attr, "No support for transfer."); + return -rte_errno; + } + + /* not supported */ if (attr->priority) { memset(rule, 0, sizeof(struct ixgbe_fdir_rule)); rte_flow_error_set(error, EINVAL, @@ -2829,6 +2873,15 @@ ixgbe_parse_rss_filter(struct rte_eth_dev *dev, return -rte_errno; } + /* not supported */ + if (attr->transfer) { + memset(rss_conf, 0, sizeof(struct ixgbe_rte_flow_rss_conf)); + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + attr, "No support for transfer."); + return -rte_errno; + } + if (attr->priority > 0xFFFF) { memset(rss_conf, 0, sizeof(struct ixgbe_rte_flow_rss_conf)); rte_flow_error_set(error, EINVAL, diff --git a/drivers/net/mlx4/mlx4_flow.c b/drivers/net/mlx4/mlx4_flow.c index 779641e11..480442f87 100644 --- a/drivers/net/mlx4/mlx4_flow.c +++ b/drivers/net/mlx4/mlx4_flow.c @@ -652,6 +652,10 @@ mlx4_flow_prepare(struct priv *priv, return rte_flow_error_set (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, NULL, "egress is not supported"); + if (attr->transfer) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + NULL, "transfer is not supported"); if (!attr->ingress) return rte_flow_error_set (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 8863e451c..288610620 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -569,6 +569,13 @@ mlx5_flow_convert_attributes(const struct rte_flow_attr *attr, "egress is not supported"); return -rte_errno; } + if (attr->transfer) { + rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + NULL, + "transfer is not supported"); + return -rte_errno; + } if (!attr->ingress) { rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, diff --git a/drivers/net/mvpp2/mrvl_flow.c b/drivers/net/mvpp2/mrvl_flow.c index 6604a411f..4848d5cf9 100644 --- a/drivers/net/mvpp2/mrvl_flow.c +++ b/drivers/net/mvpp2/mrvl_flow.c @@ -2188,6 +2188,12 @@ mrvl_flow_parse_attr(struct mrvl_priv *priv __rte_unused, "Egress is not supported"); return -rte_errno; } + if (attr->transfer) { + rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, NULL, + "Transfer is not supported"); + return -rte_errno; + } return 0; } diff --git a/drivers/net/sfc/sfc_flow.c b/drivers/net/sfc/sfc_flow.c index f61d4ec92..b12a47281 100644 --- a/drivers/net/sfc/sfc_flow.c +++ b/drivers/net/sfc/sfc_flow.c @@ -1126,6 +1126,12 @@ sfc_flow_parse_attr(const struct rte_flow_attr *attr, "Egress is not supported"); return -rte_errno; } + if (attr->transfer != 0) { + rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, attr, + "Transfer is not supported"); + return -rte_errno; + } if (attr->ingress == 0) { rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, attr, diff --git a/drivers/net/tap/tap_flow.c b/drivers/net/tap/tap_flow.c index e53eff6ce..597945ad2 100644 --- a/drivers/net/tap/tap_flow.c +++ b/drivers/net/tap/tap_flow.c @@ -1041,6 +1041,12 @@ priv_flow_process(struct pmd_internals *pmd, }; int action = 0; /* Only one action authorized for now */ + if (attr->transfer) { + rte_flow_error_set( + error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + NULL, "transfer is not supported"); + return -rte_errno; + } if (attr->group > MAX_GROUP) { rte_flow_error_set( error, EINVAL, RTE_FLOW_ERROR_TYPE_ATTR_GROUP, diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index b13b0e2e6..b7bdc0469 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -72,7 +72,22 @@ struct rte_flow_attr { uint32_t priority; /**< Priority level within group. */ uint32_t ingress:1; /**< Rule applies to ingress traffic. */ uint32_t egress:1; /**< Rule applies to egress traffic. */ - uint32_t reserved:30; /**< Reserved, must be zero. */ + /** + * Instead of simply matching the properties of traffic as it would + * appear on a given DPDK port ID, enabling this attribute transfers + * a flow rule to the lowest possible level of any device endpoints + * found in the pattern. + * + * When supported, this effectively enables an application to + * re-route traffic not necessarily intended for it (e.g. coming + * from or addressed to different physical ports, VFs or + * applications) at the device level. + * + * It complements the behavior of some pattern items such as + * RTE_FLOW_ITEM_TYPE_PORT and is meaningless without them. + */ + uint32_t transfer:1; + uint32_t reserved:29; /**< Reserved, must be zero. */ }; /** @@ -1175,6 +1190,7 @@ enum rte_flow_error_type { RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, /**< Priority field. */ RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, /**< Ingress field. */ RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, /**< Egress field. */ + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, /**< Transfer field. */ RTE_FLOW_ERROR_TYPE_ATTR, /**< Attributes structure. */ RTE_FLOW_ERROR_TYPE_ITEM_NUM, /**< Pattern length. */ RTE_FLOW_ERROR_TYPE_ITEM_SPEC, /**< Item specification. */ -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v2 12/15] ethdev: update behavior of VF/PF in flow API 2018-04-06 13:25 ` [dpdk-dev] [PATCH v2 00/15] Flow API overhaul for switch offloads Adrien Mazarguil ` (10 preceding siblings ...) 2018-04-06 13:25 ` [dpdk-dev] [PATCH v2 11/15] ethdev: add transfer attribute to " Adrien Mazarguil @ 2018-04-06 13:25 ` Adrien Mazarguil 2018-04-07 9:41 ` Andrew Rybchenko 2018-04-06 13:25 ` [dpdk-dev] [PATCH v2 13/15] ethdev: rename physical port item " Adrien Mazarguil ` (3 subsequent siblings) 15 siblings, 1 reply; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-06 13:25 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev Cc: Ajit Khaparde, Somnath Kotur, Beilei Xing, Qi Zhang Contrary to all other pattern items, these are inconsistently documented as affecting traffic instead of simply matching its origin, without provision for the latter. This commit clarifies documentation and updates PMDs since the original behavior now has to be explicitly requested using the new transfer attribute. It breaks ABI compatibility for the following public functions: - rte_flow_create() - rte_flow_validate() Impacted PMDs are bnxt and i40e, for which the VF pattern item is now only supported when a transfer attribute is also present. Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Cc: Ajit Khaparde <ajit.khaparde@broadcom.com> Cc: Somnath Kotur <somnath.kotur@broadcom.com> Cc: Beilei Xing <beilei.xing@intel.com> Cc: Qi Zhang <qi.z.zhang@intel.com> --- app/test-pmd/cmdline_flow.c | 12 +++--- doc/guides/prog_guide/rte_flow.rst | 36 +++++++++--------- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 12 +++--- drivers/net/bnxt/bnxt_filter.c | 22 ++++++----- drivers/net/i40e/i40e_flow.c | 23 +++++++----- lib/librte_ether/rte_flow.h | 47 ++++++++++-------------- 6 files changed, 77 insertions(+), 75 deletions(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 122e9d50b..741d66b22 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -1041,21 +1041,21 @@ static const struct token token_list[] = { }, [ITEM_PF] = { .name = "pf", - .help = "match packets addressed to the physical function", + .help = "match traffic from/to the physical function", .priv = PRIV_ITEM(PF, 0), .next = NEXT(NEXT_ENTRY(ITEM_NEXT)), .call = parse_vc, }, [ITEM_VF] = { .name = "vf", - .help = "match packets addressed to a virtual function ID", + .help = "match traffic from/to a virtual function ID", .priv = PRIV_ITEM(VF, sizeof(struct rte_flow_item_vf)), .next = NEXT(item_vf), .call = parse_vc, }, [ITEM_VF_ID] = { .name = "id", - .help = "destination VF ID", + .help = "VF ID", .next = NEXT(item_vf, NEXT_ENTRY(UNSIGNED), item_param), .args = ARGS(ARGS_ENTRY(struct rte_flow_item_vf, id)), }, @@ -1686,14 +1686,14 @@ static const struct token token_list[] = { }, [ACTION_PF] = { .name = "pf", - .help = "redirect packets to physical device function", + .help = "direct traffic to physical function", .priv = PRIV_ACTION(PF, 0), .next = NEXT(NEXT_ENTRY(ACTION_NEXT)), .call = parse_vc, }, [ACTION_VF] = { .name = "vf", - .help = "redirect packets to virtual device function", + .help = "direct traffic to a virtual function ID", .priv = PRIV_ACTION(VF, sizeof(struct rte_flow_action_vf)), .next = NEXT(action_vf), .call = parse_vc, @@ -1708,7 +1708,7 @@ static const struct token token_list[] = { }, [ACTION_VF_ID] = { .name = "id", - .help = "VF ID to redirect packets to", + .help = "VF ID", .next = NEXT(action_vf, NEXT_ENTRY(UNSIGNED)), .args = ARGS(ARGS_ENTRY(struct rte_flow_action_vf, id)), .call = parse_vc_conf, diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 735ce6323..beedc713b 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -518,15 +518,12 @@ Usage example, matching non-TCPv4 packets only: Item: ``PF`` ^^^^^^^^^^^^ -Matches packets addressed to the physical function of the device. +Matches traffic originating from (ingress) or going to (egress) the physical +function of the current device. -If the underlying device function differs from the one that would normally -receive the matched traffic, specifying this item prevents it from reaching -that device unless the flow rule contains a `Action: PF`_. Packets are not -duplicated between device instances by default. +If supported, should work even if the physical function is not managed by +the application and thus not associated with a DPDK port ID. -- Likely to return an error or never match any traffic if applied to a VF - device. - Can be combined with any number of `Item: VF`_ to match both PF and VF traffic. - ``spec``, ``last`` and ``mask`` must not be set. @@ -548,15 +545,15 @@ duplicated between device instances by default. Item: ``VF`` ^^^^^^^^^^^^ -Matches packets addressed to a virtual function ID of the device. +Matches traffic originating from (ingress) or going to (egress) a given +virtual function of the current device. -If the underlying device function differs from the one that would normally -receive the matched traffic, specifying this item prevents it from reaching -that device unless the flow rule contains a `Action: VF`_. Packets are not -duplicated between device instances by default. +If supported, should work even if the virtual function is not managed by the +application and thus not associated with a DPDK port ID. + +Note this pattern item does not match VF representors traffic which, as +separate entities, should be addressed through their own DPDK port IDs. -- Likely to return an error or never match any traffic if this causes a VF - device to match traffic addressed to a different VF. - Can be specified multiple times to match traffic addressed to several VF IDs. - Can be combined with a PF item to match both PF and VF traffic. @@ -1379,7 +1376,10 @@ only matching traffic goes through. Action: ``PF`` ^^^^^^^^^^^^^^ -Redirects packets to the physical function (PF) of the current device. +Directs matching traffic to the physical function (PF) of the current +device. + +See `Item: PF`_. - No configurable properties. @@ -1396,13 +1396,15 @@ Redirects packets to the physical function (PF) of the current device. Action: ``VF`` ^^^^^^^^^^^^^^ -Redirects packets to a virtual function (VF) of the current device. +Directs matching traffic to a given virtual function of the current device. Packets matched by a VF pattern item can be redirected to their original VF ID instead of the specified one. This parameter may not be available and is not guaranteed to work properly if the VF part is matched by a prior flow rule or if packets are not addressed to a VF in the first place. +See `Item: VF`_. + .. _table_rte_flow_action_vf: .. table:: VF @@ -1412,7 +1414,7 @@ rule or if packets are not addressed to a VF in the first place. +==============+================================+ | ``original`` | use original VF ID if possible | +--------------+--------------------------------+ - | ``vf`` | VF ID to redirect packets to | + | ``id`` | VF ID | +--------------+--------------------------------+ Action: ``METER`` diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index a87cd1542..2f1db9a29 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3202,11 +3202,11 @@ This section lists supported pattern items and their attributes, if any. - ``num {unsigned}``: number of layers covered. -- ``pf``: match packets addressed to the physical function. +- ``pf``: match traffic from/to the physical function. -- ``vf``: match packets addressed to a virtual function ID. +- ``vf``: match traffic from/to a virtual function ID. - - ``id {unsigned}``: destination VF ID. + - ``id {unsigned}``: VF ID. - ``port``: device-specific physical port index to use. @@ -3414,12 +3414,12 @@ This section lists supported actions and their attributes, if any. - ``queues [{unsigned} [...]] end``: queue indices to use. -- ``pf``: redirect packets to physical device function. +- ``pf``: direct traffic to physical function. -- ``vf``: redirect packets to virtual device function. +- ``vf``: direct traffic to a virtual function ID. - ``original {boolean}``: use original VF ID if possible. - - ``id {unsigned}``: VF ID to redirect packets to. + - ``id {unsigned}``: VF ID. Destroying flow rules ~~~~~~~~~~~~~~~~~~~~~ diff --git a/drivers/net/bnxt/bnxt_filter.c b/drivers/net/bnxt/bnxt_filter.c index 862e03188..f2ee250e8 100644 --- a/drivers/net/bnxt/bnxt_filter.c +++ b/drivers/net/bnxt/bnxt_filter.c @@ -276,6 +276,7 @@ bnxt_filter_type_check(const struct rte_flow_item pattern[], static int bnxt_validate_and_parse_flow_type(struct bnxt *bp, + const struct rte_flow_attr *attr, const struct rte_flow_item pattern[], struct rte_flow_error *error, struct bnxt_filter_info *filter) @@ -703,6 +704,16 @@ bnxt_validate_and_parse_flow_type(struct bnxt *bp, return -rte_errno; } + if (!attr->transfer) { + rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ITEM, + item, + "Matching VF traffic without" + " affecting it (transfer attribute)" + " is unsupported"); + return -rte_errno; + } + filter->mirror_vnic_id = dflt_vnic = bnxt_hwrm_func_qcfg_vf_dflt_vnic_id(bp, vf); if (dflt_vnic < 0) { @@ -750,14 +761,6 @@ bnxt_flow_parse_attr(const struct rte_flow_attr *attr, } /* Not supported */ - if (attr->transfer) { - rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, - attr, "No support for transfer."); - return -rte_errno; - } - - /* Not supported */ if (attr->priority) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, @@ -837,7 +840,8 @@ bnxt_validate_and_parse_flow(struct rte_eth_dev *dev, goto ret; } - rc = bnxt_validate_and_parse_flow_type(bp, pattern, error, filter); + rc = bnxt_validate_and_parse_flow_type(bp, attr, pattern, error, + filter); if (rc != 0) goto ret; diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c index 0a3f93fad..96a698a2c 100644 --- a/drivers/net/i40e/i40e_flow.c +++ b/drivers/net/i40e/i40e_flow.c @@ -54,6 +54,7 @@ static int i40e_flow_parse_ethertype_action(struct rte_eth_dev *dev, struct rte_flow_error *error, struct rte_eth_ethertype_filter *filter); static int i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev, + const struct rte_flow_attr *attr, const struct rte_flow_item *pattern, struct rte_flow_error *error, struct i40e_fdir_filter_conf *filter); @@ -1918,14 +1919,6 @@ i40e_flow_parse_attr(const struct rte_flow_attr *attr, } /* Not supported */ - if (attr->transfer) { - rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, - attr, "No support for transfer."); - return -rte_errno; - } - - /* Not supported */ if (attr->priority) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, @@ -2429,6 +2422,7 @@ i40e_flow_fdir_get_pctype_value(struct i40e_pf *pf, */ static int i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev, + const struct rte_flow_attr *attr, const struct rte_flow_item *pattern, struct rte_flow_error *error, struct i40e_fdir_filter_conf *filter) @@ -2969,6 +2963,16 @@ i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev, break; case RTE_FLOW_ITEM_TYPE_VF: vf_spec = item->spec; + if (!attr->transfer) { + rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ITEM, + item, + "Matching VF traffic" + " without affecting it" + " (transfer attribute)" + " is unsupported"); + return -rte_errno; + } filter->input.flow_ext.is_vf = 1; filter->input.flow_ext.dst_id = vf_spec->id; if (filter->input.flow_ext.is_vf && @@ -3131,7 +3135,8 @@ i40e_flow_parse_fdir_filter(struct rte_eth_dev *dev, &filter->fdir_filter; int ret; - ret = i40e_flow_parse_fdir_pattern(dev, pattern, error, fdir_filter); + ret = i40e_flow_parse_fdir_pattern(dev, attr, pattern, error, + fdir_filter); if (ret) return ret; diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index b7bdc0469..bb9d59833 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -148,13 +148,8 @@ enum rte_flow_item_type { /** * [META] * - * Matches packets addressed to the physical function of the device. - * - * If the underlying device function differs from the one that would - * normally receive the matched traffic, specifying this item - * prevents it from reaching that device unless the flow rule - * contains a PF action. Packets are not duplicated between device - * instances by default. + * Matches traffic originating from (ingress) or going to (egress) + * the physical function of the current device. * * No associated specification structure. */ @@ -163,13 +158,8 @@ enum rte_flow_item_type { /** * [META] * - * Matches packets addressed to a virtual function ID of the device. - * - * If the underlying device function differs from the one that would - * normally receive the matched traffic, specifying this item - * prevents it from reaching that device unless the flow rule - * contains a VF action. Packets are not duplicated between device - * instances by default. + * Matches traffic originating from (ingress) or going to (egress) a + * given virtual function of the current device. * * See struct rte_flow_item_vf. */ @@ -367,15 +357,15 @@ static const struct rte_flow_item_any rte_flow_item_any_mask = { /** * RTE_FLOW_ITEM_TYPE_VF * - * Matches packets addressed to a virtual function ID of the device. + * Matches traffic originating from (ingress) or going to (egress) a given + * virtual function of the current device. * - * If the underlying device function differs from the one that would - * normally receive the matched traffic, specifying this item prevents it - * from reaching that device unless the flow rule contains a VF - * action. Packets are not duplicated between device instances by default. + * If supported, should work even if the virtual function is not managed by + * the application and thus not associated with a DPDK port ID. + * + * Note this pattern item does not match VF representors traffic which, as + * separate entities, should be addressed through their own DPDK port IDs. * - * - Likely to return an error or never match any traffic if this causes a - * VF device to match traffic addressed to a different VF. * - Can be specified multiple times to match traffic addressed to several * VF IDs. * - Can be combined with a PF item to match both PF and VF traffic. @@ -383,7 +373,7 @@ static const struct rte_flow_item_any rte_flow_item_any_mask = { * A zeroed mask can be used to match any VF ID. */ struct rte_flow_item_vf { - uint32_t id; /**< Destination VF ID. */ + uint32_t id; /**< VF ID. */ }; /** Default mask for RTE_FLOW_ITEM_TYPE_VF. */ @@ -984,16 +974,16 @@ enum rte_flow_action_type { RTE_FLOW_ACTION_TYPE_RSS, /** - * Redirects packets to the physical function (PF) of the current - * device. + * Directs matching traffic to the physical function (PF) of the + * current device. * * No associated configuration structure. */ RTE_FLOW_ACTION_TYPE_PF, /** - * Redirects packets to the virtual function (VF) of the current - * device with the specified ID. + * Directs matching traffic to a given virtual function of the + * current device. * * See struct rte_flow_action_vf. */ @@ -1101,7 +1091,8 @@ struct rte_flow_action_rss { /** * RTE_FLOW_ACTION_TYPE_VF * - * Redirects packets to a virtual function (VF) of the current device. + * Directs matching traffic to a given virtual function of the current + * device. * * Packets matched by a VF pattern item can be redirected to their original * VF ID instead of the specified one. This parameter may not be available @@ -1112,7 +1103,7 @@ struct rte_flow_action_rss { struct rte_flow_action_vf { uint32_t original:1; /**< Use original VF ID if possible. */ uint32_t reserved:31; /**< Reserved, must be zero. */ - uint32_t id; /**< VF ID to redirect packets to. */ + uint32_t id; /**< VF ID. */ }; /** -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [dpdk-dev] [PATCH v2 12/15] ethdev: update behavior of VF/PF in flow API 2018-04-06 13:25 ` [dpdk-dev] [PATCH v2 12/15] ethdev: update behavior of VF/PF in " Adrien Mazarguil @ 2018-04-07 9:41 ` Andrew Rybchenko 2018-04-09 14:49 ` Adrien Mazarguil 0 siblings, 1 reply; 157+ messages in thread From: Andrew Rybchenko @ 2018-04-07 9:41 UTC (permalink / raw) To: Adrien Mazarguil, Thomas Monjalon, Ferruh Yigit, dev Cc: Ajit Khaparde, Somnath Kotur, Beilei Xing, Qi Zhang On 04/06/2018 04:25 PM, Adrien Mazarguil wrote: > Contrary to all other pattern items, these are inconsistently documented as > affecting traffic instead of simply matching its origin, without provision > for the latter. > > This commit clarifies documentation and updates PMDs since the original > behavior now has to be explicitly requested using the new transfer > attribute. > > It breaks ABI compatibility for the following public functions: > > - rte_flow_create() > - rte_flow_validate() > > Impacted PMDs are bnxt and i40e, for which the VF pattern item is now only > supported when a transfer attribute is also present. > > Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> > Cc: Ajit Khaparde <ajit.khaparde@broadcom.com> > Cc: Somnath Kotur <somnath.kotur@broadcom.com> > Cc: Beilei Xing <beilei.xing@intel.com> > Cc: Qi Zhang <qi.z.zhang@intel.com> > --- > app/test-pmd/cmdline_flow.c | 12 +++--- > doc/guides/prog_guide/rte_flow.rst | 36 +++++++++--------- > doc/guides/testpmd_app_ug/testpmd_funcs.rst | 12 +++--- > drivers/net/bnxt/bnxt_filter.c | 22 ++++++----- > drivers/net/i40e/i40e_flow.c | 23 +++++++----- > lib/librte_ether/rte_flow.h | 47 ++++++++++-------------- > 6 files changed, 77 insertions(+), 75 deletions(-) <...> > diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst > index 735ce6323..beedc713b 100644 > --- a/doc/guides/prog_guide/rte_flow.rst > +++ b/doc/guides/prog_guide/rte_flow.rst > @@ -518,15 +518,12 @@ Usage example, matching non-TCPv4 packets only: > Item: ``PF`` > ^^^^^^^^^^^^ > > -Matches packets addressed to the physical function of the device. > +Matches traffic originating from (ingress) or going to (egress) the physical > +function of the current device. Not sure that I understand above. It looks like ingress and egress are misplaced. There many similar cases below. <...> ^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [dpdk-dev] [PATCH v2 12/15] ethdev: update behavior of VF/PF in flow API 2018-04-07 9:41 ` Andrew Rybchenko @ 2018-04-09 14:49 ` Adrien Mazarguil 0 siblings, 0 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-09 14:49 UTC (permalink / raw) To: Andrew Rybchenko Cc: Thomas Monjalon, Ferruh Yigit, dev, Ajit Khaparde, Somnath Kotur, Beilei Xing, Qi Zhang On Sat, Apr 07, 2018 at 12:41:17PM +0300, Andrew Rybchenko wrote: > On 04/06/2018 04:25 PM, Adrien Mazarguil wrote: > > Contrary to all other pattern items, these are inconsistently documented as > > affecting traffic instead of simply matching its origin, without provision > > for the latter. > > > > This commit clarifies documentation and updates PMDs since the original > > behavior now has to be explicitly requested using the new transfer > > attribute. > > > > It breaks ABI compatibility for the following public functions: > > > > - rte_flow_create() > > - rte_flow_validate() > > > > Impacted PMDs are bnxt and i40e, for which the VF pattern item is now only > > supported when a transfer attribute is also present. > > > > Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> > > Cc: Ajit Khaparde <ajit.khaparde@broadcom.com> > > Cc: Somnath Kotur <somnath.kotur@broadcom.com> > > Cc: Beilei Xing <beilei.xing@intel.com> > > Cc: Qi Zhang <qi.z.zhang@intel.com> > > --- > > app/test-pmd/cmdline_flow.c | 12 +++--- > > doc/guides/prog_guide/rte_flow.rst | 36 +++++++++--------- > > doc/guides/testpmd_app_ug/testpmd_funcs.rst | 12 +++--- > > drivers/net/bnxt/bnxt_filter.c | 22 ++++++----- > > drivers/net/i40e/i40e_flow.c | 23 +++++++----- > > lib/librte_ether/rte_flow.h | 47 ++++++++++-------------- > > 6 files changed, 77 insertions(+), 75 deletions(-) > > <...> > > > diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst > > index 735ce6323..beedc713b 100644 > > --- a/doc/guides/prog_guide/rte_flow.rst > > +++ b/doc/guides/prog_guide/rte_flow.rst > > @@ -518,15 +518,12 @@ Usage example, matching non-TCPv4 packets only: > > Item: ``PF`` > > ^^^^^^^^^^^^ > > -Matches packets addressed to the physical function of the device. > > +Matches traffic originating from (ingress) or going to (egress) the physical > > +function of the current device. > > Not sure that I understand above. It looks like ingress and egress are > misplaced. > There many similar cases below. In this API, "ingress" and "egress" are always defined as relative to the application creating the flow rule. In that sense they are respectively synonyms for "from" and "to". I agree they are not properly defined in this document, in fact ingress and egress were clarified (with diagrams and all) in the RFC submitted prior to this patch [1]. I will update the "Attribute: Traffic direction" section in my next update. [1] See "Traffic direction" in http://dpdk.org/ml/archives/dev/2018-March/092513.html -- Adrien Mazarguil 6WIND ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v2 13/15] ethdev: rename physical port item in flow API 2018-04-06 13:25 ` [dpdk-dev] [PATCH v2 00/15] Flow API overhaul for switch offloads Adrien Mazarguil ` (11 preceding siblings ...) 2018-04-06 13:25 ` [dpdk-dev] [PATCH v2 12/15] ethdev: update behavior of VF/PF in " Adrien Mazarguil @ 2018-04-06 13:25 ` Adrien Mazarguil 2018-04-06 13:25 ` [dpdk-dev] [PATCH v2 14/15] ethdev: add physical port action to " Adrien Mazarguil ` (2 subsequent siblings) 15 siblings, 0 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-06 13:25 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev While RTE_FLOW_ITEM_TYPE_PORT refers to physical ports of the underlying device using specific identifiers, these are often confused with DPDK port IDs exposed to applications in the global name space. Since this pattern item is seldom used, rename it RTE_FLOW_ITEM_PHY_PORT for better clarity. No ABI impact. Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> --- app/test-pmd/cmdline_flow.c | 27 +++++++++++---------- app/test-pmd/config.c | 2 +- doc/guides/prog_guide/rte_flow.rst | 22 ++++++++--------- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 2 +- lib/librte_ether/rte_flow.c | 2 +- lib/librte_ether/rte_flow.h | 31 ++++++++++-------------- 6 files changed, 41 insertions(+), 45 deletions(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 741d66b22..bfe532f0a 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -87,8 +87,8 @@ enum index { ITEM_PF, ITEM_VF, ITEM_VF_ID, - ITEM_PORT, - ITEM_PORT_INDEX, + ITEM_PHY_PORT, + ITEM_PHY_PORT_INDEX, ITEM_RAW, ITEM_RAW_RELATIVE, ITEM_RAW_SEARCH, @@ -441,7 +441,7 @@ static const enum index next_item[] = { ITEM_ANY, ITEM_PF, ITEM_VF, - ITEM_PORT, + ITEM_PHY_PORT, ITEM_RAW, ITEM_ETH, ITEM_VLAN, @@ -482,8 +482,8 @@ static const enum index item_vf[] = { ZERO, }; -static const enum index item_port[] = { - ITEM_PORT_INDEX, +static const enum index item_phy_port[] = { + ITEM_PHY_PORT_INDEX, ITEM_NEXT, ZERO, }; @@ -1059,18 +1059,19 @@ static const struct token token_list[] = { .next = NEXT(item_vf, NEXT_ENTRY(UNSIGNED), item_param), .args = ARGS(ARGS_ENTRY(struct rte_flow_item_vf, id)), }, - [ITEM_PORT] = { - .name = "port", - .help = "device-specific physical port index to use", - .priv = PRIV_ITEM(PORT, sizeof(struct rte_flow_item_port)), - .next = NEXT(item_port), + [ITEM_PHY_PORT] = { + .name = "phy_port", + .help = "match traffic from/to a specific physical port", + .priv = PRIV_ITEM(PHY_PORT, + sizeof(struct rte_flow_item_phy_port)), + .next = NEXT(item_phy_port), .call = parse_vc, }, - [ITEM_PORT_INDEX] = { + [ITEM_PHY_PORT_INDEX] = { .name = "index", .help = "physical port index", - .next = NEXT(item_port, NEXT_ENTRY(UNSIGNED), item_param), - .args = ARGS(ARGS_ENTRY(struct rte_flow_item_port, index)), + .next = NEXT(item_phy_port, NEXT_ENTRY(UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_phy_port, index)), }, [ITEM_RAW] = { .name = "raw", diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 49ef87782..9f968919e 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -960,7 +960,7 @@ static const struct { MK_FLOW_ITEM(ANY, sizeof(struct rte_flow_item_any)), MK_FLOW_ITEM(PF, 0), MK_FLOW_ITEM(VF, sizeof(struct rte_flow_item_vf)), - MK_FLOW_ITEM(PORT, sizeof(struct rte_flow_item_port)), + MK_FLOW_ITEM(PHY_PORT, sizeof(struct rte_flow_item_phy_port)), MK_FLOW_ITEM(RAW, sizeof(struct rte_flow_item_raw)), MK_FLOW_ITEM(ETH, sizeof(struct rte_flow_item_eth)), MK_FLOW_ITEM(VLAN, sizeof(struct rte_flow_item_vlan)), diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index beedc713b..656d4b5b7 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -189,8 +189,8 @@ When supported, this effectively enables an application to re-route traffic not necessarily intended for it (e.g. coming from or addressed to different physical ports, VFs or applications) at the device level. -It complements the behavior of some pattern items such as `Item: PORT`_ and -is meaningless without them. +It complements the behavior of some pattern items such as `Item: PHY_PORT`_ +and is meaningless without them. Pattern item ~~~~~~~~~~~~ @@ -573,15 +573,15 @@ separate entities, should be addressed through their own DPDK port IDs. | ``mask`` | ``id`` | zeroed to match any VF ID | +----------+----------+---------------------------+ -Item: ``PORT`` -^^^^^^^^^^^^^^ +Item: ``PHY_PORT`` +^^^^^^^^^^^^^^^^^^ -Matches packets coming from the specified physical port of the underlying -device. +Matches traffic originating from (ingress) or going to (egress) a physical +port of the underlying device. -The first PORT item overrides the physical port normally associated with the -specified DPDK input port (port_id). This item can be provided several times -to match additional physical ports. +The first PHY_PORT item overrides the physical port normally associated with +the specified DPDK input port (port_id). This item can be provided several +times to match additional physical ports. Note that physical ports are not necessarily tied to DPDK input ports (port_id) when those are not under DPDK control. Possible values are @@ -593,9 +593,9 @@ associated with a port_id should be retrieved by other means. - Default ``mask`` matches any port index. -.. _table_rte_flow_item_port: +.. _table_rte_flow_item_phy_port: -.. table:: PORT +.. table:: PHY_PORT +----------+-----------+--------------------------------+ | Field | Subfield | Value | diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index 2f1db9a29..1d9ce6963 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3208,7 +3208,7 @@ This section lists supported pattern items and their attributes, if any. - ``id {unsigned}``: VF ID. -- ``port``: device-specific physical port index to use. +- ``phy_port``: match traffic from/to a specific physical port. - ``index {unsigned}``: physical port index. diff --git a/lib/librte_ether/rte_flow.c b/lib/librte_ether/rte_flow.c index 1f247d656..6d4d7f5ed 100644 --- a/lib/librte_ether/rte_flow.c +++ b/lib/librte_ether/rte_flow.c @@ -38,7 +38,7 @@ static const struct rte_flow_desc_data rte_flow_desc_item[] = { MK_FLOW_ITEM(ANY, sizeof(struct rte_flow_item_any)), MK_FLOW_ITEM(PF, 0), MK_FLOW_ITEM(VF, sizeof(struct rte_flow_item_vf)), - MK_FLOW_ITEM(PORT, sizeof(struct rte_flow_item_port)), + MK_FLOW_ITEM(PHY_PORT, sizeof(struct rte_flow_item_phy_port)), MK_FLOW_ITEM(RAW, sizeof(struct rte_flow_item_raw)), MK_FLOW_ITEM(ETH, sizeof(struct rte_flow_item_eth)), MK_FLOW_ITEM(VLAN, sizeof(struct rte_flow_item_vlan)), diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index bb9d59833..cd4cde3fa 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -84,7 +84,7 @@ struct rte_flow_attr { * applications) at the device level. * * It complements the behavior of some pattern items such as - * RTE_FLOW_ITEM_TYPE_PORT and is meaningless without them. + * RTE_FLOW_ITEM_TYPE_PHY_PORT and is meaningless without them. */ uint32_t transfer:1; uint32_t reserved:29; /**< Reserved, must be zero. */ @@ -168,17 +168,12 @@ enum rte_flow_item_type { /** * [META] * - * Matches packets coming from the specified physical port of the - * underlying device. - * - * The first PORT item overrides the physical port normally - * associated with the specified DPDK input port (port_id). This - * item can be provided several times to match additional physical - * ports. + * Matches traffic originating from (ingress) or going to (egress) a + * physical port of the underlying device. * - * See struct rte_flow_item_port. + * See struct rte_flow_item_phy_port. */ - RTE_FLOW_ITEM_TYPE_PORT, + RTE_FLOW_ITEM_TYPE_PHY_PORT, /** * Matches a byte string of a given length at a given offset. @@ -384,13 +379,13 @@ static const struct rte_flow_item_vf rte_flow_item_vf_mask = { #endif /** - * RTE_FLOW_ITEM_TYPE_PORT + * RTE_FLOW_ITEM_TYPE_PHY_PORT * - * Matches packets coming from the specified physical port of the underlying - * device. + * Matches traffic originating from (ingress) or going to (egress) a + * physical port of the underlying device. * - * The first PORT item overrides the physical port normally associated with - * the specified DPDK input port (port_id). This item can be provided + * The first PHY_PORT item overrides the physical port normally associated + * with the specified DPDK input port (port_id). This item can be provided * several times to match additional physical ports. * * Note that physical ports are not necessarily tied to DPDK input ports @@ -403,13 +398,13 @@ static const struct rte_flow_item_vf rte_flow_item_vf_mask = { * * A zeroed mask can be used to match any port index. */ -struct rte_flow_item_port { +struct rte_flow_item_phy_port { uint32_t index; /**< Physical port index. */ }; -/** Default mask for RTE_FLOW_ITEM_TYPE_PORT. */ +/** Default mask for RTE_FLOW_ITEM_TYPE_PHY_PORT. */ #ifndef __cplusplus -static const struct rte_flow_item_port rte_flow_item_port_mask = { +static const struct rte_flow_item_phy_port rte_flow_item_phy_port_mask = { .index = 0x00000000, }; #endif -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v2 14/15] ethdev: add physical port action to flow API 2018-04-06 13:25 ` [dpdk-dev] [PATCH v2 00/15] Flow API overhaul for switch offloads Adrien Mazarguil ` (12 preceding siblings ...) 2018-04-06 13:25 ` [dpdk-dev] [PATCH v2 13/15] ethdev: rename physical port item " Adrien Mazarguil @ 2018-04-06 13:25 ` Adrien Mazarguil 2018-04-07 9:51 ` Andrew Rybchenko 2018-04-06 13:25 ` [dpdk-dev] [PATCH v2 15/15] ethdev: add port ID item and " Adrien Mazarguil 2018-04-10 16:36 ` [dpdk-dev] [PATCH v3 00/16] Flow API overhaul for switch offloads Adrien Mazarguil 15 siblings, 1 reply; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-06 13:25 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev; +Cc: Zhang, Qi Z This patch adds the missing action counterpart to the PHY_PORT pattern item, that is, the ability to directly inject matching traffic into a physical port of the underlying device. It breaks ABI compatibility for the following public functions: - rte_flow_copy() - rte_flow_create() - rte_flow_query() - rte_flow_validate() Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Cc: "Zhang, Qi Z" <qi.z.zhang@intel.com> --- app/test-pmd/cmdline_flow.c | 35 ++++++++++++++++++++++++ app/test-pmd/config.c | 1 + doc/guides/prog_guide/rte_flow.rst | 20 ++++++++++++++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 5 ++++ lib/librte_ether/rte_flow.c | 1 + lib/librte_ether/rte_flow.h | 22 +++++++++++++++ 6 files changed, 84 insertions(+) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index bfe532f0a..c77525ad9 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -182,6 +182,9 @@ enum index { ACTION_VF, ACTION_VF_ORIGINAL, ACTION_VF_ID, + ACTION_PHY_PORT, + ACTION_PHY_PORT_ORIGINAL, + ACTION_PHY_PORT_INDEX, ACTION_METER, ACTION_METER_ID, }; @@ -623,6 +626,7 @@ static const enum index next_action[] = { ACTION_RSS, ACTION_PF, ACTION_VF, + ACTION_PHY_PORT, ACTION_METER, ZERO, }; @@ -657,6 +661,13 @@ static const enum index action_vf[] = { ZERO, }; +static const enum index action_phy_port[] = { + ACTION_PHY_PORT_ORIGINAL, + ACTION_PHY_PORT_INDEX, + ACTION_NEXT, + ZERO, +}; + static const enum index action_meter[] = { ACTION_METER_ID, ACTION_NEXT, @@ -1714,6 +1725,30 @@ static const struct token token_list[] = { .args = ARGS(ARGS_ENTRY(struct rte_flow_action_vf, id)), .call = parse_vc_conf, }, + [ACTION_PHY_PORT] = { + .name = "phy_port", + .help = "direct packets to physical port index", + .priv = PRIV_ACTION(PHY_PORT, + sizeof(struct rte_flow_action_phy_port)), + .next = NEXT(action_phy_port), + .call = parse_vc, + }, + [ACTION_PHY_PORT_ORIGINAL] = { + .name = "original", + .help = "use original port index if possible", + .next = NEXT(action_phy_port, NEXT_ENTRY(BOOLEAN)), + .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_phy_port, + original, 1)), + .call = parse_vc_conf, + }, + [ACTION_PHY_PORT_INDEX] = { + .name = "index", + .help = "physical port index", + .next = NEXT(action_phy_port, NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_phy_port, + index)), + .call = parse_vc_conf, + }, [ACTION_METER] = { .name = "meter", .help = "meter the directed packets at given id", diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 9f968919e..effb4ff81 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -1058,6 +1058,7 @@ static const struct { MK_FLOW_ACTION(RSS, sizeof(struct rte_flow_action_rss)), MK_FLOW_ACTION(PF, 0), MK_FLOW_ACTION(VF, sizeof(struct rte_flow_action_vf)), + MK_FLOW_ACTION(PHY_PORT, sizeof(struct rte_flow_action_phy_port)), MK_FLOW_ACTION(METER, sizeof(struct rte_flow_action_meter)), }; diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 656d4b5b7..ec59d0f3c 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -1417,6 +1417,26 @@ See `Item: VF`_. | ``id`` | VF ID | +--------------+--------------------------------+ +Action: ``PHY_PORT`` +^^^^^^^^^^^^^^^^^^^^ + +Directs matching traffic to a given physical port index of the underlying +device. + +See `Item: PHY_PORT`_. + +.. _table_rte_flow_action_phy_port: + +.. table:: PHY_PORT + + +--------------+-------------------------------------+ + | Field | Value | + +==============+=====================================+ + | ``original`` | use original port index if possible | + +--------------+-------------------------------------+ + | ``index`` | physical port index | + +--------------+-------------------------------------+ + Action: ``METER`` ^^^^^^^^^^^^^^^^^ diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index 1d9ce6963..ca23ba146 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3421,6 +3421,11 @@ This section lists supported actions and their attributes, if any. - ``original {boolean}``: use original VF ID if possible. - ``id {unsigned}``: VF ID. +- ``phy_port``: direct packets to physical port index. + + - ``original {boolean}``: use original port index if possible. + - ``index {unsigned}``: physical port index. + Destroying flow rules ~~~~~~~~~~~~~~~~~~~~~ diff --git a/lib/librte_ether/rte_flow.c b/lib/librte_ether/rte_flow.c index 6d4d7f5ed..e0fd78dd5 100644 --- a/lib/librte_ether/rte_flow.c +++ b/lib/librte_ether/rte_flow.c @@ -76,6 +76,7 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = { MK_FLOW_ACTION(RSS, sizeof(struct rte_flow_action_rss)), MK_FLOW_ACTION(PF, 0), MK_FLOW_ACTION(VF, sizeof(struct rte_flow_action_vf)), + MK_FLOW_ACTION(PHY_PORT, sizeof(struct rte_flow_action_phy_port)), }; static int diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index cd4cde3fa..68a13ffa9 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -985,6 +985,14 @@ enum rte_flow_action_type { RTE_FLOW_ACTION_TYPE_VF, /** + * Directs packets to a given physical port index of the underlying + * device. + * + * See struct rte_flow_action_phy_port. + */ + RTE_FLOW_ACTION_TYPE_PHY_PORT, + + /** * Traffic metering and policing (MTR). * * See struct rte_flow_action_meter. @@ -1102,6 +1110,20 @@ struct rte_flow_action_vf { }; /** + * RTE_FLOW_ACTION_TYPE_PHY_PORT + * + * Directs packets to a given physical port index of the underlying + * device. + * + * @see RTE_FLOW_ITEM_TYPE_PHY_PORT + */ +struct rte_flow_action_phy_port { + uint32_t original:1; /**< Use original port index if possible. */ + uint32_t reserved:31; /**< Reserved, must be zero. */ + uint32_t index; /**< Physical port index. */ +}; + +/** * RTE_FLOW_ACTION_TYPE_METER * * Traffic metering and policing (MTR). -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [dpdk-dev] [PATCH v2 14/15] ethdev: add physical port action to flow API 2018-04-06 13:25 ` [dpdk-dev] [PATCH v2 14/15] ethdev: add physical port action to " Adrien Mazarguil @ 2018-04-07 9:51 ` Andrew Rybchenko 2018-04-09 15:00 ` Adrien Mazarguil 0 siblings, 1 reply; 157+ messages in thread From: Andrew Rybchenko @ 2018-04-07 9:51 UTC (permalink / raw) To: Adrien Mazarguil, Thomas Monjalon, Ferruh Yigit, dev; +Cc: Zhang, Qi Z On 04/06/2018 04:25 PM, Adrien Mazarguil wrote: > This patch adds the missing action counterpart to the PHY_PORT pattern > item, that is, the ability to directly inject matching traffic into a > physical port of the underlying device. Does it mean that if it is applied on ingress (incoming packet from network) it will simply send packets back to network (specified physical port)? And if it is applied on egress (outgoing from device to network) it will be directed to possibly different physical port and sent to network. > It breaks ABI compatibility for the following public functions: > > - rte_flow_copy() > - rte_flow_create() > - rte_flow_query() > - rte_flow_validate() > > Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> > Cc: "Zhang, Qi Z" <qi.z.zhang@intel.com> > --- > app/test-pmd/cmdline_flow.c | 35 ++++++++++++++++++++++++ > app/test-pmd/config.c | 1 + > doc/guides/prog_guide/rte_flow.rst | 20 ++++++++++++++ > doc/guides/testpmd_app_ug/testpmd_funcs.rst | 5 ++++ > lib/librte_ether/rte_flow.c | 1 + > lib/librte_ether/rte_flow.h | 22 +++++++++++++++ > 6 files changed, 84 insertions(+) <...> ^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [dpdk-dev] [PATCH v2 14/15] ethdev: add physical port action to flow API 2018-04-07 9:51 ` Andrew Rybchenko @ 2018-04-09 15:00 ` Adrien Mazarguil 0 siblings, 0 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-09 15:00 UTC (permalink / raw) To: Andrew Rybchenko; +Cc: Thomas Monjalon, Ferruh Yigit, dev, Zhang, Qi Z On Sat, Apr 07, 2018 at 12:51:40PM +0300, Andrew Rybchenko wrote: > On 04/06/2018 04:25 PM, Adrien Mazarguil wrote: > > This patch adds the missing action counterpart to the PHY_PORT pattern > > item, that is, the ability to directly inject matching traffic into a > > physical port of the underlying device. > > Does it mean that if it is applied on ingress (incoming packet from network) > it will simply send packets back to network (specified physical port)? Precisely. > And if it is applied on egress (outgoing from device to network) it will > be directed to possibly different physical port and sent to network. Right, note it gives applications the ability to express that wish, the fact PMDs support it is another matter :) In any case, this action is added for API completeness but should be rarely necessary since we chose to go with port representors. Port representors will expose valid DPDK port IDs, therefore applications will simply have to create ingress/egress flow rules on the right DPDK port targeting different port IDs through the PORT_ID action. > > It breaks ABI compatibility for the following public functions: > > > > - rte_flow_copy() > > - rte_flow_create() > > - rte_flow_query() > > - rte_flow_validate() > > > > Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> > > Cc: "Zhang, Qi Z" <qi.z.zhang@intel.com> > > --- > > app/test-pmd/cmdline_flow.c | 35 ++++++++++++++++++++++++ > > app/test-pmd/config.c | 1 + > > doc/guides/prog_guide/rte_flow.rst | 20 ++++++++++++++ > > doc/guides/testpmd_app_ug/testpmd_funcs.rst | 5 ++++ > > lib/librte_ether/rte_flow.c | 1 + > > lib/librte_ether/rte_flow.h | 22 +++++++++++++++ > > 6 files changed, 84 insertions(+) > > <...> -- Adrien Mazarguil 6WIND ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v2 15/15] ethdev: add port ID item and action to flow API 2018-04-06 13:25 ` [dpdk-dev] [PATCH v2 00/15] Flow API overhaul for switch offloads Adrien Mazarguil ` (13 preceding siblings ...) 2018-04-06 13:25 ` [dpdk-dev] [PATCH v2 14/15] ethdev: add physical port action to " Adrien Mazarguil @ 2018-04-06 13:25 ` Adrien Mazarguil 2018-04-10 16:36 ` [dpdk-dev] [PATCH v3 00/16] Flow API overhaul for switch offloads Adrien Mazarguil 15 siblings, 0 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-06 13:25 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev; +Cc: Zhang, Qi Z, Declan Doherty RTE_FLOW_ACTION_TYPE_PORT_ID brings the ability to inject matching traffic into a different device, as identified by its DPDK port ID. This is normally only supported when the target port ID has some kind of relationship with the port ID the flow rule is created against, such as being exposed by a common physical device (e.g. a different port of an Ethernet switch). The converse pattern item, RTE_FLOW_ITEM_TYPE_PORT_ID, makes the resulting flow rule match traffic whose origin is the specified port ID. Note that specifying a port ID that differs from the one the flow rule is created against is normally meaningless (if even accepted), but can make sense if combined with the transfer attribute. These must not be confused with their PHY_PORT counterparts, which refer to physical ports using device-specific indices, but unlike PORT_ID are not necessarily tied to DPDK port IDs. This breaks ABI compatibility for the following public functions: - rte_flow_copy() - rte_flow_create() - rte_flow_query() - rte_flow_validate() Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Reviewed-by: Qi Zhang <qi.z.zhang@intel.com> Cc: "Zhang, Qi Z" <qi.z.zhang@intel.com> Cc: Declan Doherty <declan.doherty@intel.com> --- This patch provides the same functionality and supersedes Qi Zhang's "ether: add flow action to redirect packet to a port" [1]. The main differences are: - Action is named PORT_ID instead of PORT. - Addition of a PORT_ID pattern item. - More extensive documentation. - Testpmd support. - rte_flow_copy() support. [1] http://dpdk.org/ml/archives/dev/2018-April/094648.html --- app/test-pmd/cmdline_flow.c | 57 ++++++++++++++++++++++++ app/test-pmd/config.c | 2 + doc/guides/prog_guide/rte_flow.rst | 48 ++++++++++++++++++++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 9 ++++ lib/librte_ether/rte_flow.c | 2 + lib/librte_ether/rte_flow.h | 56 +++++++++++++++++++++++ 6 files changed, 174 insertions(+) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index c77525ad9..f85c1c57f 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -89,6 +89,8 @@ enum index { ITEM_VF_ID, ITEM_PHY_PORT, ITEM_PHY_PORT_INDEX, + ITEM_PORT_ID, + ITEM_PORT_ID_ID, ITEM_RAW, ITEM_RAW_RELATIVE, ITEM_RAW_SEARCH, @@ -185,6 +187,9 @@ enum index { ACTION_PHY_PORT, ACTION_PHY_PORT_ORIGINAL, ACTION_PHY_PORT_INDEX, + ACTION_PORT_ID, + ACTION_PORT_ID_ORIGINAL, + ACTION_PORT_ID_ID, ACTION_METER, ACTION_METER_ID, }; @@ -445,6 +450,7 @@ static const enum index next_item[] = { ITEM_PF, ITEM_VF, ITEM_PHY_PORT, + ITEM_PORT_ID, ITEM_RAW, ITEM_ETH, ITEM_VLAN, @@ -491,6 +497,12 @@ static const enum index item_phy_port[] = { ZERO, }; +static const enum index item_port_id[] = { + ITEM_PORT_ID_ID, + ITEM_NEXT, + ZERO, +}; + static const enum index item_raw[] = { ITEM_RAW_RELATIVE, ITEM_RAW_SEARCH, @@ -627,6 +639,7 @@ static const enum index next_action[] = { ACTION_PF, ACTION_VF, ACTION_PHY_PORT, + ACTION_PORT_ID, ACTION_METER, ZERO, }; @@ -668,6 +681,13 @@ static const enum index action_phy_port[] = { ZERO, }; +static const enum index action_port_id[] = { + ACTION_PORT_ID_ORIGINAL, + ACTION_PORT_ID_ID, + ACTION_NEXT, + ZERO, +}; + static const enum index action_meter[] = { ACTION_METER_ID, ACTION_NEXT, @@ -1084,6 +1104,20 @@ static const struct token token_list[] = { .next = NEXT(item_phy_port, NEXT_ENTRY(UNSIGNED), item_param), .args = ARGS(ARGS_ENTRY(struct rte_flow_item_phy_port, index)), }, + [ITEM_PORT_ID] = { + .name = "port_id", + .help = "match traffic from/to a given DPDK port ID", + .priv = PRIV_ITEM(PORT_ID, + sizeof(struct rte_flow_item_port_id)), + .next = NEXT(item_port_id), + .call = parse_vc, + }, + [ITEM_PORT_ID_ID] = { + .name = "id", + .help = "DPDK port ID", + .next = NEXT(item_port_id, NEXT_ENTRY(UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_port_id, id)), + }, [ITEM_RAW] = { .name = "raw", .help = "match an arbitrary byte string", @@ -1749,6 +1783,29 @@ static const struct token token_list[] = { index)), .call = parse_vc_conf, }, + [ACTION_PORT_ID] = { + .name = "port_id", + .help = "direct matching traffic to a given DPDK port ID", + .priv = PRIV_ACTION(PORT_ID, + sizeof(struct rte_flow_action_port_id)), + .next = NEXT(action_port_id), + .call = parse_vc, + }, + [ACTION_PORT_ID_ORIGINAL] = { + .name = "original", + .help = "use original DPDK port ID if possible", + .next = NEXT(action_port_id, NEXT_ENTRY(BOOLEAN)), + .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_port_id, + original, 1)), + .call = parse_vc_conf, + }, + [ACTION_PORT_ID_ID] = { + .name = "id", + .help = "DPDK port ID", + .next = NEXT(action_port_id, NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_port_id, id)), + .call = parse_vc_conf, + }, [ACTION_METER] = { .name = "meter", .help = "meter the directed packets at given id", diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index effb4ff81..4a273eff7 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -961,6 +961,7 @@ static const struct { MK_FLOW_ITEM(PF, 0), MK_FLOW_ITEM(VF, sizeof(struct rte_flow_item_vf)), MK_FLOW_ITEM(PHY_PORT, sizeof(struct rte_flow_item_phy_port)), + MK_FLOW_ITEM(PORT_ID, sizeof(struct rte_flow_item_port_id)), MK_FLOW_ITEM(RAW, sizeof(struct rte_flow_item_raw)), MK_FLOW_ITEM(ETH, sizeof(struct rte_flow_item_eth)), MK_FLOW_ITEM(VLAN, sizeof(struct rte_flow_item_vlan)), @@ -1059,6 +1060,7 @@ static const struct { MK_FLOW_ACTION(PF, 0), MK_FLOW_ACTION(VF, sizeof(struct rte_flow_action_vf)), MK_FLOW_ACTION(PHY_PORT, sizeof(struct rte_flow_action_phy_port)), + MK_FLOW_ACTION(PORT_ID, sizeof(struct rte_flow_action_port_id)), MK_FLOW_ACTION(METER, sizeof(struct rte_flow_action_meter)), }; diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index ec59d0f3c..91dbd61a0 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -607,6 +607,36 @@ associated with a port_id should be retrieved by other means. | ``mask`` | ``index`` | zeroed to match any port index | +----------+-----------+--------------------------------+ +Item: ``PORT_ID`` +^^^^^^^^^^^^^^^^^ + +Matches traffic originating from (ingress) or going to (egress) a given DPDK +port ID. + +Normally only supported if the port ID in question is known by the +underlying PMD and related to the device the flow rule is created against. + +This must not be confused with `Item: PHY_PORT`_ which refers to the +physical port of a device, whereas `Item: PORT_ID`_ refers to a ``struct +rte_eth_dev`` object on the application side (also known as "port +representor" depending on the kind of underlying device). + +- Default ``mask`` matches the specified DPDK port ID. + +.. _table_rte_flow_item_port_id: + +.. table:: PORT_ID + + +----------+----------+-----------------------------+ + | Field | Subfield | Value | + +==========+==========+=============================+ + | ``spec`` | ``id`` | DPDK port ID | + +----------+----------+-----------------------------+ + | ``last`` | ``id`` | upper range value | + +----------+----------+-----------------------------+ + | ``mask`` | ``id`` | zeroed to match any port ID | + +----------+----------+-----------------------------+ + Data matching item types ~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1437,6 +1467,24 @@ See `Item: PHY_PORT`_. | ``index`` | physical port index | +--------------+-------------------------------------+ +Action: ``PORT_ID`` +^^^^^^^^^^^^^^^^^^^ +Directs matching traffic to a given DPDK port ID. + +See `Item: PORT_ID`_. + +.. _table_rte_flow_action_port_id: + +.. table:: PORT_ID + + +--------------+---------------------------------------+ + | Field | Value | + +==============+=======================================+ + | ``original`` | use original DPDK port ID if possible | + +--------------+---------------------------------------+ + | ``id`` | DPDK port ID | + +--------------+---------------------------------------+ + Action: ``METER`` ^^^^^^^^^^^^^^^^^ diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index ca23ba146..e78f26dce 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3212,6 +3212,10 @@ This section lists supported pattern items and their attributes, if any. - ``index {unsigned}``: physical port index. +- ``port_id``: match traffic from/to a given DPDK port ID. + + - ``id {unsigned}``: DPDK port ID. + - ``raw``: match an arbitrary byte string. - ``relative {boolean}``: look for pattern after the previous item. @@ -3426,6 +3430,11 @@ This section lists supported actions and their attributes, if any. - ``original {boolean}``: use original port index if possible. - ``index {unsigned}``: physical port index. +- ``port_id``: direct matching traffic to a given DPDK port ID. + + - ``original {boolean}``: use original DPDK port ID if possible. + - ``id {unsigned}``: DPDK port ID. + Destroying flow rules ~~~~~~~~~~~~~~~~~~~~~ diff --git a/lib/librte_ether/rte_flow.c b/lib/librte_ether/rte_flow.c index e0fd78dd5..3d8116ebd 100644 --- a/lib/librte_ether/rte_flow.c +++ b/lib/librte_ether/rte_flow.c @@ -39,6 +39,7 @@ static const struct rte_flow_desc_data rte_flow_desc_item[] = { MK_FLOW_ITEM(PF, 0), MK_FLOW_ITEM(VF, sizeof(struct rte_flow_item_vf)), MK_FLOW_ITEM(PHY_PORT, sizeof(struct rte_flow_item_phy_port)), + MK_FLOW_ITEM(PORT_ID, sizeof(struct rte_flow_item_port_id)), MK_FLOW_ITEM(RAW, sizeof(struct rte_flow_item_raw)), MK_FLOW_ITEM(ETH, sizeof(struct rte_flow_item_eth)), MK_FLOW_ITEM(VLAN, sizeof(struct rte_flow_item_vlan)), @@ -77,6 +78,7 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = { MK_FLOW_ACTION(PF, 0), MK_FLOW_ACTION(VF, sizeof(struct rte_flow_action_vf)), MK_FLOW_ACTION(PHY_PORT, sizeof(struct rte_flow_action_phy_port)), + MK_FLOW_ACTION(PORT_ID, sizeof(struct rte_flow_action_port_id)), }; static int diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index 68a13ffa9..bed727df8 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -176,6 +176,16 @@ enum rte_flow_item_type { RTE_FLOW_ITEM_TYPE_PHY_PORT, /** + * [META] + * + * Matches traffic originating from (ingress) or going to (egress) a + * given DPDK port ID. + * + * See struct rte_flow_item_port_id. + */ + RTE_FLOW_ITEM_TYPE_PORT_ID, + + /** * Matches a byte string of a given length at a given offset. * * See struct rte_flow_item_raw. @@ -410,6 +420,32 @@ static const struct rte_flow_item_phy_port rte_flow_item_phy_port_mask = { #endif /** + * RTE_FLOW_ITEM_TYPE_PORT_ID + * + * Matches traffic originating from (ingress) or going to (egress) a given + * DPDK port ID. + * + * Normally only supported if the port ID in question is known by the + * underlying PMD and related to the device the flow rule is created + * against. + * + * This must not be confused with @p PHY_PORT which refers to the physical + * port of a device, whereas @p PORT_ID refers to a struct rte_eth_dev + * object on the application side (also known as "port representor" + * depending on the kind of underlying device). + */ +struct rte_flow_item_port_id { + uint32_t id; /**< DPDK port ID. */ +}; + +/** Default mask for RTE_FLOW_ITEM_TYPE_PORT_ID. */ +#ifndef __cplusplus +static const struct rte_flow_item_port_id rte_flow_item_port_id_mask = { + .id = 0xffffffff, +}; +#endif + +/** * RTE_FLOW_ITEM_TYPE_RAW * * Matches a byte string of a given length at a given offset. @@ -993,6 +1029,13 @@ enum rte_flow_action_type { RTE_FLOW_ACTION_TYPE_PHY_PORT, /** + * Directs matching traffic to a given DPDK port ID. + * + * See struct rte_flow_action_port_id. + */ + RTE_FLOW_ACTION_TYPE_PORT_ID, + + /** * Traffic metering and policing (MTR). * * See struct rte_flow_action_meter. @@ -1124,6 +1167,19 @@ struct rte_flow_action_phy_port { }; /** + * RTE_FLOW_ACTION_TYPE_PORT_ID + * + * Directs matching traffic to a given DPDK port ID. + * + * @see RTE_FLOW_ITEM_TYPE_PORT_ID + */ +struct rte_flow_action_port_id { + uint32_t original:1; /**< Use original DPDK port ID if possible. */ + uint32_t reserved:31; /**< Reserved, must be zero. */ + uint32_t id; /**< DPDK port ID. */ +}; + +/** * RTE_FLOW_ACTION_TYPE_METER * * Traffic metering and policing (MTR). -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v3 00/16] Flow API overhaul for switch offloads 2018-04-06 13:25 ` [dpdk-dev] [PATCH v2 00/15] Flow API overhaul for switch offloads Adrien Mazarguil ` (14 preceding siblings ...) 2018-04-06 13:25 ` [dpdk-dev] [PATCH v2 15/15] ethdev: add port ID item and " Adrien Mazarguil @ 2018-04-10 16:36 ` Adrien Mazarguil 2018-04-10 16:36 ` [dpdk-dev] [PATCH v3 01/16] ethdev: add error types to flow API Adrien Mazarguil ` (16 more replies) 15 siblings, 17 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-10 16:36 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev As summarized in a prior RFC [1], the flow API (rte_flow) was chosen as a means to manage switch offloads supported by many devices (usually going by names such as E-Switch or vSwitch) through user-specified flow rules. Combined with the need to support encap/decap actions, this requires a change in the way flow actions are processed (in order and possibly repeated) which modifies the behavior of some of the existing actions, thus warranting a major ABI breakage. Given this ABI breakage is also required by other work submitted for the current release [2][3], this series addresses various longstanding issues with the flow API and makes minor improvements in preparation for upcoming features. Changes summary: - Additional error types. - Clearer documentation. - Improved C++ compatibility. - Exhaustive RSS action. - Consistent behavior of VLAN pattern item. - New "transfer" attribute bringing consistency to VF/PF pattern items. - Confusing "PORT" pattern item renamed "PHY_PORT", with new action counterpart. - New "PORT_ID" pattern item and action to be used with port representors. This series piggybacks on the major ABI update introduced by a prior commit [4] for DPDK 18.05 and depends on several fixes [5] which must be applied first. [1] "[RFC] Switch device offload with DPDK" http://dpdk.org/ml/archives/dev/2018-March/092513.html [2] commit 676b605182a5 ("doc: announce ethdev API change for RSS configuration") [3] "[PATCH v1 00/21] MLX5 tunnel Rx offloading" http://dpdk.org/ml/archives/dev/2018-March/092264.html [4] commit 653e038efc9b ("ethdev: remove versioning of filter control function") [5] "[PATCH v4 00/11] Bunch of flow API-related fixes" http://dpdk.org/ml/archives/dev/2018-April/096509.html v3 changes: - Rebased series, fixed latest conflicts. - Addressed Andrew's comments, see affected patches for details: - Empty RSS types in flow rule means PMD-specific RSS instead of no RSS. - RSS hash function now explicitly compared against RTE_ETH_HASH_FUNCTION_DEFAULT instead of 0 in all PMDs. - sfc PMD updated to also accept Toeplitz. - Implicit VLAN TPID matching now removed from all PMDs. - Default mask upate for VLAN TCI now split as separate patch #11. - Ingress/egress definition clarified in patch #12. v2 changes: - Squashed "ethdev: update ABI for flow API functions" in subsequent patches. - Emphasized ABI impact in relevant commit logs. - Modified documentation in "ethdev: alter behavior of flow API actions" to describe how terminating flow rules without any action of the fate kind result in undefined behavior instead of dropping traffic. - Fixed other minor documentation formatting issues. - Modified "ethdev: refine TPID handling in flow API" as follows: - Using standard macro definitions for VLAN, QinQ and E-Tag EtherTypes. - Fixed endian conversion in sfc. - Replaced a condition in VLAN pattern item processing with an assertion check for i40e. Adrien Mazarguil (16): ethdev: add error types to flow API ethdev: clarify flow API pattern items and actions doc: remove flow API migration section ethdev: remove DUP action from flow API ethdev: alter behavior of flow API actions ethdev: remove C99 flexible arrays from flow API ethdev: flatten RSS configuration in flow API ethdev: add hash function to RSS flow API action ethdev: add encap level to RSS flow API action ethdev: refine TPID handling in flow API ethdev: limit default VLAN TCI mask in flow API ethdev: add transfer attribute to flow API ethdev: update behavior of VF/PF in flow API ethdev: rename physical port item in flow API ethdev: add physical port action to flow API ethdev: add port ID item and action to flow API app/test-pmd/cmdline_flow.c | 394 +++++++++++---- app/test-pmd/config.c | 78 +-- doc/guides/nics/tap.rst | 2 +- doc/guides/prog_guide/rte_flow.rst | 618 ++++++++--------------- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 60 ++- drivers/net/bnxt/bnxt_filter.c | 49 +- drivers/net/e1000/e1000_ethdev.h | 13 +- drivers/net/e1000/igb_ethdev.c | 4 +- drivers/net/e1000/igb_flow.c | 83 ++- drivers/net/e1000/igb_rxtx.c | 55 +- drivers/net/enic/enic_flow.c | 50 +- drivers/net/i40e/i40e_ethdev.c | 57 ++- drivers/net/i40e/i40e_ethdev.h | 15 +- drivers/net/i40e/i40e_flow.c | 140 +++-- drivers/net/ixgbe/ixgbe_ethdev.c | 7 +- drivers/net/ixgbe/ixgbe_ethdev.h | 13 +- drivers/net/ixgbe/ixgbe_flow.c | 91 +++- drivers/net/ixgbe/ixgbe_rxtx.c | 55 +- drivers/net/mlx4/mlx4.c | 2 +- drivers/net/mlx4/mlx4_flow.c | 117 +++-- drivers/net/mlx4/mlx4_flow.h | 2 +- drivers/net/mlx4/mlx4_rxq.c | 2 +- drivers/net/mlx4/mlx4_rxtx.h | 2 +- drivers/net/mlx5/mlx5_flow.c | 316 ++++++------ drivers/net/mlx5/mlx5_rxq.c | 22 +- drivers/net/mlx5/mlx5_rxtx.h | 26 +- drivers/net/mvpp2/mrvl_flow.c | 32 +- drivers/net/sfc/sfc_flow.c | 78 ++- drivers/net/tap/tap_flow.c | 49 +- examples/ipsec-secgw/ipsec.c | 21 +- lib/librte_ether/rte_ethdev_version.map | 22 +- lib/librte_ether/rte_flow.c | 68 +-- lib/librte_ether/rte_flow.h | 339 ++++++++----- lib/librte_net/rte_ether.h | 1 + 34 files changed, 1756 insertions(+), 1127 deletions(-) -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v3 01/16] ethdev: add error types to flow API 2018-04-10 16:36 ` [dpdk-dev] [PATCH v3 00/16] Flow API overhaul for switch offloads Adrien Mazarguil @ 2018-04-10 16:36 ` Adrien Mazarguil 2018-04-10 16:36 ` [dpdk-dev] [PATCH v3 02/16] ethdev: clarify flow API pattern items and actions Adrien Mazarguil ` (15 subsequent siblings) 16 siblings, 0 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-10 16:36 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev These enable more precise reporting of objects responsible for errors. This breaks ABI compatibility for the following public functions: - rte_flow_create() - rte_flow_destroy() - rte_flow_error_set() - rte_flow_flush() - rte_flow_isolate() - rte_flow_query() - rte_flow_validate() Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Acked-by: Andrew Rybchenko <arybchenko@solarflare.com> --- app/test-pmd/config.c | 4 ++++ lib/librte_ether/rte_ethdev_version.map | 20 +++++++++++++------- lib/librte_ether/rte_flow.h | 4 ++++ 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 2058e6ec8..7ae0295f6 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -1228,8 +1228,12 @@ port_flow_complain(struct rte_flow_error *error) [RTE_FLOW_ERROR_TYPE_ATTR_EGRESS] = "egress field", [RTE_FLOW_ERROR_TYPE_ATTR] = "attributes structure", [RTE_FLOW_ERROR_TYPE_ITEM_NUM] = "pattern length", + [RTE_FLOW_ERROR_TYPE_ITEM_SPEC] = "item specification", + [RTE_FLOW_ERROR_TYPE_ITEM_LAST] = "item specification range", + [RTE_FLOW_ERROR_TYPE_ITEM_MASK] = "item specification mask", [RTE_FLOW_ERROR_TYPE_ITEM] = "specific pattern item", [RTE_FLOW_ERROR_TYPE_ACTION_NUM] = "number of actions", + [RTE_FLOW_ERROR_TYPE_ACTION_CONF] = "action configuration", [RTE_FLOW_ERROR_TYPE_ACTION] = "specific action", }; const char *errstr; diff --git a/lib/librte_ether/rte_ethdev_version.map b/lib/librte_ether/rte_ethdev_version.map index 34df6c8b5..e915e7929 100644 --- a/lib/librte_ether/rte_ethdev_version.map +++ b/lib/librte_ether/rte_ethdev_version.map @@ -127,11 +127,6 @@ DPDK_17.02 { _rte_eth_dev_reset; rte_eth_dev_fw_version_get; - rte_flow_create; - rte_flow_destroy; - rte_flow_flush; - rte_flow_query; - rte_flow_validate; } DPDK_16.07; @@ -153,7 +148,6 @@ DPDK_17.08 { _rte_eth_dev_callback_process; rte_eth_dev_adjust_nb_rx_tx_desc; rte_flow_copy; - rte_flow_isolate; rte_tm_capabilities_get; rte_tm_hierarchy_commit; rte_tm_level_capabilities_get; @@ -192,7 +186,6 @@ DPDK_17.11 { rte_eth_dev_get_sec_ctx; rte_eth_dev_pool_ops_supported; rte_eth_dev_reset; - rte_flow_error_set; } DPDK_17.08; @@ -203,6 +196,19 @@ DPDK_18.02 { } DPDK_17.11; +DPDK_18.05 { + global: + + rte_flow_create; + rte_flow_destroy; + rte_flow_error_set; + rte_flow_flush; + rte_flow_isolate; + rte_flow_query; + rte_flow_validate; + +} DPDK_18.02; + EXPERIMENTAL { global: diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index cdaaa3a5b..95799fd9c 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -1186,8 +1186,12 @@ enum rte_flow_error_type { RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, /**< Egress field. */ RTE_FLOW_ERROR_TYPE_ATTR, /**< Attributes structure. */ RTE_FLOW_ERROR_TYPE_ITEM_NUM, /**< Pattern length. */ + RTE_FLOW_ERROR_TYPE_ITEM_SPEC, /**< Item specification. */ + RTE_FLOW_ERROR_TYPE_ITEM_LAST, /**< Item specification range. */ + RTE_FLOW_ERROR_TYPE_ITEM_MASK, /**< Item specification mask. */ RTE_FLOW_ERROR_TYPE_ITEM, /**< Specific pattern item. */ RTE_FLOW_ERROR_TYPE_ACTION_NUM, /**< Number of actions. */ + RTE_FLOW_ERROR_TYPE_ACTION_CONF, /**< Action configuration. */ RTE_FLOW_ERROR_TYPE_ACTION, /**< Specific action. */ }; -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v3 02/16] ethdev: clarify flow API pattern items and actions 2018-04-10 16:36 ` [dpdk-dev] [PATCH v3 00/16] Flow API overhaul for switch offloads Adrien Mazarguil 2018-04-10 16:36 ` [dpdk-dev] [PATCH v3 01/16] ethdev: add error types to flow API Adrien Mazarguil @ 2018-04-10 16:36 ` Adrien Mazarguil 2018-04-10 16:36 ` [dpdk-dev] [PATCH v3 03/16] doc: remove flow API migration section Adrien Mazarguil ` (14 subsequent siblings) 16 siblings, 0 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-10 16:36 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev Although pattern items and actions examples end with "and so on", these lists include all existing definitions and as a result are updated almost every time new types are added. This is cumbersome and pointless. This patch also synchronizes Doxygen and external API documentation wording with a slight clarification regarding meta pattern items. No fundamental API change. Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Acked-by: Andrew Rybchenko <arybchenko@solarflare.com> --- doc/guides/prog_guide/rte_flow.rst | 23 +++++++++++------------ lib/librte_ether/rte_flow.h | 23 ++++++++++------------- 2 files changed, 21 insertions(+), 25 deletions(-) diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 961943dda..a11ebd617 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -186,12 +186,13 @@ Pattern item Pattern items fall in two categories: -- Matching protocol headers and packet data (ANY, RAW, ETH, VLAN, IPV4, - IPV6, ICMP, UDP, TCP, SCTP, VXLAN, MPLS, GRE, ESP and so on), usually - associated with a specification structure. +- Matching protocol headers and packet data, usually associated with a + specification structure. These must be stacked in the same order as the + protocol layers to match inside packets, starting from the lowest. -- Matching meta-data or affecting pattern processing (END, VOID, INVERT, PF, - VF, PORT and so on), often without a specification structure. +- Matching meta-data or affecting pattern processing, often without a + specification structure. Since they do not match packet contents, their + position in the list is usually not relevant. Item specification structures are used to match specific values among protocol fields (or item properties). Documentation describes for each item @@ -1001,15 +1002,13 @@ to a flow rule. That list is not ordered. They fall in three categories: -- Terminating actions (such as QUEUE, DROP, RSS, PF, VF) that prevent - processing matched packets by subsequent flow rules, unless overridden - with PASSTHRU. +- Terminating actions that prevent processing matched packets by subsequent + flow rules, unless overridden with PASSTHRU. -- Non-terminating actions (PASSTHRU, DUP) that leave matched packets up for - additional processing by subsequent flow rules. +- Non-terminating actions that leave matched packets up for additional + processing by subsequent flow rules. -- Other non-terminating meta actions that do not affect the fate of packets - (END, VOID, MARK, FLAG, COUNT, SECURITY). +- Other non-terminating meta actions that do not affect the fate of packets. When several actions are combined in a flow rule, they should all have different types (e.g. dropping a packet twice is not possible). diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index 95799fd9c..36fd38ffa 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -78,15 +78,13 @@ struct rte_flow_attr { * * Pattern items fall in two categories: * - * - Matching protocol headers and packet data (ANY, RAW, ETH, VLAN, IPV4, - * IPV6, ICMP, UDP, TCP, SCTP, VXLAN and so on), usually associated with a + * - Matching protocol headers and packet data, usually associated with a * specification structure. These must be stacked in the same order as the - * protocol layers to match, starting from the lowest. + * protocol layers to match inside packets, starting from the lowest. * - * - Matching meta-data or affecting pattern processing (END, VOID, INVERT, - * PF, VF, PORT and so on), often without a specification structure. Since - * they do not match packet contents, these can be specified anywhere - * within item lists without affecting others. + * - Matching meta-data or affecting pattern processing, often without a + * specification structure. Since they do not match packet contents, their + * position in the list is usually not relevant. * * See the description of individual types for more information. Those * marked with [META] fall into the second category. @@ -865,15 +863,14 @@ struct rte_flow_item { * * They fall in three categories: * - * - Terminating actions (such as QUEUE, DROP, RSS, PF, VF) that prevent - * processing matched packets by subsequent flow rules, unless overridden - * with PASSTHRU. + * - Terminating actions that prevent processing matched packets by + * subsequent flow rules, unless overridden with PASSTHRU. * - * - Non terminating actions (PASSTHRU, DUP) that leave matched packets up - * for additional processing by subsequent flow rules. + * - Non terminating actions that leave matched packets up for additional + * processing by subsequent flow rules. * * - Other non terminating meta actions that do not affect the fate of - * packets (END, VOID, MARK, FLAG, COUNT). + * packets. * * When several actions are combined in a flow rule, they should all have * different types (e.g. dropping a packet twice is not possible). -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v3 03/16] doc: remove flow API migration section 2018-04-10 16:36 ` [dpdk-dev] [PATCH v3 00/16] Flow API overhaul for switch offloads Adrien Mazarguil 2018-04-10 16:36 ` [dpdk-dev] [PATCH v3 01/16] ethdev: add error types to flow API Adrien Mazarguil 2018-04-10 16:36 ` [dpdk-dev] [PATCH v3 02/16] ethdev: clarify flow API pattern items and actions Adrien Mazarguil @ 2018-04-10 16:36 ` Adrien Mazarguil 2018-04-10 16:36 ` [dpdk-dev] [PATCH v3 04/16] ethdev: remove DUP action from flow API Adrien Mazarguil ` (13 subsequent siblings) 16 siblings, 0 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-10 16:36 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev This section has become less relevant since the flow API (rte_flow) is now a mature DPDK API with applications developed directly on top of it instead of an afterthought. This patch removes it for the following reasons: - It has never been updated to track the latest changes in the legacy filter types and never will. - Many provided examples are theoretical and misleading since PMDs do not implement them. Others are obvious. - Upcoming work on the flow API will alter the behavior of several pattern items, actions and in some cases, flow rules, which will in turn cause existing examples to be wrong. Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Acked-by: Andrew Rybchenko <arybchenko@solarflare.com> --- doc/guides/prog_guide/rte_flow.rst | 298 -------------------------------- 1 file changed, 298 deletions(-) diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index a11ebd617..51826d04c 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -55,9 +55,6 @@ encompasses and supersedes (including all functions and filter types) in order to expose a single interface with an unambiguous behavior that is common to all poll-mode drivers (PMDs). -Several methods to migrate existing applications are described in `API -migration`_. - Flow rule --------- @@ -2068,298 +2065,3 @@ Future evolutions - Optional software fallback when PMDs are unable to handle requested flow rules so applications do not have to implement their own. - -API migration -------------- - -Exhaustive list of deprecated filter types (normally prefixed with -*RTE_ETH_FILTER_*) found in ``rte_eth_ctrl.h`` and methods to convert them -to *rte_flow* rules. - -``MACVLAN`` to ``ETH`` → ``VF``, ``PF`` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -*MACVLAN* can be translated to a basic `Item: ETH`_ flow rule with a -terminating `Action: VF`_ or `Action: PF`_. - -.. _table_rte_flow_migration_macvlan: - -.. table:: MACVLAN conversion - - +--------------------------+---------+ - | Pattern | Actions | - +===+=====+==========+=====+=========+ - | 0 | ETH | ``spec`` | any | VF, | - | | +----------+-----+ PF | - | | | ``last`` | N/A | | - | | +----------+-----+ | - | | | ``mask`` | any | | - +---+-----+----------+-----+---------+ - | 1 | END | END | - +---+----------------------+---------+ - -``ETHERTYPE`` to ``ETH`` → ``QUEUE``, ``DROP`` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -*ETHERTYPE* is basically an `Item: ETH`_ flow rule with a terminating -`Action: QUEUE`_ or `Action: DROP`_. - -.. _table_rte_flow_migration_ethertype: - -.. table:: ETHERTYPE conversion - - +--------------------------+---------+ - | Pattern | Actions | - +===+=====+==========+=====+=========+ - | 0 | ETH | ``spec`` | any | QUEUE, | - | | +----------+-----+ DROP | - | | | ``last`` | N/A | | - | | +----------+-----+ | - | | | ``mask`` | any | | - +---+-----+----------+-----+---------+ - | 1 | END | END | - +---+----------------------+---------+ - -``FLEXIBLE`` to ``RAW`` → ``QUEUE`` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -*FLEXIBLE* can be translated to one `Item: RAW`_ pattern with a terminating -`Action: QUEUE`_ and a defined priority level. - -.. _table_rte_flow_migration_flexible: - -.. table:: FLEXIBLE conversion - - +--------------------------+---------+ - | Pattern | Actions | - +===+=====+==========+=====+=========+ - | 0 | RAW | ``spec`` | any | QUEUE | - | | +----------+-----+ | - | | | ``last`` | N/A | | - | | +----------+-----+ | - | | | ``mask`` | any | | - +---+-----+----------+-----+---------+ - | 1 | END | END | - +---+----------------------+---------+ - -``SYN`` to ``TCP`` → ``QUEUE`` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -*SYN* is a `Item: TCP`_ rule with only the ``syn`` bit enabled and masked, -and a terminating `Action: QUEUE`_. - -Priority level can be set to simulate the high priority bit. - -.. _table_rte_flow_migration_syn: - -.. table:: SYN conversion - - +-----------------------------------+---------+ - | Pattern | Actions | - +===+======+==========+=============+=========+ - | 0 | ETH | ``spec`` | unset | QUEUE | - | | +----------+-------------+ | - | | | ``last`` | unset | | - | | +----------+-------------+ | - | | | ``mask`` | unset | | - +---+------+----------+-------------+---------+ - | 1 | IPV4 | ``spec`` | unset | END | - | | +----------+-------------+ | - | | | ``mask`` | unset | | - | | +----------+-------------+ | - | | | ``mask`` | unset | | - +---+------+----------+---------+---+ | - | 2 | TCP | ``spec`` | ``syn`` | 1 | | - | | +----------+---------+---+ | - | | | ``mask`` | ``syn`` | 1 | | - +---+------+----------+---------+---+ | - | 3 | END | | - +---+-------------------------------+---------+ - -``NTUPLE`` to ``IPV4``, ``TCP``, ``UDP`` → ``QUEUE`` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -*NTUPLE* is similar to specifying an empty L2, `Item: IPV4`_ as L3 with -`Item: TCP`_ or `Item: UDP`_ as L4 and a terminating `Action: QUEUE`_. - -A priority level can be specified as well. - -.. _table_rte_flow_migration_ntuple: - -.. table:: NTUPLE conversion - - +-----------------------------+---------+ - | Pattern | Actions | - +===+======+==========+=======+=========+ - | 0 | ETH | ``spec`` | unset | QUEUE | - | | +----------+-------+ | - | | | ``last`` | unset | | - | | +----------+-------+ | - | | | ``mask`` | unset | | - +---+------+----------+-------+---------+ - | 1 | IPV4 | ``spec`` | any | END | - | | +----------+-------+ | - | | | ``last`` | unset | | - | | +----------+-------+ | - | | | ``mask`` | any | | - +---+------+----------+-------+ | - | 2 | TCP, | ``spec`` | any | | - | | UDP +----------+-------+ | - | | | ``last`` | unset | | - | | +----------+-------+ | - | | | ``mask`` | any | | - +---+------+----------+-------+ | - | 3 | END | | - +---+-------------------------+---------+ - -``TUNNEL`` to ``ETH``, ``IPV4``, ``IPV6``, ``VXLAN`` (or other) → ``QUEUE`` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -*TUNNEL* matches common IPv4 and IPv6 L3/L4-based tunnel types. - -In the following table, `Item: ANY`_ is used to cover the optional L4. - -.. _table_rte_flow_migration_tunnel: - -.. table:: TUNNEL conversion - - +-------------------------------------------------------+---------+ - | Pattern | Actions | - +===+==========================+==========+=============+=========+ - | 0 | ETH | ``spec`` | any | QUEUE | - | | +----------+-------------+ | - | | | ``last`` | unset | | - | | +----------+-------------+ | - | | | ``mask`` | any | | - +---+--------------------------+----------+-------------+---------+ - | 1 | IPV4, IPV6 | ``spec`` | any | END | - | | +----------+-------------+ | - | | | ``last`` | unset | | - | | +----------+-------------+ | - | | | ``mask`` | any | | - +---+--------------------------+----------+-------------+ | - | 2 | ANY | ``spec`` | any | | - | | +----------+-------------+ | - | | | ``last`` | unset | | - | | +----------+---------+---+ | - | | | ``mask`` | ``num`` | 0 | | - +---+--------------------------+----------+---------+---+ | - | 3 | VXLAN, GENEVE, TEREDO, | ``spec`` | any | | - | | NVGRE, GRE, ... +----------+-------------+ | - | | | ``last`` | unset | | - | | +----------+-------------+ | - | | | ``mask`` | any | | - +---+--------------------------+----------+-------------+ | - | 4 | END | | - +---+---------------------------------------------------+---------+ - -``FDIR`` to most item types → ``QUEUE``, ``DROP``, ``PASSTHRU`` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -*FDIR* is more complex than any other type, there are several methods to -emulate its functionality. It is summarized for the most part in the table -below. - -A few features are intentionally not supported: - -- The ability to configure the matching input set and masks for the entire - device, PMDs should take care of it automatically according to the - requested flow rules. - - For example if a device supports only one bit-mask per protocol type, - source/address IPv4 bit-masks can be made immutable by the first created - rule. Subsequent IPv4 or TCPv4 rules can only be created if they are - compatible. - - Note that only protocol bit-masks affected by existing flow rules are - immutable, others can be changed later. They become mutable again after - the related flow rules are destroyed. - -- Returning four or eight bytes of matched data when using flex bytes - filtering. Although a specific action could implement it, it conflicts - with the much more useful 32 bits tagging on devices that support it. - -- Side effects on RSS processing of the entire device. Flow rules that - conflict with the current device configuration should not be - allowed. Similarly, device configuration should not be allowed when it - affects existing flow rules. - -- Device modes of operation. "none" is unsupported since filtering cannot be - disabled as long as a flow rule is present. - -- "MAC VLAN" or "tunnel" perfect matching modes should be automatically set - according to the created flow rules. - -- Signature mode of operation is not defined but could be handled through - "FUZZY" item. - -.. _table_rte_flow_migration_fdir: - -.. table:: FDIR conversion - - +----------------------------------------+-----------------------+ - | Pattern | Actions | - +===+===================+==========+=====+=======================+ - | 0 | ETH, RAW | ``spec`` | any | QUEUE, DROP, PASSTHRU | - | | +----------+-----+ | - | | | ``last`` | N/A | | - | | +----------+-----+ | - | | | ``mask`` | any | | - +---+-------------------+----------+-----+-----------------------+ - | 1 | IPV4, IPv6 | ``spec`` | any | MARK | - | | +----------+-----+ | - | | | ``last`` | N/A | | - | | +----------+-----+ | - | | | ``mask`` | any | | - +---+-------------------+----------+-----+-----------------------+ - | 2 | TCP, UDP, SCTP | ``spec`` | any | END | - | | +----------+-----+ | - | | | ``last`` | N/A | | - | | +----------+-----+ | - | | | ``mask`` | any | | - +---+-------------------+----------+-----+ | - | 3 | VF, PF, FUZZY | ``spec`` | any | | - | | (optional) +----------+-----+ | - | | | ``last`` | N/A | | - | | +----------+-----+ | - | | | ``mask`` | any | | - +---+-------------------+----------+-----+ | - | 4 | END | | - +---+------------------------------------+-----------------------+ - -``HASH`` -~~~~~~~~ - -There is no counterpart to this filter type because it translates to a -global device setting instead of a pattern item. Device settings are -automatically set according to the created flow rules. - -``L2_TUNNEL`` to ``VOID`` → ``VXLAN`` (or others) -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -All packets are matched. This type alters incoming packets to encapsulate -them in a chosen tunnel type, optionally redirect them to a VF as well. - -The destination pool for tag based forwarding can be emulated with other -flow rules using `Action: DUP`_. - -.. _table_rte_flow_migration_l2tunnel: - -.. table:: L2_TUNNEL conversion - - +---------------------------+--------------------+ - | Pattern | Actions | - +===+======+==========+=====+====================+ - | 0 | VOID | ``spec`` | N/A | VXLAN, GENEVE, ... | - | | | | | | - | | | | | | - | | +----------+-----+ | - | | | ``last`` | N/A | | - | | +----------+-----+ | - | | | ``mask`` | N/A | | - | | | | | | - +---+------+----------+-----+--------------------+ - | 1 | END | VF (optional) | - +---+ +--------------------+ - | 2 | | END | - +---+-----------------------+--------------------+ -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v3 04/16] ethdev: remove DUP action from flow API 2018-04-10 16:36 ` [dpdk-dev] [PATCH v3 00/16] Flow API overhaul for switch offloads Adrien Mazarguil ` (2 preceding siblings ...) 2018-04-10 16:36 ` [dpdk-dev] [PATCH v3 03/16] doc: remove flow API migration section Adrien Mazarguil @ 2018-04-10 16:36 ` Adrien Mazarguil 2018-04-10 16:36 ` [dpdk-dev] [PATCH v3 05/16] ethdev: alter behavior of flow API actions Adrien Mazarguil ` (12 subsequent siblings) 16 siblings, 0 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-10 16:36 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev Upcoming changes in relation to the handling of actions list will make the DUP action redundant as specifying several QUEUE actions will achieve the same behavior. Besides, no PMD implements this action. By removing an entry from enum rte_flow_action_type, this patch breaks ABI compatibility for the following public functions: - rte_flow_copy() - rte_flow_create() - rte_flow_query() - rte_flow_validate() Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Acked-by: Andrew Rybchenko <arybchenko@solarflare.com> --- app/test-pmd/cmdline_flow.c | 23 ----------------------- app/test-pmd/config.c | 1 - doc/guides/prog_guide/rte_flow.rst | 23 ----------------------- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 8 -------- lib/librte_ether/rte_ethdev_version.map | 2 +- lib/librte_ether/rte_flow.c | 1 - lib/librte_ether/rte_flow.h | 24 ------------------------ 7 files changed, 1 insertion(+), 81 deletions(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index ac4b51a8a..be867b0ec 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -164,8 +164,6 @@ enum index { ACTION_QUEUE_INDEX, ACTION_DROP, ACTION_COUNT, - ACTION_DUP, - ACTION_DUP_INDEX, ACTION_RSS, ACTION_RSS_TYPES, ACTION_RSS_TYPE, @@ -625,7 +623,6 @@ static const enum index next_action[] = { ACTION_QUEUE, ACTION_DROP, ACTION_COUNT, - ACTION_DUP, ACTION_RSS, ACTION_PF, ACTION_VF, @@ -645,12 +642,6 @@ static const enum index action_queue[] = { ZERO, }; -static const enum index action_dup[] = { - ACTION_DUP_INDEX, - ACTION_NEXT, - ZERO, -}; - static const enum index action_rss[] = { ACTION_RSS_TYPES, ACTION_RSS_KEY, @@ -1597,20 +1588,6 @@ static const struct token token_list[] = { .next = NEXT(NEXT_ENTRY(ACTION_NEXT)), .call = parse_vc, }, - [ACTION_DUP] = { - .name = "dup", - .help = "duplicate packets to a given queue index", - .priv = PRIV_ACTION(DUP, sizeof(struct rte_flow_action_dup)), - .next = NEXT(action_dup), - .call = parse_vc, - }, - [ACTION_DUP_INDEX] = { - .name = "index", - .help = "queue index to duplicate packets to", - .next = NEXT(action_dup, NEXT_ENTRY(UNSIGNED)), - .args = ARGS(ARGS_ENTRY(struct rte_flow_action_dup, index)), - .call = parse_vc_conf, - }, [ACTION_RSS] = { .name = "rss", .help = "spread packets among several queues", diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 7ae0295f6..8d42ea9a9 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -1049,7 +1049,6 @@ static const struct { MK_FLOW_ACTION(QUEUE, sizeof(struct rte_flow_action_queue)), MK_FLOW_ACTION(DROP, 0), MK_FLOW_ACTION(COUNT, 0), - MK_FLOW_ACTION(DUP, sizeof(struct rte_flow_action_dup)), MK_FLOW_ACTION(RSS, sizeof(struct rte_flow_action_rss)), /* +queue[] */ MK_FLOW_ACTION(PF, 0), MK_FLOW_ACTION(VF, sizeof(struct rte_flow_action_vf)), diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 51826d04c..a237e4fd2 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -1299,26 +1299,6 @@ Query structure to retrieve and reset flow rule counters: | ``bytes`` | out | number of bytes through this rule | +---------------+-----+-----------------------------------+ -Action: ``DUP`` -^^^^^^^^^^^^^^^ - -Duplicates packets to a given queue index. - -This is normally combined with QUEUE, however when used alone, it is -actually similar to QUEUE + PASSTHRU. - -- Non-terminating by default. - -.. _table_rte_flow_action_dup: - -.. table:: DUP - - +-----------+------------------------------------+ - | Field | Value | - +===========+====================================+ - | ``index`` | queue index to duplicate packet to | - +-----------+------------------------------------+ - Action: ``RSS`` ^^^^^^^^^^^^^^^ @@ -2010,9 +1990,6 @@ Unsupported actions and tagging (`Action: MARK`_ or `Action: FLAG`_) may be implemented in software as long as the target queue is used by a single rule. -- A rule specifying both `Action: DUP`_ + `Action: QUEUE`_ may be translated - to two hidden rules combining `Action: QUEUE`_ and `Action: PASSTHRU`_. - - When a single target queue is provided, `Action: RSS`_ can also be implemented through `Action: QUEUE`_. diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index cb6f201e1..a015d02a4 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3363,10 +3363,6 @@ actions can sometimes be combined when the end result is unambiguous:: :: - drop / dup index 6 / end # same as above - -:: - queue index 6 / rss queues 6 7 8 / end # queue has no effect :: @@ -3400,10 +3396,6 @@ This section lists supported actions and their attributes, if any. - ``count``: enable counters for this rule. -- ``dup``: duplicate packets to a given queue index. - - - ``index {unsigned}``: queue index to duplicate packets to. - - ``rss``: spread packets among several queues. - ``types [{RSS hash type} [...]] end``: RSS hash types, allowed tokens diff --git a/lib/librte_ether/rte_ethdev_version.map b/lib/librte_ether/rte_ethdev_version.map index e915e7929..8f1ae5ed2 100644 --- a/lib/librte_ether/rte_ethdev_version.map +++ b/lib/librte_ether/rte_ethdev_version.map @@ -147,7 +147,6 @@ DPDK_17.08 { _rte_eth_dev_callback_process; rte_eth_dev_adjust_nb_rx_tx_desc; - rte_flow_copy; rte_tm_capabilities_get; rte_tm_hierarchy_commit; rte_tm_level_capabilities_get; @@ -199,6 +198,7 @@ DPDK_18.02 { DPDK_18.05 { global: + rte_flow_copy; rte_flow_create; rte_flow_destroy; rte_flow_error_set; diff --git a/lib/librte_ether/rte_flow.c b/lib/librte_ether/rte_flow.c index ba6feddee..db04c4f94 100644 --- a/lib/librte_ether/rte_flow.c +++ b/lib/librte_ether/rte_flow.c @@ -73,7 +73,6 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = { MK_FLOW_ACTION(QUEUE, sizeof(struct rte_flow_action_queue)), MK_FLOW_ACTION(DROP, 0), MK_FLOW_ACTION(COUNT, 0), - MK_FLOW_ACTION(DUP, sizeof(struct rte_flow_action_dup)), MK_FLOW_ACTION(RSS, sizeof(struct rte_flow_action_rss)), /* +queue[] */ MK_FLOW_ACTION(PF, 0), MK_FLOW_ACTION(VF, sizeof(struct rte_flow_action_vf)), diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index 36fd38ffa..aab637a2c 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -961,16 +961,6 @@ enum rte_flow_action_type { RTE_FLOW_ACTION_TYPE_COUNT, /** - * Duplicates packets to a given queue index. - * - * This is normally combined with QUEUE, however when used alone, it - * is actually similar to QUEUE + PASSTHRU. - * - * See struct rte_flow_action_dup. - */ - RTE_FLOW_ACTION_TYPE_DUP, - - /** * Similar to QUEUE, except RSS is additionally performed on packets * to spread them among several queues according to the provided * parameters. @@ -1052,20 +1042,6 @@ struct rte_flow_query_count { }; /** - * RTE_FLOW_ACTION_TYPE_DUP - * - * Duplicates packets to a given queue index. - * - * This is normally combined with QUEUE, however when used alone, it is - * actually similar to QUEUE + PASSTHRU. - * - * Non-terminating by default. - */ -struct rte_flow_action_dup { - uint16_t index; /**< Queue index to duplicate packets to. */ -}; - -/** * RTE_FLOW_ACTION_TYPE_RSS * * Similar to QUEUE, except RSS is additionally performed on packets to -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v3 05/16] ethdev: alter behavior of flow API actions 2018-04-10 16:36 ` [dpdk-dev] [PATCH v3 00/16] Flow API overhaul for switch offloads Adrien Mazarguil ` (3 preceding siblings ...) 2018-04-10 16:36 ` [dpdk-dev] [PATCH v3 04/16] ethdev: remove DUP action from flow API Adrien Mazarguil @ 2018-04-10 16:36 ` Adrien Mazarguil 2018-04-10 16:36 ` [dpdk-dev] [PATCH v3 06/16] ethdev: remove C99 flexible arrays from flow API Adrien Mazarguil ` (11 subsequent siblings) 16 siblings, 0 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-10 16:36 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev Cc: Ajit Khaparde, Wenzhuo Lu, John Daley, Gaetan Rivet, Beilei Xing, Konstantin Ananyev, Nelio Laranjeiro, Andrew Rybchenko, Pascal Mazon This patch makes the following changes to flow rule actions: - List order now matters, they are redefined as performed first to last instead of "all simultaneously". - Repeated actions are now supported (e.g. specifying QUEUE multiple times now duplicates traffic among them). Previously only the last action of any given kind was taken into account. - No more distinction between terminating/non-terminating/meta actions. Flow rules themselves are now defined as always terminating unless a PASSTHRU action is specified. These changes alter the behavior of flow rules in corner cases in order to prepare the flow API for actions that modify traffic contents or properties (e.g. encapsulation, compression) and for which order matter when combined. Previously one would have to do so through multiple flow rules by combining PASSTRHU with priority levels, however this proved overly complex to implement at the PMD level, hence this simpler approach. This breaks ABI compatibility for the following public functions: - rte_flow_create() - rte_flow_validate() PMDs with rte_flow support are modified accordingly: - bnxt: no change, implementation already forbids multiple actions and does not support PASSTHRU. - e1000: no change, same as bnxt. - enic: modified to forbid redundant actions, no support for default drop. - failsafe: no change needed. - i40e: no change, implementation already forbids multiple actions. - ixgbe: same as i40e. - mlx4: modified to forbid multiple fate-deciding actions and drop when unspecified. - mlx5: same as mlx4, with other redundant actions also forbidden. - sfc: same as mlx4. - tap: implementation already complies with the new behavior except for the default pass-through modified as a default drop. Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Reviewed-by: Andrew Rybchenko <arybchenko@oktetlabs.ru> Cc: Ajit Khaparde <ajit.khaparde@broadcom.com> Cc: Wenzhuo Lu <wenzhuo.lu@intel.com> Cc: John Daley <johndale@cisco.com> Cc: Gaetan Rivet <gaetan.rivet@6wind.com> Cc: Beilei Xing <beilei.xing@intel.com> Cc: Konstantin Ananyev <konstantin.ananyev@intel.com> Cc: Nelio Laranjeiro <nelio.laranjeiro@6wind.com> Cc: Andrew Rybchenko <arybchenko@solarflare.com> Cc: Pascal Mazon <pascal.mazon@6wind.com> --- doc/guides/prog_guide/rte_flow.rst | 67 +++++++++++++------------------- drivers/net/enic/enic_flow.c | 25 ++++++++++++ drivers/net/mlx4/mlx4_flow.c | 21 +++++++--- drivers/net/mlx5/mlx5_flow.c | 69 ++++++++++++++------------------- drivers/net/sfc/sfc_flow.c | 22 +++++++---- drivers/net/tap/tap_flow.c | 11 ++++++ lib/librte_ether/rte_flow.h | 54 +++++++------------------- 7 files changed, 138 insertions(+), 131 deletions(-) diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index a237e4fd2..80360d068 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -995,28 +995,27 @@ Actions Each possible action is represented by a type. Some have associated configuration structures. Several actions combined in a list can be assigned -to a flow rule. That list is not ordered. +to a flow rule and are performed in order. They fall in three categories: -- Terminating actions that prevent processing matched packets by subsequent - flow rules, unless overridden with PASSTHRU. +- Actions that modify the fate of matching traffic, for instance by dropping + or assigning it a specific destination. -- Non-terminating actions that leave matched packets up for additional - processing by subsequent flow rules. +- Actions that modify matching traffic contents or its properties. This + includes adding/removing encapsulation, encryption, compression and marks. -- Other non-terminating meta actions that do not affect the fate of packets. +- Actions related to the flow rule itself, such as updating counters or + making it non-terminating. -When several actions are combined in a flow rule, they should all have -different types (e.g. dropping a packet twice is not possible). +Flow rules being terminating by default, not specifying any action of the +fate kind results in undefined behavior. This applies to both ingress and +egress. -Only the last action of a given type is taken into account. PMDs still -perform error checking on the entire list. +PASSTHRU, when supported, makes a flow rule non-terminating. Like matching patterns, action lists are terminated by END items. -*Note that PASSTHRU is the only action able to override a terminating rule.* - Example of action that redirects packets to queue index 10: .. _table_rte_flow_action_example: @@ -1029,12 +1028,11 @@ Example of action that redirects packets to queue index 10: | ``index`` | 10 | +-----------+-------+ -Action lists examples, their order is not significant, applications must -consider all actions to be performed simultaneously: +Actions are performed in list order: -.. _table_rte_flow_count_and_drop: +.. _table_rte_flow_count_then_drop: -.. table:: Count and drop +.. table:: Count then drop +-------+--------+ | Index | Action | @@ -1050,7 +1048,7 @@ consider all actions to be performed simultaneously: .. _table_rte_flow_mark_count_redirect: -.. table:: Mark, count and redirect +.. table:: Mark, count then redirect +-------+--------+-----------+-------+ | Index | Action | Field | Value | @@ -1080,12 +1078,15 @@ consider all actions to be performed simultaneously: | 2 | END | +-------+----------------------------+ -In the above example, considering both actions are performed simultaneously, -the end result is that only QUEUE has any effect. +In the above example, while DROP and QUEUE must be performed in order, both +have to happen before reaching END. Only QUEUE has a visible effect. + +Note that such a list may be thought as ambiguous and rejected on that +basis. -.. _table_rte_flow_redirect_queue_3: +.. _table_rte_flow_redirect_queue_5_3: -.. table:: Redirect to queue 3 +.. table:: Redirect to queues 5 and 3 +-------+--------+-----------+-------+ | Index | Action | Field | Value | @@ -1099,9 +1100,9 @@ the end result is that only QUEUE has any effect. | 3 | END | +-------+----------------------------+ -As previously described, only the last action of a given type found in the -list is taken into account. The above example also shows that VOID is -ignored. +As previously described, all actions must be taken into account. This +effectively duplicates traffic to both queues. The above example also shows +that VOID is ignored. Action types ~~~~~~~~~~~~ @@ -1151,9 +1152,8 @@ PMDs. Action: ``PASSTHRU`` ^^^^^^^^^^^^^^^^^^^^ -Leaves packets up for additional processing by subsequent flow rules. This -is the default when a rule does not contain a terminating action, but can be -specified to force a rule to become non-terminating. +Leaves traffic up for additional processing by subsequent flow rules; makes +a flow rule non-terminating. - No configurable properties. @@ -1227,8 +1227,6 @@ Action: ``QUEUE`` Assigns packets to a given queue index. -- Terminating by default. - .. _table_rte_flow_action_queue: .. table:: QUEUE @@ -1245,8 +1243,6 @@ Action: ``DROP`` Drop packets. - No configurable properties. -- Terminating by default. -- PASSTHRU overrides this action if both are specified. .. _table_rte_flow_action_drop: @@ -1309,8 +1305,6 @@ Note: RSS hash result is stored in the ``hash.rss`` mbuf field which overlaps ``hash.fdir.lo``. Since `Action: MARK`_ sets the ``hash.fdir.hi`` field only, both can be requested simultaneously. -- Terminating by default. - .. _table_rte_flow_action_rss: .. table:: RSS @@ -1331,7 +1325,6 @@ Action: ``PF`` Redirects packets to the physical function (PF) of the current device. - No configurable properties. -- Terminating by default. .. _table_rte_flow_action_pf: @@ -1353,8 +1346,6 @@ ID instead of the specified one. This parameter may not be available and is not guaranteed to work properly if the VF part is matched by a prior flow rule or if packets are not addressed to a VF in the first place. -- Terminating by default. - .. _table_rte_flow_action_vf: .. table:: VF @@ -1378,8 +1369,6 @@ action parameter. More than one flow can use the same MTR object through the meter action. The MTR object can be further updated or queried using the rte_mtr* API. -- Non-terminating by default. - .. _table_rte_flow_action_meter: .. table:: METER @@ -1415,8 +1404,6 @@ direction. Multiple flows can be configured to use the same security session. -- Non-terminating by default. - .. _table_rte_flow_action_security: .. table:: SECURITY diff --git a/drivers/net/enic/enic_flow.c b/drivers/net/enic/enic_flow.c index b9f36587c..a5c6a1670 100644 --- a/drivers/net/enic/enic_flow.c +++ b/drivers/net/enic/enic_flow.c @@ -3,6 +3,7 @@ */ #include <errno.h> +#include <stdint.h> #include <rte_log.h> #include <rte_ethdev_driver.h> #include <rte_flow_driver.h> @@ -964,6 +965,9 @@ static int enic_copy_action_v1(const struct rte_flow_action actions[], struct filter_action_v2 *enic_action) { + enum { FATE = 1, }; + uint32_t overlap = 0; + FLOW_TRACE(); for (; actions->type != RTE_FLOW_ACTION_TYPE_END; actions++) { @@ -975,6 +979,10 @@ enic_copy_action_v1(const struct rte_flow_action actions[], const struct rte_flow_action_queue *queue = (const struct rte_flow_action_queue *) actions->conf; + + if (overlap & FATE) + return ENOTSUP; + overlap |= FATE; enic_action->rq_idx = enic_rte_rq_idx_to_sop_idx(queue->index); break; @@ -984,6 +992,8 @@ enic_copy_action_v1(const struct rte_flow_action actions[], break; } } + if (!overlap & FATE) + return ENOTSUP; enic_action->type = FILTER_ACTION_RQ_STEERING; return 0; } @@ -1001,6 +1011,9 @@ static int enic_copy_action_v2(const struct rte_flow_action actions[], struct filter_action_v2 *enic_action) { + enum { FATE = 1, MARK = 2, }; + uint32_t overlap = 0; + FLOW_TRACE(); for (; actions->type != RTE_FLOW_ACTION_TYPE_END; actions++) { @@ -1009,6 +1022,10 @@ enic_copy_action_v2(const struct rte_flow_action actions[], const struct rte_flow_action_queue *queue = (const struct rte_flow_action_queue *) actions->conf; + + if (overlap & FATE) + return ENOTSUP; + overlap |= FATE; enic_action->rq_idx = enic_rte_rq_idx_to_sop_idx(queue->index); enic_action->flags |= FILTER_ACTION_RQ_STEERING_FLAG; @@ -1019,6 +1036,9 @@ enic_copy_action_v2(const struct rte_flow_action actions[], (const struct rte_flow_action_mark *) actions->conf; + if (overlap & MARK) + return ENOTSUP; + overlap |= MARK; /* ENIC_MAGIC_FILTER_ID is reserved and is the highest * in the range of allows mark ids. */ @@ -1029,6 +1049,9 @@ enic_copy_action_v2(const struct rte_flow_action actions[], break; } case RTE_FLOW_ACTION_TYPE_FLAG: { + if (overlap & MARK) + return ENOTSUP; + overlap |= MARK; enic_action->filter_id = ENIC_MAGIC_FILTER_ID; enic_action->flags |= FILTER_ACTION_FILTER_ID_FLAG; break; @@ -1044,6 +1067,8 @@ enic_copy_action_v2(const struct rte_flow_action actions[], break; } } + if (!overlap & FATE) + return ENOTSUP; enic_action->type = FILTER_ACTION_V2; return 0; } diff --git a/drivers/net/mlx4/mlx4_flow.c b/drivers/net/mlx4/mlx4_flow.c index 4d26df326..582483076 100644 --- a/drivers/net/mlx4/mlx4_flow.c +++ b/drivers/net/mlx4/mlx4_flow.c @@ -637,6 +637,7 @@ mlx4_flow_prepare(struct priv *priv, struct rte_flow temp = { .ibv_attr_size = sizeof(*temp.ibv_attr) }; struct rte_flow *flow = &temp; const char *msg = NULL; + int overlap; if (attr->group) return rte_flow_error_set @@ -656,6 +657,7 @@ mlx4_flow_prepare(struct priv *priv, (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, NULL, "only ingress is supported"); fill: + overlap = 0; proc = mlx4_flow_proc_item_list; /* Go over pattern. */ for (item = pattern; item->type; ++item) { @@ -702,6 +704,16 @@ mlx4_flow_prepare(struct priv *priv, } /* Go over actions list. */ for (action = actions; action->type; ++action) { + /* This one may appear anywhere multiple times. */ + if (action->type == RTE_FLOW_ACTION_TYPE_VOID) + continue; + /* Fate-deciding actions may appear exactly once. */ + if (overlap) { + msg = "cannot combine several fate-deciding actions," + " choose between DROP, QUEUE or RSS"; + goto exit_action_not_supported; + } + overlap = 1; switch (action->type) { const struct rte_flow_action_queue *queue; const struct rte_flow_action_rss *rss; @@ -709,8 +721,6 @@ mlx4_flow_prepare(struct priv *priv, uint64_t fields; unsigned int i; - case RTE_FLOW_ACTION_TYPE_VOID: - continue; case RTE_FLOW_ACTION_TYPE_DROP: flow->drop = 1; break; @@ -801,10 +811,9 @@ mlx4_flow_prepare(struct priv *priv, goto exit_action_not_supported; } } - if (!flow->rss && !flow->drop) - return rte_flow_error_set - (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, - NULL, "no valid action"); + /* When fate is unknown, drop traffic. */ + if (!overlap) + flow->drop = 1; /* Validation ends here. */ if (!addr) { if (flow->rss) diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index f051fbef5..84d6f9b92 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -4,6 +4,7 @@ */ #include <sys/queue.h> +#include <stdint.h> #include <string.h> /* Verbs header. */ @@ -638,6 +639,8 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, struct rte_flow_error *error, struct mlx5_flow_parse *parser) { + enum { FATE = 1, MARK = 2, COUNT = 4, }; + uint32_t overlap = 0; struct priv *priv = dev->data->dev_private; int ret; @@ -654,39 +657,31 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, if (actions->type == RTE_FLOW_ACTION_TYPE_VOID) { continue; } else if (actions->type == RTE_FLOW_ACTION_TYPE_DROP) { + if (overlap & FATE) + goto exit_action_overlap; + overlap |= FATE; parser->drop = 1; } else if (actions->type == RTE_FLOW_ACTION_TYPE_QUEUE) { const struct rte_flow_action_queue *queue = (const struct rte_flow_action_queue *) actions->conf; - uint16_t n; - uint16_t found = 0; + if (overlap & FATE) + goto exit_action_overlap; + overlap |= FATE; if (!queue || (queue->index > (priv->rxqs_n - 1))) goto exit_action_not_supported; - for (n = 0; n < parser->queues_n; ++n) { - if (parser->queues[n] == queue->index) { - found = 1; - break; - } - } - if (parser->queues_n > 1 && !found) { - rte_flow_error_set(error, ENOTSUP, - RTE_FLOW_ERROR_TYPE_ACTION, - actions, - "queue action not in RSS queues"); - return -rte_errno; - } - if (!found) { - parser->queues_n = 1; - parser->queues[0] = queue->index; - } + parser->queues_n = 1; + parser->queues[0] = queue->index; } else if (actions->type == RTE_FLOW_ACTION_TYPE_RSS) { const struct rte_flow_action_rss *rss = (const struct rte_flow_action_rss *) actions->conf; uint16_t n; + if (overlap & FATE) + goto exit_action_overlap; + overlap |= FATE; if (!rss || !rss->num) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, @@ -694,26 +689,6 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, "no valid queues"); return -rte_errno; } - if (parser->queues_n == 1) { - uint16_t found = 0; - - assert(parser->queues_n); - for (n = 0; n < rss->num; ++n) { - if (parser->queues[0] == - rss->queue[n]) { - found = 1; - break; - } - } - if (!found) { - rte_flow_error_set(error, ENOTSUP, - RTE_FLOW_ERROR_TYPE_ACTION, - actions, - "queue action not in RSS" - " queues"); - return -rte_errno; - } - } if (rss->num > RTE_DIM(parser->queues)) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, @@ -747,6 +722,9 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, (const struct rte_flow_action_mark *) actions->conf; + if (overlap & MARK) + goto exit_action_overlap; + overlap |= MARK; if (!mark) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, @@ -764,14 +742,23 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, parser->mark = 1; parser->mark_id = mark->id; } else if (actions->type == RTE_FLOW_ACTION_TYPE_FLAG) { + if (overlap & MARK) + goto exit_action_overlap; + overlap |= MARK; parser->mark = 1; } else if (actions->type == RTE_FLOW_ACTION_TYPE_COUNT && priv->config.flow_counter_en) { + if (overlap & COUNT) + goto exit_action_overlap; + overlap |= COUNT; parser->count = 1; } else { goto exit_action_not_supported; } } + /* When fate is unknown, drop traffic. */ + if (!overlap & FATE) + parser->drop = 1; if (parser->drop && parser->mark) parser->mark = 0; if (!parser->queues_n && !parser->drop) { @@ -784,6 +771,10 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, actions, "action not supported"); return -rte_errno; +exit_action_overlap: + rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, + actions, "overlapping actions are not supported"); + return -rte_errno; } /** diff --git a/drivers/net/sfc/sfc_flow.c b/drivers/net/sfc/sfc_flow.c index fe4c0b0c5..056405515 100644 --- a/drivers/net/sfc/sfc_flow.c +++ b/drivers/net/sfc/sfc_flow.c @@ -1467,10 +1467,19 @@ sfc_flow_parse_actions(struct sfc_adapter *sa, } for (; actions->type != RTE_FLOW_ACTION_TYPE_END; actions++) { + /* This one may appear anywhere multiple times. */ + if (actions->type == RTE_FLOW_ACTION_TYPE_VOID) + continue; + /* Fate-deciding actions may appear exactly once. */ + if (is_specified) { + rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, + actions, + "Cannot combine several fate-deciding actions," + "choose between QUEUE, RSS or DROP"); + return -rte_errno; + } switch (actions->type) { - case RTE_FLOW_ACTION_TYPE_VOID: - break; - case RTE_FLOW_ACTION_TYPE_QUEUE: rc = sfc_flow_parse_queue(sa, actions->conf, flow); if (rc != 0) { @@ -1512,11 +1521,10 @@ sfc_flow_parse_actions(struct sfc_adapter *sa, } } + /* When fate is unknown, drop traffic. */ if (!is_specified) { - rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ACTION_NUM, actions, - "Action is unspecified"); - return -rte_errno; + flow->spec.template.efs_dmaq_id = + EFX_FILTER_SPEC_RX_DMAQ_ID_DROP; } return 0; diff --git a/drivers/net/tap/tap_flow.c b/drivers/net/tap/tap_flow.c index 551b2d83d..aea3462a6 100644 --- a/drivers/net/tap/tap_flow.c +++ b/drivers/net/tap/tap_flow.c @@ -1140,6 +1140,7 @@ priv_flow_process(struct pmd_internals *pmd, else goto end; } +actions: for (; actions->type != RTE_FLOW_ACTION_TYPE_END; ++actions) { int err = 0; @@ -1222,6 +1223,16 @@ priv_flow_process(struct pmd_internals *pmd, if (err) goto exit_action_not_supported; } + /* When fate is unknown, drop traffic. */ + if (!action) { + static const struct rte_flow_action drop[] = { + { .type = RTE_FLOW_ACTION_TYPE_DROP, }, + { .type = RTE_FLOW_ACTION_TYPE_END, }, + }; + + actions = drop; + goto actions; + } end: if (flow) tap_nlattr_nested_finish(&flow->msg); /* nested TCA_OPTIONS */ diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index aab637a2c..af9b14a4d 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -859,32 +859,28 @@ struct rte_flow_item { * * Each possible action is represented by a type. Some have associated * configuration structures. Several actions combined in a list can be - * affected to a flow rule. That list is not ordered. + * assigned to a flow rule and are performed in order. * * They fall in three categories: * - * - Terminating actions that prevent processing matched packets by - * subsequent flow rules, unless overridden with PASSTHRU. + * - Actions that modify the fate of matching traffic, for instance by + * dropping or assigning it a specific destination. * - * - Non terminating actions that leave matched packets up for additional - * processing by subsequent flow rules. + * - Actions that modify matching traffic contents or its properties. This + * includes adding/removing encapsulation, encryption, compression and + * marks. * - * - Other non terminating meta actions that do not affect the fate of - * packets. + * - Actions related to the flow rule itself, such as updating counters or + * making it non-terminating. * - * When several actions are combined in a flow rule, they should all have - * different types (e.g. dropping a packet twice is not possible). + * Flow rules being terminating by default, not specifying any action of the + * fate kind results in undefined behavior. This applies to both ingress and + * egress. * - * Only the last action of a given type is taken into account. PMDs still - * perform error checking on the entire list. - * - * Note that PASSTHRU is the only action able to override a terminating - * rule. + * PASSTHRU, when supported, makes a flow rule non-terminating. */ enum rte_flow_action_type { /** - * [META] - * * End marker for action lists. Prevents further processing of * actions, thereby ending the list. * @@ -893,8 +889,6 @@ enum rte_flow_action_type { RTE_FLOW_ACTION_TYPE_END, /** - * [META] - * * Used as a placeholder for convenience. It is ignored and simply * discarded by PMDs. * @@ -903,18 +897,14 @@ enum rte_flow_action_type { RTE_FLOW_ACTION_TYPE_VOID, /** - * Leaves packets up for additional processing by subsequent flow - * rules. This is the default when a rule does not contain a - * terminating action, but can be specified to force a rule to - * become non-terminating. + * Leaves traffic up for additional processing by subsequent flow + * rules; makes a flow rule non-terminating. * * No associated configuration structure. */ RTE_FLOW_ACTION_TYPE_PASSTHRU, /** - * [META] - * * Attaches an integer value to packets and sets PKT_RX_FDIR and * PKT_RX_FDIR_ID mbuf flags. * @@ -923,8 +913,6 @@ enum rte_flow_action_type { RTE_FLOW_ACTION_TYPE_MARK, /** - * [META] - * * Flags packets. Similar to MARK without a specific value; only * sets the PKT_RX_FDIR mbuf flag. * @@ -949,9 +937,7 @@ enum rte_flow_action_type { RTE_FLOW_ACTION_TYPE_DROP, /** - * [META] - * - * Enables counters for this rule. + * Enables counters for this flow rule. * * These counters can be retrieved and reset through rte_flow_query(), * see struct rte_flow_query_count. @@ -1020,8 +1006,6 @@ struct rte_flow_action_mark { * RTE_FLOW_ACTION_TYPE_QUEUE * * Assign packets to a given queue index. - * - * Terminating by default. */ struct rte_flow_action_queue { uint16_t index; /**< Queue index to use. */ @@ -1050,8 +1034,6 @@ struct rte_flow_query_count { * Note: RSS hash result is stored in the hash.rss mbuf field which overlaps * hash.fdir.lo. Since the MARK action sets the hash.fdir.hi field only, * both can be requested simultaneously. - * - * Terminating by default. */ struct rte_flow_action_rss { const struct rte_eth_rss_conf *rss_conf; /**< RSS parameters. */ @@ -1069,8 +1051,6 @@ struct rte_flow_action_rss { * and is not guaranteed to work properly if the VF part is matched by a * prior flow rule or if packets are not addressed to a VF in the first * place. - * - * Terminating by default. */ struct rte_flow_action_vf { uint32_t original:1; /**< Use original VF ID if possible. */ @@ -1085,8 +1065,6 @@ struct rte_flow_action_vf { * * Packets matched by items of this type can be either dropped or passed to the * next item with their color set by the MTR object. - * - * Non-terminating by default. */ struct rte_flow_action_meter { uint32_t mtr_id; /**< MTR object ID created with rte_mtr_create(). */ @@ -1116,8 +1094,6 @@ struct rte_flow_action_meter { * direction. * * Multiple flows can be configured to use the same security session. - * - * Non-terminating by default. */ struct rte_flow_action_security { void *security_session; /**< Pointer to security session structure. */ -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v3 06/16] ethdev: remove C99 flexible arrays from flow API 2018-04-10 16:36 ` [dpdk-dev] [PATCH v3 00/16] Flow API overhaul for switch offloads Adrien Mazarguil ` (4 preceding siblings ...) 2018-04-10 16:36 ` [dpdk-dev] [PATCH v3 05/16] ethdev: alter behavior of flow API actions Adrien Mazarguil @ 2018-04-10 16:36 ` Adrien Mazarguil 2018-04-10 16:36 ` [dpdk-dev] [PATCH v3 07/16] ethdev: flatten RSS configuration in " Adrien Mazarguil ` (10 subsequent siblings) 16 siblings, 0 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-10 16:36 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev This patch replaces C99-style flexible arrays in struct rte_flow_action_rss and struct rte_flow_item_raw with standard pointers to the same data. They proved difficult to use in the field (e.g. no possibility of static initialization) and unsuitable for C++ applications. Affected PMDs and examples are updated accordingly. This breaks ABI compatibility for the following public functions: - rte_flow_copy() - rte_flow_create() - rte_flow_query() - rte_flow_validate() Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> --- app/test-pmd/cmdline_flow.c | 117 +++++++++++++++++--------------- app/test-pmd/config.c | 25 ++++--- doc/guides/prog_guide/rte_flow.rst | 18 ++--- drivers/net/mlx4/mlx4_flow.c | 22 +++--- drivers/net/mlx5/mlx5_flow.c | 20 +++--- examples/ipsec-secgw/ipsec.c | 17 ++--- lib/librte_ether/rte_flow.c | 25 ++++--- lib/librte_ether/rte_flow.h | 8 ++- 8 files changed, 135 insertions(+), 117 deletions(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index be867b0ec..acf19eb8a 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -179,25 +179,22 @@ enum index { ACTION_METER_ID, }; -/** Size of pattern[] field in struct rte_flow_item_raw. */ -#define ITEM_RAW_PATTERN_SIZE 36 +/** Maximum size for pattern in struct rte_flow_item_raw. */ +#define ITEM_RAW_PATTERN_SIZE 40 /** Storage size for struct rte_flow_item_raw including pattern. */ #define ITEM_RAW_SIZE \ - (offsetof(struct rte_flow_item_raw, pattern) + ITEM_RAW_PATTERN_SIZE) + (sizeof(struct rte_flow_item_raw) + ITEM_RAW_PATTERN_SIZE) /** Maximum number of queue indices in struct rte_flow_action_rss. */ #define ACTION_RSS_QUEUE_NUM 32 /** Storage for struct rte_flow_action_rss including external data. */ -union action_rss_data { +struct action_rss_data { struct rte_flow_action_rss conf; - struct { - uint8_t conf_data[offsetof(struct rte_flow_action_rss, queue)]; - uint16_t queue[ACTION_RSS_QUEUE_NUM]; - struct rte_eth_rss_conf rss_conf; - uint8_t rss_key[RSS_HASH_KEY_LENGTH]; - } s; + uint16_t queue[ACTION_RSS_QUEUE_NUM]; + struct rte_eth_rss_conf rss_conf; + uint8_t rss_key[RSS_HASH_KEY_LENGTH]; }; /** Maximum number of subsequent tokens and arguments on the stack. */ @@ -320,13 +317,6 @@ struct token { .size = sizeof(*((s *)0)->f), \ }) -/** Static initializer for ARGS() with arbitrary size. */ -#define ARGS_ENTRY_USZ(s, f, sz) \ - (&(const struct arg){ \ - .offset = offsetof(s, f), \ - .size = (sz), \ - }) - /** Static initializer for ARGS() with arbitrary offset and size. */ #define ARGS_ENTRY_ARB(o, s) \ (&(const struct arg){ \ @@ -1105,9 +1095,9 @@ static const struct token token_list[] = { NEXT_ENTRY(ITEM_PARAM_IS, ITEM_PARAM_SPEC, ITEM_PARAM_MASK)), - .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, length), - ARGS_ENTRY_USZ(struct rte_flow_item_raw, - pattern, + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, pattern), + ARGS_ENTRY(struct rte_flow_item_raw, length), + ARGS_ENTRY_ARB(sizeof(struct rte_flow_item_raw), ITEM_RAW_PATTERN_SIZE)), }, [ITEM_ETH] = { @@ -1591,7 +1581,7 @@ static const struct token token_list[] = { [ACTION_RSS] = { .name = "rss", .help = "spread packets among several queues", - .priv = PRIV_ACTION(RSS, sizeof(union action_rss_data)), + .priv = PRIV_ACTION(RSS, sizeof(struct action_rss_data)), .next = NEXT(action_rss), .call = parse_vc_action_rss, }, @@ -1610,23 +1600,21 @@ static const struct token token_list[] = { .name = "key", .help = "RSS hash key", .next = NEXT(action_rss, NEXT_ENTRY(STRING)), - .args = ARGS(ARGS_ENTRY_ARB - (((uintptr_t)&((union action_rss_data *)0)-> - s.rss_conf.rss_key_len), + .args = ARGS(ARGS_ENTRY_ARB(0, 0), + ARGS_ENTRY_ARB + (offsetof(struct action_rss_data, rss_conf) + + offsetof(struct rte_eth_rss_conf, rss_key_len), sizeof(((struct rte_eth_rss_conf *)0)-> rss_key_len)), - ARGS_ENTRY_ARB - (((uintptr_t)((union action_rss_data *)0)-> - s.rss_key), - RSS_HASH_KEY_LENGTH)), + ARGS_ENTRY(struct action_rss_data, rss_key)), }, [ACTION_RSS_KEY_LEN] = { .name = "key_len", .help = "RSS hash key length in bytes", .next = NEXT(action_rss, NEXT_ENTRY(UNSIGNED)), .args = ARGS(ARGS_ENTRY_ARB_BOUNDED - (((uintptr_t)&((union action_rss_data *)0)-> - s.rss_conf.rss_key_len), + (offsetof(struct action_rss_data, rss_conf) + + offsetof(struct rte_eth_rss_conf, rss_key_len), sizeof(((struct rte_eth_rss_conf *)0)-> rss_key_len), 0, @@ -2067,7 +2055,7 @@ parse_vc_action_rss(struct context *ctx, const struct token *token, { struct buffer *out = buf; struct rte_flow_action *action; - union action_rss_data *action_rss_data; + struct action_rss_data *action_rss_data; unsigned int i; int ret; @@ -2085,29 +2073,29 @@ parse_vc_action_rss(struct context *ctx, const struct token *token, ctx->objmask = NULL; /* Set up default configuration. */ action_rss_data = ctx->object; - *action_rss_data = (union action_rss_data){ + *action_rss_data = (struct action_rss_data){ .conf = (struct rte_flow_action_rss){ - .rss_conf = &action_rss_data->s.rss_conf, + .rss_conf = &action_rss_data->rss_conf, .num = RTE_MIN(nb_rxq, ACTION_RSS_QUEUE_NUM), + .queue = action_rss_data->queue, }, + .queue = { 0 }, + .rss_conf = (struct rte_eth_rss_conf){ + .rss_key = action_rss_data->rss_key, + .rss_key_len = sizeof(action_rss_data->rss_key), + .rss_hf = rss_hf, + }, + .rss_key = "testpmd's default RSS hash key", }; - action_rss_data->s.rss_conf = (struct rte_eth_rss_conf){ - .rss_key = action_rss_data->s.rss_key, - .rss_key_len = sizeof(action_rss_data->s.rss_key), - .rss_hf = rss_hf, - }; - strncpy((void *)action_rss_data->s.rss_key, - "testpmd's default RSS hash key", - sizeof(action_rss_data->s.rss_key)); for (i = 0; i < action_rss_data->conf.num; ++i) - action_rss_data->conf.queue[i] = i; + action_rss_data->queue[i] = i; if (!port_id_is_invalid(ctx->port, DISABLED_WARN) && ctx->port != (portid_t)RTE_PORT_ALL) { struct rte_eth_dev_info info; rte_eth_dev_info_get(ctx->port, &info); - action_rss_data->s.rss_conf.rss_key_len = - RTE_MIN(sizeof(action_rss_data->s.rss_key), + action_rss_data->rss_conf.rss_key_len = + RTE_MIN(sizeof(action_rss_data->rss_key), info.hash_key_size); } action->conf = &action_rss_data->conf; @@ -2125,7 +2113,7 @@ parse_vc_action_rss_type(struct context *ctx, const struct token *token, void *buf, unsigned int size) { static const enum index next[] = NEXT_ENTRY(ACTION_RSS_TYPE); - union action_rss_data *action_rss_data; + struct action_rss_data *action_rss_data; unsigned int i; (void)token; @@ -2135,7 +2123,7 @@ parse_vc_action_rss_type(struct context *ctx, const struct token *token, return -1; if (!(ctx->objdata >> 16) && ctx->object) { action_rss_data = ctx->object; - action_rss_data->s.rss_conf.rss_hf = 0; + action_rss_data->rss_conf.rss_hf = 0; } if (!strcmp_partial("end", str, len)) { ctx->objdata &= 0xffff; @@ -2154,7 +2142,7 @@ parse_vc_action_rss_type(struct context *ctx, const struct token *token, if (!ctx->object) return len; action_rss_data = ctx->object; - action_rss_data->s.rss_conf.rss_hf |= rss_type_table[i].rss_type; + action_rss_data->rss_conf.rss_hf |= rss_type_table[i].rss_type; return len; } @@ -2169,7 +2157,7 @@ parse_vc_action_rss_queue(struct context *ctx, const struct token *token, void *buf, unsigned int size) { static const enum index next[] = NEXT_ENTRY(ACTION_RSS_QUEUE); - union action_rss_data *action_rss_data; + struct action_rss_data *action_rss_data; int ret; int i; @@ -2186,10 +2174,9 @@ parse_vc_action_rss_queue(struct context *ctx, const struct token *token, if (i >= ACTION_RSS_QUEUE_NUM) return -1; if (push_args(ctx, - ARGS_ENTRY_ARB(offsetof(struct rte_flow_action_rss, - queue) + - i * sizeof(action_rss_data->s.queue[i]), - sizeof(action_rss_data->s.queue[i])))) + ARGS_ENTRY_ARB(offsetof(struct action_rss_data, queue) + + i * sizeof(action_rss_data->queue[i]), + sizeof(action_rss_data->queue[i])))) return -1; ret = parse_int(ctx, token, str, len, NULL, 0); if (ret < 0) { @@ -2206,6 +2193,7 @@ parse_vc_action_rss_queue(struct context *ctx, const struct token *token, return len; action_rss_data = ctx->object; action_rss_data->conf.num = i; + action_rss_data->conf.queue = i ? action_rss_data->queue : NULL; return len; } @@ -2483,8 +2471,8 @@ parse_int(struct context *ctx, const struct token *token, /** * Parse a string. * - * Two arguments (ctx->args) are retrieved from the stack to store data and - * its length (in that order). + * Three arguments (ctx->args) are retrieved from the stack to store data, + * its actual length and address (in that order). */ static int parse_string(struct context *ctx, const struct token *token, @@ -2493,6 +2481,7 @@ parse_string(struct context *ctx, const struct token *token, { const struct arg *arg_data = pop_args(ctx); const struct arg *arg_len = pop_args(ctx); + const struct arg *arg_addr = pop_args(ctx); char tmp[16]; /* Ought to be enough. */ int ret; @@ -2503,6 +2492,11 @@ parse_string(struct context *ctx, const struct token *token, push_args(ctx, arg_data); return -1; } + if (!arg_addr) { + push_args(ctx, arg_len); + push_args(ctx, arg_data); + return -1; + } size = arg_data->size; /* Bit-mask fill is not supported. */ if (arg_data->mask || size < len) @@ -2525,8 +2519,23 @@ parse_string(struct context *ctx, const struct token *token, memset((uint8_t *)buf + len, 0x00, size - len); if (ctx->objmask) memset((uint8_t *)ctx->objmask + arg_data->offset, 0xff, len); + /* Save address if requested. */ + if (arg_addr->size) { + memcpy((uint8_t *)ctx->object + arg_addr->offset, + (void *[]){ + (uint8_t *)ctx->object + arg_data->offset + }, + arg_addr->size); + if (ctx->objmask) + memcpy((uint8_t *)ctx->objmask + arg_addr->offset, + (void *[]){ + (uint8_t *)ctx->objmask + arg_data->offset + }, + arg_addr->size); + } return len; error: + push_args(ctx, arg_addr); push_args(ctx, arg_len); push_args(ctx, arg_data); return -1; diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 8d42ea9a9..052163357 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -961,7 +961,7 @@ static const struct { MK_FLOW_ITEM(PF, 0), MK_FLOW_ITEM(VF, sizeof(struct rte_flow_item_vf)), MK_FLOW_ITEM(PORT, sizeof(struct rte_flow_item_port)), - MK_FLOW_ITEM(RAW, sizeof(struct rte_flow_item_raw)), /* +pattern[] */ + MK_FLOW_ITEM(RAW, sizeof(struct rte_flow_item_raw)), MK_FLOW_ITEM(ETH, sizeof(struct rte_flow_item_eth)), MK_FLOW_ITEM(VLAN, sizeof(struct rte_flow_item_vlan)), MK_FLOW_ITEM(IPV4, sizeof(struct rte_flow_item_ipv4)), @@ -1010,14 +1010,20 @@ flow_item_spec_copy(void *buf, const struct rte_flow_item *item, union { struct rte_flow_item_raw *raw; } dst; + size_t off; case RTE_FLOW_ITEM_TYPE_RAW: src.raw = item_spec; dst.raw = buf; - size = offsetof(struct rte_flow_item_raw, pattern) + - src.raw->length * sizeof(*src.raw->pattern); - if (dst.raw) - memcpy(dst.raw, src.raw, size); + off = RTE_ALIGN_CEIL(sizeof(struct rte_flow_item_raw), + sizeof(*src.raw->pattern)); + size = off + src.raw->length * sizeof(*src.raw->pattern); + if (dst.raw) { + memcpy(dst.raw, src.raw, sizeof(*src.raw)); + dst.raw->pattern = memcpy((uint8_t *)dst.raw + off, + src.raw->pattern, + size - off); + } break; default: size = flow_item[item->type].size; @@ -1049,7 +1055,7 @@ static const struct { MK_FLOW_ACTION(QUEUE, sizeof(struct rte_flow_action_queue)), MK_FLOW_ACTION(DROP, 0), MK_FLOW_ACTION(COUNT, 0), - MK_FLOW_ACTION(RSS, sizeof(struct rte_flow_action_rss)), /* +queue[] */ + MK_FLOW_ACTION(RSS, sizeof(struct rte_flow_action_rss)), MK_FLOW_ACTION(PF, 0), MK_FLOW_ACTION(VF, sizeof(struct rte_flow_action_vf)), MK_FLOW_ACTION(METER, sizeof(struct rte_flow_action_meter)), @@ -1080,11 +1086,14 @@ flow_action_conf_copy(void *buf, const struct rte_flow_action *action) *dst.rss = (struct rte_flow_action_rss){ .num = src.rss->num, }; - off += offsetof(struct rte_flow_action_rss, queue); + off += sizeof(*src.rss); if (src.rss->num) { + off = RTE_ALIGN_CEIL(off, sizeof(double)); size = sizeof(*src.rss->queue) * src.rss->num; if (dst.rss) - memcpy(dst.rss->queue, src.rss->queue, size); + dst.rss->queue = memcpy + ((void *)((uintptr_t)dst.rss + off), + src.rss->queue, size); off += size; } off = RTE_ALIGN_CEIL(off, sizeof(double)); diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 80360d068..acbeaacbd 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -1309,15 +1309,15 @@ field only, both can be requested simultaneously. .. table:: RSS - +--------------+------------------------------+ - | Field | Value | - +==============+==============================+ - | ``rss_conf`` | RSS parameters | - +--------------+------------------------------+ - | ``num`` | number of entries in queue[] | - +--------------+------------------------------+ - | ``queue[]`` | queue indices to use | - +--------------+------------------------------+ + +--------------+--------------------------------+ + | Field | Value | + +==============+================================+ + | ``rss_conf`` | RSS parameters | + +--------------+--------------------------------+ + | ``num`` | number of entries in ``queue`` | + +--------------+--------------------------------+ + | ``queue`` | queue indices to use | + +--------------+--------------------------------+ Action: ``PF`` ^^^^^^^^^^^^^^ diff --git a/drivers/net/mlx4/mlx4_flow.c b/drivers/net/mlx4/mlx4_flow.c index 582483076..5a1b7dedd 100644 --- a/drivers/net/mlx4/mlx4_flow.c +++ b/drivers/net/mlx4/mlx4_flow.c @@ -1282,14 +1282,16 @@ mlx4_flow_internal(struct priv *priv, struct rte_flow_error *error) */ uint32_t queues = rte_align32pow2(priv->dev->data->nb_rx_queues + 1) >> 1; - alignas(struct rte_flow_action_rss) uint8_t rss_conf_data - [offsetof(struct rte_flow_action_rss, queue) + - sizeof(((struct rte_flow_action_rss *)0)->queue[0]) * queues]; - struct rte_flow_action_rss *rss_conf = (void *)rss_conf_data; + uint16_t queue[queues]; + struct rte_flow_action_rss action_rss = { + .rss_conf = NULL, /* Rely on default fallback settings. */ + .num = queues, + .queue = queue, + }; struct rte_flow_action actions[] = { { .type = RTE_FLOW_ACTION_TYPE_RSS, - .conf = rss_conf, + .conf = &action_rss, }, { .type = RTE_FLOW_ACTION_TYPE_END, @@ -1311,12 +1313,8 @@ mlx4_flow_internal(struct priv *priv, struct rte_flow_error *error) if (!queues) goto error; /* Prepare default RSS configuration. */ - *rss_conf = (struct rte_flow_action_rss){ - .rss_conf = NULL, /* Rely on default fallback settings. */ - .num = queues, - }; for (i = 0; i != queues; ++i) - rss_conf->queue[i] = i; + queue[i] = i; /* * Set up VLAN item if filtering is enabled and at least one VLAN * filter is configured. @@ -1375,7 +1373,7 @@ mlx4_flow_internal(struct priv *priv, struct rte_flow_error *error) if (j != sizeof(mac->addr_bytes)) continue; if (flow->rss->queues != queues || - memcmp(flow->rss->queue_id, rss_conf->queue, + memcmp(flow->rss->queue_id, action_rss.queue, queues * sizeof(flow->rss->queue_id[0]))) continue; break; @@ -1415,7 +1413,7 @@ mlx4_flow_internal(struct priv *priv, struct rte_flow_error *error) if (flow && flow->internal) { assert(flow->rss); if (flow->rss->queues != queues || - memcmp(flow->rss->queue_id, rss_conf->queue, + memcmp(flow->rss->queue_id, action_rss.queue, queues * sizeof(flow->rss->queue_id[0]))) flow = NULL; } diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 84d6f9b92..a52dcf263 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -2446,9 +2446,16 @@ mlx5_ctrl_flow_vlan(struct rte_eth_dev *dev, .type = RTE_FLOW_ITEM_TYPE_END, }, }; + uint16_t queue[priv->reta_idx_n]; + struct rte_flow_action_rss action_rss = { + .rss_conf = &priv->rss_conf, + .num = priv->reta_idx_n, + .queue = queue, + }; struct rte_flow_action actions[] = { { .type = RTE_FLOW_ACTION_TYPE_RSS, + .conf = &action_rss, }, { .type = RTE_FLOW_ACTION_TYPE_END, @@ -2457,24 +2464,13 @@ mlx5_ctrl_flow_vlan(struct rte_eth_dev *dev, struct rte_flow *flow; struct rte_flow_error error; unsigned int i; - union { - struct rte_flow_action_rss rss; - struct { - const struct rte_eth_rss_conf *rss_conf; - uint16_t num; - uint16_t queue[RTE_MAX_QUEUES_PER_PORT]; - } local; - } action_rss; if (!priv->reta_idx_n) { rte_errno = EINVAL; return -rte_errno; } for (i = 0; i != priv->reta_idx_n; ++i) - action_rss.local.queue[i] = (*priv->reta_idx)[i]; - action_rss.local.rss_conf = &priv->rss_conf; - action_rss.local.num = priv->reta_idx_n; - actions[0].conf = (const void *)&action_rss.rss; + queue[i] = (*priv->reta_idx)[i]; flow = mlx5_flow_list_create(dev, &priv->ctrl_flows, &attr, items, actions, &error); if (!flow) diff --git a/examples/ipsec-secgw/ipsec.c b/examples/ipsec-secgw/ipsec.c index 5fb5bc16e..8b2047adb 100644 --- a/examples/ipsec-secgw/ipsec.c +++ b/examples/ipsec-secgw/ipsec.c @@ -186,14 +186,8 @@ create_session(struct ipsec_ctx *ipsec_ctx, struct ipsec_sa *sa) .rss_key_len = 40, }; struct rte_eth_dev *eth_dev; - union { - struct rte_flow_action_rss rss; - struct { - const struct rte_eth_rss_conf *rss_conf; - uint16_t num; - uint16_t queue[RTE_MAX_QUEUES_PER_PORT]; - } local; - } action_rss; + uint16_t queue[RTE_MAX_QUEUES_PER_PORT]; + struct rte_flow_action_rss action_rss; unsigned int i; unsigned int j; @@ -207,9 +201,10 @@ create_session(struct ipsec_ctx *ipsec_ctx, struct ipsec_sa *sa) for (i = 0, j = 0; i < eth_dev->data->nb_rx_queues; ++i) if (eth_dev->data->rx_queues[i]) - action_rss.local.queue[j++] = i; - action_rss.local.num = j; - action_rss.local.rss_conf = &rss_conf; + queue[j++] = i; + action_rss.rss_conf = &rss_conf; + action_rss.num = j; + action_rss.queue = queue; ret = rte_flow_validate(sa->portid, &sa->attr, sa->pattern, sa->action, &err); diff --git a/lib/librte_ether/rte_flow.c b/lib/librte_ether/rte_flow.c index db04c4f94..550086411 100644 --- a/lib/librte_ether/rte_flow.c +++ b/lib/librte_ether/rte_flow.c @@ -39,7 +39,7 @@ static const struct rte_flow_desc_data rte_flow_desc_item[] = { MK_FLOW_ITEM(PF, 0), MK_FLOW_ITEM(VF, sizeof(struct rte_flow_item_vf)), MK_FLOW_ITEM(PORT, sizeof(struct rte_flow_item_port)), - MK_FLOW_ITEM(RAW, sizeof(struct rte_flow_item_raw)), /* +pattern[] */ + MK_FLOW_ITEM(RAW, sizeof(struct rte_flow_item_raw)), MK_FLOW_ITEM(ETH, sizeof(struct rte_flow_item_eth)), MK_FLOW_ITEM(VLAN, sizeof(struct rte_flow_item_vlan)), MK_FLOW_ITEM(IPV4, sizeof(struct rte_flow_item_ipv4)), @@ -73,7 +73,7 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = { MK_FLOW_ACTION(QUEUE, sizeof(struct rte_flow_action_queue)), MK_FLOW_ACTION(DROP, 0), MK_FLOW_ACTION(COUNT, 0), - MK_FLOW_ACTION(RSS, sizeof(struct rte_flow_action_rss)), /* +queue[] */ + MK_FLOW_ACTION(RSS, sizeof(struct rte_flow_action_rss)), MK_FLOW_ACTION(PF, 0), MK_FLOW_ACTION(VF, sizeof(struct rte_flow_action_vf)), }; @@ -282,14 +282,20 @@ flow_item_spec_copy(void *buf, const struct rte_flow_item *item, union { struct rte_flow_item_raw *raw; } dst; + size_t off; case RTE_FLOW_ITEM_TYPE_RAW: src.raw = item_spec; dst.raw = buf; - size = offsetof(struct rte_flow_item_raw, pattern) + - src.raw->length * sizeof(*src.raw->pattern); - if (dst.raw) - memcpy(dst.raw, src.raw, size); + off = RTE_ALIGN_CEIL(sizeof(struct rte_flow_item_raw), + sizeof(*src.raw->pattern)); + size = off + src.raw->length * sizeof(*src.raw->pattern); + if (dst.raw) { + memcpy(dst.raw, src.raw, sizeof(*src.raw)); + dst.raw->pattern = memcpy((uint8_t *)dst.raw + off, + src.raw->pattern, + size - off); + } break; default: size = rte_flow_desc_item[item->type].size; @@ -326,11 +332,14 @@ flow_action_conf_copy(void *buf, const struct rte_flow_action *action) *dst.rss = (struct rte_flow_action_rss){ .num = src.rss->num, }; - off += offsetof(struct rte_flow_action_rss, queue); + off += sizeof(*src.rss); if (src.rss->num) { + off = RTE_ALIGN_CEIL(off, sizeof(double)); size = sizeof(*src.rss->queue) * src.rss->num; if (dst.rss) - memcpy(dst.rss->queue, src.rss->queue, size); + dst.rss->queue = memcpy + ((void *)((uintptr_t)dst.rss + off), + src.rss->queue, size); off += size; } off = RTE_ALIGN_CEIL(off, sizeof(double)); diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index af9b14a4d..895feb1a3 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -14,6 +14,7 @@ * associated actions in hardware through flow rules. */ +#include <stddef.h> #include <stdint.h> #include <rte_arp.h> @@ -432,7 +433,7 @@ struct rte_flow_item_raw { int32_t offset; /**< Absolute or relative offset for pattern. */ uint16_t limit; /**< Search area limit for start of pattern. */ uint16_t length; /**< Pattern length. */ - uint8_t pattern[]; /**< Byte string to look for. */ + const uint8_t *pattern; /**< Byte string to look for. */ }; /** Default mask for RTE_FLOW_ITEM_TYPE_RAW. */ @@ -444,6 +445,7 @@ static const struct rte_flow_item_raw rte_flow_item_raw_mask = { .offset = 0xffffffff, .limit = 0xffff, .length = 0xffff, + .pattern = NULL, }; #endif @@ -1037,8 +1039,8 @@ struct rte_flow_query_count { */ struct rte_flow_action_rss { const struct rte_eth_rss_conf *rss_conf; /**< RSS parameters. */ - uint16_t num; /**< Number of entries in queue[]. */ - uint16_t queue[]; /**< Queues indices to use. */ + uint16_t num; /**< Number of entries in @p queue. */ + const uint16_t *queue; /**< Queue indices to use. */ }; /** -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v3 07/16] ethdev: flatten RSS configuration in flow API 2018-04-10 16:36 ` [dpdk-dev] [PATCH v3 00/16] Flow API overhaul for switch offloads Adrien Mazarguil ` (5 preceding siblings ...) 2018-04-10 16:36 ` [dpdk-dev] [PATCH v3 06/16] ethdev: remove C99 flexible arrays from flow API Adrien Mazarguil @ 2018-04-10 16:36 ` Adrien Mazarguil 2018-04-11 13:06 ` Andrew Rybchenko 2018-04-10 16:36 ` [dpdk-dev] [PATCH v3 08/16] ethdev: add hash function to RSS flow API action Adrien Mazarguil ` (9 subsequent siblings) 16 siblings, 1 reply; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-10 16:36 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev Cc: Xueming Li, Wenzhuo Lu, Jingjing Wu, Beilei Xing, Qi Zhang, Konstantin Ananyev, Nelio Laranjeiro, Yongseok Koh, Andrew Rybchenko, Pascal Mazon, Radu Nicolau, Akhil Goyal Since its inception, the rte_flow RSS action has been relying in part on external struct rte_eth_rss_conf for compatibility with the legacy RSS API. This structure lacks parameters such as the hash algorithm to use, and more recently, a method to tell which layer RSS should be performed on [1]. Given struct rte_eth_rss_conf will never be flexible enough to represent a complete RSS configuration (e.g. RETA table), this patch supersedes it by extending the rte_flow RSS action directly. A subsequent patch will add a field to use a non-default RSS hash algorithm. To that end, a field named "types" replaces the field formerly known as "rss_hf" and standing for "RSS hash functions" as it was confusing. Actual RSS hash function types are defined by enum rte_eth_hash_function. This patch updates all PMDs and example applications accordingly. It breaks ABI compatibility for the following public functions: - rte_flow_copy() - rte_flow_create() - rte_flow_query() - rte_flow_validate() [1] commit 676b605182a5 ("doc: announce ethdev API change for RSS configuration") Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Cc: Xueming Li <xuemingl@mellanox.com> Cc: Ferruh Yigit <ferruh.yigit@intel.com> Cc: Thomas Monjalon <thomas@monjalon.net> Cc: Wenzhuo Lu <wenzhuo.lu@intel.com> Cc: Jingjing Wu <jingjing.wu@intel.com> Cc: Beilei Xing <beilei.xing@intel.com> Cc: Qi Zhang <qi.z.zhang@intel.com> Cc: Konstantin Ananyev <konstantin.ananyev@intel.com> Cc: Nelio Laranjeiro <nelio.laranjeiro@6wind.com> Cc: Yongseok Koh <yskoh@mellanox.com> Cc: Andrew Rybchenko <arybchenko@solarflare.com> Cc: Pascal Mazon <pascal.mazon@6wind.com> Cc: Radu Nicolau <radu.nicolau@intel.com> Cc: Akhil Goyal <akhil.goyal@nxp.com> --- v3 changes: Documentation update regarding the meaning of a 0 value for RSS types in flow rules. It used to implicitly mean "no RSS" but is redefined as requesting a kind of "best-effort" mode from PMDs, i.e. anything ranging from empty to all-inclusive RSS; what matters is it provides safe defaults that will work regardless of PMD capabilities. --- app/test-pmd/cmdline_flow.c | 48 +++--- app/test-pmd/config.c | 39 ++--- doc/guides/prog_guide/rte_flow.rst | 28 ++-- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 6 +- drivers/net/e1000/e1000_ethdev.h | 13 +- drivers/net/e1000/igb_ethdev.c | 4 +- drivers/net/e1000/igb_flow.c | 31 ++-- drivers/net/e1000/igb_rxtx.c | 51 +++++- drivers/net/i40e/i40e_ethdev.c | 53 +++++-- drivers/net/i40e/i40e_ethdev.h | 15 +- drivers/net/i40e/i40e_flow.c | 57 ++++--- drivers/net/ixgbe/ixgbe_ethdev.c | 4 +- drivers/net/ixgbe/ixgbe_ethdev.h | 13 +- drivers/net/ixgbe/ixgbe_flow.c | 30 ++-- drivers/net/ixgbe/ixgbe_rxtx.c | 51 +++++- drivers/net/mlx4/mlx4.c | 2 +- drivers/net/mlx4/mlx4_flow.c | 61 +++---- drivers/net/mlx4/mlx4_flow.h | 2 +- drivers/net/mlx4/mlx4_rxq.c | 2 +- drivers/net/mlx4/mlx4_rxtx.h | 2 +- drivers/net/mlx5/mlx5_flow.c | 193 +++++++++++------------ drivers/net/mlx5/mlx5_rxq.c | 22 +-- drivers/net/mlx5/mlx5_rxtx.h | 26 +-- drivers/net/sfc/sfc_flow.c | 21 ++- drivers/net/tap/tap_flow.c | 8 +- examples/ipsec-secgw/ipsec.c | 10 +- lib/librte_ether/rte_flow.c | 39 ++--- lib/librte_ether/rte_flow.h | 12 +- 28 files changed, 484 insertions(+), 359 deletions(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index acf19eb8a..f6b73ca6e 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -192,9 +192,8 @@ enum index { /** Storage for struct rte_flow_action_rss including external data. */ struct action_rss_data { struct rte_flow_action_rss conf; + uint8_t key[RSS_HASH_KEY_LENGTH]; uint16_t queue[ACTION_RSS_QUEUE_NUM]; - struct rte_eth_rss_conf rss_conf; - uint8_t rss_key[RSS_HASH_KEY_LENGTH]; }; /** Maximum number of subsequent tokens and arguments on the stack. */ @@ -1587,7 +1586,7 @@ static const struct token token_list[] = { }, [ACTION_RSS_TYPES] = { .name = "types", - .help = "RSS hash types", + .help = "specific RSS hash types", .next = NEXT(action_rss, NEXT_ENTRY(ACTION_RSS_TYPE)), }, [ACTION_RSS_TYPE] = { @@ -1602,21 +1601,21 @@ static const struct token token_list[] = { .next = NEXT(action_rss, NEXT_ENTRY(STRING)), .args = ARGS(ARGS_ENTRY_ARB(0, 0), ARGS_ENTRY_ARB - (offsetof(struct action_rss_data, rss_conf) + - offsetof(struct rte_eth_rss_conf, rss_key_len), - sizeof(((struct rte_eth_rss_conf *)0)-> - rss_key_len)), - ARGS_ENTRY(struct action_rss_data, rss_key)), + (offsetof(struct action_rss_data, conf) + + offsetof(struct rte_flow_action_rss, key_len), + sizeof(((struct rte_flow_action_rss *)0)-> + key_len)), + ARGS_ENTRY(struct action_rss_data, key)), }, [ACTION_RSS_KEY_LEN] = { .name = "key_len", .help = "RSS hash key length in bytes", .next = NEXT(action_rss, NEXT_ENTRY(UNSIGNED)), .args = ARGS(ARGS_ENTRY_ARB_BOUNDED - (offsetof(struct action_rss_data, rss_conf) + - offsetof(struct rte_eth_rss_conf, rss_key_len), - sizeof(((struct rte_eth_rss_conf *)0)-> - rss_key_len), + (offsetof(struct action_rss_data, conf) + + offsetof(struct rte_flow_action_rss, key_len), + sizeof(((struct rte_flow_action_rss *)0)-> + key_len), 0, RSS_HASH_KEY_LENGTH)), }, @@ -2075,27 +2074,24 @@ parse_vc_action_rss(struct context *ctx, const struct token *token, action_rss_data = ctx->object; *action_rss_data = (struct action_rss_data){ .conf = (struct rte_flow_action_rss){ - .rss_conf = &action_rss_data->rss_conf, - .num = RTE_MIN(nb_rxq, ACTION_RSS_QUEUE_NUM), + .types = rss_hf, + .key_len = sizeof(action_rss_data->key), + .queue_num = RTE_MIN(nb_rxq, ACTION_RSS_QUEUE_NUM), + .key = action_rss_data->key, .queue = action_rss_data->queue, }, + .key = "testpmd's default RSS hash key", .queue = { 0 }, - .rss_conf = (struct rte_eth_rss_conf){ - .rss_key = action_rss_data->rss_key, - .rss_key_len = sizeof(action_rss_data->rss_key), - .rss_hf = rss_hf, - }, - .rss_key = "testpmd's default RSS hash key", }; - for (i = 0; i < action_rss_data->conf.num; ++i) + for (i = 0; i < action_rss_data->conf.queue_num; ++i) action_rss_data->queue[i] = i; if (!port_id_is_invalid(ctx->port, DISABLED_WARN) && ctx->port != (portid_t)RTE_PORT_ALL) { struct rte_eth_dev_info info; rte_eth_dev_info_get(ctx->port, &info); - action_rss_data->rss_conf.rss_key_len = - RTE_MIN(sizeof(action_rss_data->rss_key), + action_rss_data->conf.key_len = + RTE_MIN(sizeof(action_rss_data->key), info.hash_key_size); } action->conf = &action_rss_data->conf; @@ -2123,7 +2119,7 @@ parse_vc_action_rss_type(struct context *ctx, const struct token *token, return -1; if (!(ctx->objdata >> 16) && ctx->object) { action_rss_data = ctx->object; - action_rss_data->rss_conf.rss_hf = 0; + action_rss_data->conf.types = 0; } if (!strcmp_partial("end", str, len)) { ctx->objdata &= 0xffff; @@ -2142,7 +2138,7 @@ parse_vc_action_rss_type(struct context *ctx, const struct token *token, if (!ctx->object) return len; action_rss_data = ctx->object; - action_rss_data->rss_conf.rss_hf |= rss_type_table[i].rss_type; + action_rss_data->conf.types |= rss_type_table[i].rss_type; return len; } @@ -2192,7 +2188,7 @@ parse_vc_action_rss_queue(struct context *ctx, const struct token *token, if (!ctx->object) return len; action_rss_data = ctx->object; - action_rss_data->conf.num = i; + action_rss_data->conf.queue_num = i; action_rss_data->conf.queue = i ? action_rss_data->queue : NULL; return len; } diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 052163357..717f31774 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -1084,40 +1084,27 @@ flow_action_conf_copy(void *buf, const struct rte_flow_action *action) off = 0; if (dst.rss) *dst.rss = (struct rte_flow_action_rss){ - .num = src.rss->num, + .types = src.rss->types, + .key_len = src.rss->key_len, + .queue_num = src.rss->queue_num, }; off += sizeof(*src.rss); - if (src.rss->num) { + if (src.rss->key_len) { off = RTE_ALIGN_CEIL(off, sizeof(double)); - size = sizeof(*src.rss->queue) * src.rss->num; + size = sizeof(*src.rss->key) * src.rss->key_len; if (dst.rss) - dst.rss->queue = memcpy + dst.rss->key = memcpy ((void *)((uintptr_t)dst.rss + off), - src.rss->queue, size); + src.rss->key, size); off += size; } - off = RTE_ALIGN_CEIL(off, sizeof(double)); - if (dst.rss) { - dst.rss->rss_conf = (void *)((uintptr_t)dst.rss + off); - *(struct rte_eth_rss_conf *)(uintptr_t) - dst.rss->rss_conf = (struct rte_eth_rss_conf){ - .rss_key_len = src.rss->rss_conf->rss_key_len, - .rss_hf = src.rss->rss_conf->rss_hf, - }; - } - off += sizeof(*src.rss->rss_conf); - if (src.rss->rss_conf->rss_key_len) { + if (src.rss->queue_num) { off = RTE_ALIGN_CEIL(off, sizeof(double)); - size = sizeof(*src.rss->rss_conf->rss_key) * - src.rss->rss_conf->rss_key_len; - if (dst.rss) { - ((struct rte_eth_rss_conf *)(uintptr_t) - dst.rss->rss_conf)->rss_key = - (void *)((uintptr_t)dst.rss + off); - memcpy(dst.rss->rss_conf->rss_key, - src.rss->rss_conf->rss_key, - size); - } + size = sizeof(*src.rss->queue) * src.rss->queue_num; + if (dst.rss) + dst.rss->queue = memcpy + ((void *)((uintptr_t)dst.rss + off), + src.rss->queue, size); off += size; } size = off; diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index acbeaacbd..cf252eeba 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -1301,6 +1301,12 @@ Action: ``RSS`` Similar to QUEUE, except RSS is additionally performed on packets to spread them among several queues according to the provided parameters. +Unlike global RSS settings used by other DPDK APIs, unsetting the ``types`` +field does not disable RSS in a flow rule. Doing so instead requests safe +unspecified "best-effort" settings from the underlying PMD, which depending +on the flow rule, may result in anything ranging from empty (single queue) +to all-inclusive RSS. + Note: RSS hash result is stored in the ``hash.rss`` mbuf field which overlaps ``hash.fdir.lo``. Since `Action: MARK`_ sets the ``hash.fdir.hi`` field only, both can be requested simultaneously. @@ -1309,15 +1315,19 @@ field only, both can be requested simultaneously. .. table:: RSS - +--------------+--------------------------------+ - | Field | Value | - +==============+================================+ - | ``rss_conf`` | RSS parameters | - +--------------+--------------------------------+ - | ``num`` | number of entries in ``queue`` | - +--------------+--------------------------------+ - | ``queue`` | queue indices to use | - +--------------+--------------------------------+ + +---------------+---------------------------------------------+ + | Field | Value | + +===============+=============================================+ + | ``types`` | specific RSS hash types (see ``ETH_RSS_*``) | + +---------------+---------------------------------------------+ + | ``key_len`` | hash key length in bytes | + +---------------+---------------------------------------------+ + | ``queue_num`` | number of entries in ``queue`` | + +---------------+---------------------------------------------+ + | ``key`` | hash key | + +---------------+---------------------------------------------+ + | ``queue`` | queue indices to use | + +---------------+---------------------------------------------+ Action: ``PF`` ^^^^^^^^^^^^^^ diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index a015d02a4..17336d163 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3398,8 +3398,10 @@ This section lists supported actions and their attributes, if any. - ``rss``: spread packets among several queues. - - ``types [{RSS hash type} [...]] end``: RSS hash types, allowed tokens - are the same as `set_hash_input_set`_, an empty list means none (0). + - ``types [{RSS hash type} [...]] end``: specific RSS hash types, allowed + tokens are the same as `set_hash_input_set`_, except that an empty list + does not disable RSS but instead requests unspecified "best-effort" + settings. - ``key {string}``: RSS hash key, overrides ``key_len``. diff --git a/drivers/net/e1000/e1000_ethdev.h b/drivers/net/e1000/e1000_ethdev.h index 6354b894a..902001f36 100644 --- a/drivers/net/e1000/e1000_ethdev.h +++ b/drivers/net/e1000/e1000_ethdev.h @@ -4,6 +4,10 @@ #ifndef _E1000_ETHDEV_H_ #define _E1000_ETHDEV_H_ + +#include <stdint.h> + +#include <rte_flow.h> #include <rte_time.h> #include <rte_pci.h> @@ -27,6 +31,7 @@ #define E1000_CTRL_EXT_EXTEND_VLAN (1<<26) /* EXTENDED VLAN */ #define IGB_VFTA_SIZE 128 +#define IGB_HKEY_MAX_INDEX 10 #define IGB_MAX_RX_QUEUE_NUM 8 #define IGB_MAX_RX_QUEUE_NUM_82576 16 @@ -229,8 +234,8 @@ struct igb_ethertype_filter { }; struct igb_rte_flow_rss_conf { - struct rte_eth_rss_conf rss_conf; /**< RSS parameters. */ - uint16_t num; /**< Number of entries in queue[]. */ + struct rte_flow_action_rss conf; /**< RSS parameters. */ + uint8_t key[IGB_HKEY_MAX_INDEX * sizeof(uint32_t)]; /* Hash key. */ uint16_t queue[IGB_MAX_RX_QUEUE_NUM]; /**< Queues indices to use. */ }; @@ -501,6 +506,10 @@ int eth_igb_syn_filter_set(struct rte_eth_dev *dev, int eth_igb_add_del_flex_filter(struct rte_eth_dev *dev, struct rte_eth_flex_filter *filter, bool add); +int igb_rss_conf_init(struct igb_rte_flow_rss_conf *out, + const struct rte_flow_action_rss *in); +int igb_action_rss_same(const struct rte_flow_action_rss *comp, + const struct rte_flow_action_rss *with); int igb_config_rss_filter(struct rte_eth_dev *dev, struct igb_rte_flow_rss_conf *conf, bool add); diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c index 8d4226676..7a431ac33 100644 --- a/drivers/net/e1000/igb_ethdev.c +++ b/drivers/net/e1000/igb_ethdev.c @@ -41,8 +41,6 @@ #define IGB_DEFAULT_TX_HTHRESH 1 #define IGB_DEFAULT_TX_WTHRESH ((hw->mac.type == e1000_82576) ? 1 : 16) -#define IGB_HKEY_MAX_INDEX 10 - /* Bit shift and mask */ #define IGB_4_BIT_WIDTH (CHAR_BIT / 2) #define IGB_4_BIT_MASK RTE_LEN2MASK(IGB_4_BIT_WIDTH, uint8_t) @@ -5576,7 +5574,7 @@ igb_rss_filter_restore(struct rte_eth_dev *dev) struct e1000_filter_info *filter_info = E1000_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private); - if (filter_info->rss_info.num) + if (filter_info->rss_info.conf.queue_num) igb_config_rss_filter(dev, &filter_info->rss_info, TRUE); } diff --git a/drivers/net/e1000/igb_flow.c b/drivers/net/e1000/igb_flow.c index c0f5b5190..8dc5f75f2 100644 --- a/drivers/net/e1000/igb_flow.c +++ b/drivers/net/e1000/igb_flow.c @@ -1292,7 +1292,7 @@ igb_parse_rss_filter(struct rte_eth_dev *dev, rss = (const struct rte_flow_action_rss *)act->conf; - if (!rss || !rss->num) { + if (!rss || !rss->queue_num) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, act, @@ -1300,7 +1300,7 @@ igb_parse_rss_filter(struct rte_eth_dev *dev, return -rte_errno; } - for (n = 0; n < rss->num; n++) { + for (n = 0; n < rss->queue_num; n++) { if (rss->queue[n] >= dev->data->nb_rx_queues) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, @@ -1310,14 +1310,18 @@ igb_parse_rss_filter(struct rte_eth_dev *dev, } } - if (rss->rss_conf) - rss_conf->rss_conf = *rss->rss_conf; - else - rss_conf->rss_conf.rss_hf = IGB_RSS_OFFLOAD_ALL; - - for (n = 0; n < rss->num; ++n) - rss_conf->queue[n] = rss->queue[n]; - rss_conf->num = rss->num; + if (rss->key_len && rss->key_len != RTE_DIM(rss_conf->key)) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, + "RSS hash key must be exactly 40 bytes"); + if (rss->queue_num > RTE_DIM(rss_conf->queue)) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, + "too many queues for RSS context"); + if (igb_rss_conf_init(rss_conf, rss)) + return rte_flow_error_set + (error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, act, + "RSS context initialization failure"); /* check if the next not void item is END */ index++; @@ -1518,9 +1522,8 @@ igb_flow_create(struct rte_eth_dev *dev, PMD_DRV_LOG(ERR, "failed to allocate memory"); goto out; } - rte_memcpy(&rss_filter_ptr->filter_info, - &rss_conf, - sizeof(struct igb_rte_flow_rss_conf)); + igb_rss_conf_init(&rss_filter_ptr->filter_info, + &rss_conf.conf); TAILQ_INSERT_TAIL(&igb_filter_rss_list, rss_filter_ptr, entries); flow->rule = rss_filter_ptr; @@ -1757,7 +1760,7 @@ igb_clear_rss_filter(struct rte_eth_dev *dev) struct e1000_filter_info *filter = E1000_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private); - if (filter->rss_info.num) + if (filter->rss_info.conf.queue_num) igb_config_rss_filter(dev, &filter->rss_info, FALSE); } diff --git a/drivers/net/e1000/igb_rxtx.c b/drivers/net/e1000/igb_rxtx.c index 323913f0d..45bb3455c 100644 --- a/drivers/net/e1000/igb_rxtx.c +++ b/drivers/net/e1000/igb_rxtx.c @@ -2898,12 +2898,47 @@ igb_txq_info_get(struct rte_eth_dev *dev, uint16_t queue_id, } int +igb_rss_conf_init(struct igb_rte_flow_rss_conf *out, + const struct rte_flow_action_rss *in) +{ + if (in->key_len > RTE_DIM(out->key) || + in->queue_num > RTE_DIM(out->queue)) + return -EINVAL; + out->conf = (struct rte_flow_action_rss){ + .types = in->types, + .key_len = in->key_len, + .queue_num = in->queue_num, + .key = memcpy(out->key, in->key, in->key_len), + .queue = memcpy(out->queue, in->queue, + sizeof(*in->queue) * in->queue_num), + }; + return 0; +} + +int +igb_action_rss_same(const struct rte_flow_action_rss *comp, + const struct rte_flow_action_rss *with) +{ + return (comp->types == with->types && + comp->key_len == with->key_len && + comp->queue_num == with->queue_num && + !memcmp(comp->key, with->key, with->key_len) && + !memcmp(comp->queue, with->queue, + sizeof(*with->queue) * with->queue_num)); +} + +int igb_config_rss_filter(struct rte_eth_dev *dev, struct igb_rte_flow_rss_conf *conf, bool add) { uint32_t shift; uint16_t i, j; - struct rte_eth_rss_conf rss_conf = conf->rss_conf; + struct rte_eth_rss_conf rss_conf = { + .rss_key = conf->conf.key_len ? + (void *)(uintptr_t)conf->conf.key : NULL, + .rss_key_len = conf->conf.key_len, + .rss_hf = conf->conf.types, + }; struct e1000_filter_info *filter_info = E1000_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private); struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private); @@ -2911,8 +2946,8 @@ igb_config_rss_filter(struct rte_eth_dev *dev, hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private); if (!add) { - if (memcmp(conf, &filter_info->rss_info, - sizeof(struct igb_rte_flow_rss_conf)) == 0) { + if (igb_action_rss_same(&filter_info->rss_info.conf, + &conf->conf)) { igb_rss_disable(dev); memset(&filter_info->rss_info, 0, sizeof(struct igb_rte_flow_rss_conf)); @@ -2921,7 +2956,7 @@ igb_config_rss_filter(struct rte_eth_dev *dev, return -EINVAL; } - if (filter_info->rss_info.num) + if (filter_info->rss_info.conf.queue_num) return -EINVAL; /* Fill in redirection table. */ @@ -2933,9 +2968,9 @@ igb_config_rss_filter(struct rte_eth_dev *dev, } reta; uint8_t q_idx; - if (j == conf->num) + if (j == conf->conf.queue_num) j = 0; - q_idx = conf->queue[j]; + q_idx = conf->conf.queue[j]; reta.bytes[i & 3] = (uint8_t)(q_idx << shift); if ((i & 3) == 3) E1000_WRITE_REG(hw, E1000_RETA(i >> 2), reta.dword); @@ -2952,8 +2987,8 @@ igb_config_rss_filter(struct rte_eth_dev *dev, rss_conf.rss_key = rss_intel_key; /* Default hash key */ igb_hw_rss_hash_set(hw, &rss_conf); - rte_memcpy(&filter_info->rss_info, - conf, sizeof(struct igb_rte_flow_rss_conf)); + if (igb_rss_conf_init(&filter_info->rss_info, &conf->conf)) + return -EINVAL; return 0; } diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index 6e06f8a2b..0242b5d59 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c @@ -11,6 +11,7 @@ #include <inttypes.h> #include <assert.h> +#include <rte_common.h> #include <rte_eal.h> #include <rte_string_fns.h> #include <rte_pci.h> @@ -11467,7 +11468,7 @@ i40e_rss_filter_restore(struct i40e_pf *pf) { struct i40e_rte_flow_rss_conf *conf = &pf->rss_info; - if (conf->num) + if (conf->conf.queue_num) i40e_config_rss_filter(pf, conf, TRUE); } @@ -11966,18 +11967,52 @@ i40e_cloud_filter_qinq_create(struct i40e_pf *pf) } int +i40e_rss_conf_init(struct i40e_rte_flow_rss_conf *out, + const struct rte_flow_action_rss *in) +{ + if (in->key_len > RTE_DIM(out->key) || + in->queue_num > RTE_DIM(out->queue)) + return -EINVAL; + out->conf = (struct rte_flow_action_rss){ + .types = in->types, + .key_len = in->key_len, + .queue_num = in->queue_num, + .key = memcpy(out->key, in->key, in->key_len), + .queue = memcpy(out->queue, in->queue, + sizeof(*in->queue) * in->queue_num), + }; + return 0; +} + +int +i40e_action_rss_same(const struct rte_flow_action_rss *comp, + const struct rte_flow_action_rss *with) +{ + return (comp->types == with->types && + comp->key_len == with->key_len && + comp->queue_num == with->queue_num && + !memcmp(comp->key, with->key, with->key_len) && + !memcmp(comp->queue, with->queue, + sizeof(*with->queue) * with->queue_num)); +} + +int i40e_config_rss_filter(struct i40e_pf *pf, struct i40e_rte_flow_rss_conf *conf, bool add) { struct i40e_hw *hw = I40E_PF_TO_HW(pf); uint32_t i, lut = 0; uint16_t j, num; - struct rte_eth_rss_conf rss_conf = conf->rss_conf; + struct rte_eth_rss_conf rss_conf = { + .rss_key = conf->conf.key_len ? + (void *)(uintptr_t)conf->conf.key : NULL, + .rss_key_len = conf->conf.key_len, + .rss_hf = conf->conf.types, + }; struct i40e_rte_flow_rss_conf *rss_info = &pf->rss_info; if (!add) { - if (memcmp(conf, rss_info, - sizeof(struct i40e_rte_flow_rss_conf)) == 0) { + if (i40e_action_rss_same(&rss_info->conf, &conf->conf)) { i40e_pf_disable_rss(pf); memset(rss_info, 0, sizeof(struct i40e_rte_flow_rss_conf)); @@ -11986,7 +12021,7 @@ i40e_config_rss_filter(struct i40e_pf *pf, return -EINVAL; } - if (rss_info->num) + if (rss_info->conf.queue_num) return -EINVAL; /* If both VMDQ and RSS enabled, not all of PF queues are configured. @@ -11997,7 +12032,7 @@ i40e_config_rss_filter(struct i40e_pf *pf, else num = pf->dev_data->nb_rx_queues; - num = RTE_MIN(num, conf->num); + num = RTE_MIN(num, conf->conf.queue_num); PMD_DRV_LOG(INFO, "Max of contiguous %u PF queues are configured", num); @@ -12010,7 +12045,7 @@ i40e_config_rss_filter(struct i40e_pf *pf, for (i = 0, j = 0; i < hw->func_caps.rss_table_size; i++, j++) { if (j == num) j = 0; - lut = (lut << 8) | (conf->queue[j] & ((0x1 << + lut = (lut << 8) | (conf->conf.queue[j] & ((0x1 << hw->func_caps.rss_table_entry_width) - 1)); if ((i & 3) == 3) I40E_WRITE_REG(hw, I40E_PFQF_HLUT(i >> 2), lut); @@ -12035,8 +12070,8 @@ i40e_config_rss_filter(struct i40e_pf *pf, i40e_hw_rss_hash_set(pf, &rss_conf); - rte_memcpy(rss_info, - conf, sizeof(struct i40e_rte_flow_rss_conf)); + if (i40e_rss_conf_init(rss_info, &conf->conf)) + return -EINVAL; return 0; } diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h index 151ed1a8c..5c02b37a0 100644 --- a/drivers/net/i40e/i40e_ethdev.h +++ b/drivers/net/i40e/i40e_ethdev.h @@ -5,13 +5,18 @@ #ifndef _I40E_ETHDEV_H_ #define _I40E_ETHDEV_H_ +#include <stdint.h> + #include <rte_eth_ctrl.h> #include <rte_time.h> #include <rte_kvargs.h> #include <rte_hash.h> +#include <rte_flow.h> #include <rte_flow_driver.h> #include <rte_tm_driver.h> +#include "base/i40e_register.h" + #define I40E_VLAN_TAG_SIZE 4 #define I40E_AQ_LEN 32 @@ -877,9 +882,11 @@ struct i40e_customized_pctype { }; struct i40e_rte_flow_rss_conf { - struct rte_eth_rss_conf rss_conf; /**< RSS parameters. */ + struct rte_flow_action_rss conf; /**< RSS parameters. */ uint16_t queue_region_conf; /**< Queue region config flag */ - uint16_t num; /**< Number of entries in queue[]. */ + uint8_t key[(I40E_VFQF_HKEY_MAX_INDEX > I40E_PFQF_HKEY_MAX_INDEX ? + I40E_VFQF_HKEY_MAX_INDEX : I40E_PFQF_HKEY_MAX_INDEX) + 1 * + sizeof(uint32_t)]; /* Hash key. */ uint16_t queue[I40E_MAX_Q_PER_TC]; /**< Queues indices to use. */ }; @@ -1217,6 +1224,10 @@ void i40e_init_queue_region_conf(struct rte_eth_dev *dev); void i40e_flex_payload_reg_set_default(struct i40e_hw *hw); int i40e_set_rss_key(struct i40e_vsi *vsi, uint8_t *key, uint8_t key_len); int i40e_set_rss_lut(struct i40e_vsi *vsi, uint8_t *lut, uint16_t lut_size); +int i40e_rss_conf_init(struct i40e_rte_flow_rss_conf *out, + const struct rte_flow_action_rss *in); +int i40e_action_rss_same(const struct rte_flow_action_rss *comp, + const struct rte_flow_action_rss *with); int i40e_config_rss_filter(struct i40e_pf *pf, struct i40e_rte_flow_rss_conf *conf, bool add); diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c index a32ad9b58..db708fb5b 100644 --- a/drivers/net/i40e/i40e_flow.c +++ b/drivers/net/i40e/i40e_flow.c @@ -4207,7 +4207,7 @@ i40e_flow_parse_rss_action(struct rte_eth_dev *dev, if (action_flag) { for (n = 0; n < 64; n++) { - if (rss->rss_conf->rss_hf & (hf_bit << n)) { + if (rss->types & (hf_bit << n)) { conf_info->region[0].hw_flowtype[0] = n; conf_info->region[0].flowtype_num = 1; conf_info->queue_region_number = 1; @@ -4217,12 +4217,12 @@ i40e_flow_parse_rss_action(struct rte_eth_dev *dev, } if (conf_info->queue_region_number) { - for (i = 0; i < rss->num; i++) { - for (j = 0; j < rss_info->num; j++) { - if (rss->queue[i] == rss_info->queue[j]) + for (i = 0; i < rss->queue_num; i++) { + for (j = 0; j < rss_info->conf.queue_num; j++) { + if (rss->queue[i] == rss_info->conf.queue[j]) break; } - if (j == rss_info->num) { + if (j == rss_info->conf.queue_num) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, act, @@ -4231,7 +4231,7 @@ i40e_flow_parse_rss_action(struct rte_eth_dev *dev, } } - for (i = 0; i < rss->num - 1; i++) { + for (i = 0; i < rss->queue_num - 1; i++) { if (rss->queue[i + 1] != rss->queue[i] + 1) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, @@ -4245,8 +4245,8 @@ i40e_flow_parse_rss_action(struct rte_eth_dev *dev, for (n = 0; n < conf_info->queue_region_number; n++) { if (conf_info->region[n].user_priority_num || conf_info->region[n].flowtype_num) { - if (!((rte_is_power_of_2(rss->num)) && - rss->num <= 64)) { + if (!((rte_is_power_of_2(rss->queue_num)) && + rss->queue_num <= 64)) { PMD_DRV_LOG(ERR, "The region sizes should be any of the following values: 1, 2, 4, 8, 16, 32, 64 as long as the " "total number of queues do not exceed the VSI allocation"); return -rte_errno; @@ -4264,10 +4264,11 @@ i40e_flow_parse_rss_action(struct rte_eth_dev *dev, return -rte_errno; } - if (rss_info->num < rss->num || - rss->queue[0] < rss_info->queue[0] || - (rss->queue[0] + rss->num > - rss_info->num + rss_info->queue[0])) { + if (rss_info->conf.queue_num < rss->queue_num || + rss->queue[0] < rss_info->conf.queue[0] || + (rss->queue[0] + rss->queue_num > + rss_info->conf.queue_num + + rss_info->conf.queue[0])) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, act, @@ -4276,7 +4277,8 @@ i40e_flow_parse_rss_action(struct rte_eth_dev *dev, } for (i = 0; i < info->queue_region_number; i++) { - if (info->region[i].queue_num == rss->num && + if (info->region[i].queue_num == + rss->queue_num && info->region[i].queue_start_index == rss->queue[0]) break; @@ -4289,7 +4291,7 @@ i40e_flow_parse_rss_action(struct rte_eth_dev *dev, } info->region[i].queue_num = - rss->num; + rss->queue_num; info->region[i].queue_start_index = rss->queue[0]; info->region[i].region_id = @@ -4332,7 +4334,7 @@ i40e_flow_parse_rss_action(struct rte_eth_dev *dev, if (rss_config->queue_region_conf) return 0; - if (!rss || !rss->num) { + if (!rss || !rss->queue_num) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, act, @@ -4340,7 +4342,7 @@ i40e_flow_parse_rss_action(struct rte_eth_dev *dev, return -rte_errno; } - for (n = 0; n < rss->num; n++) { + for (n = 0; n < rss->queue_num; n++) { if (rss->queue[n] >= dev->data->nb_rx_queues) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, @@ -4349,15 +4351,20 @@ i40e_flow_parse_rss_action(struct rte_eth_dev *dev, return -rte_errno; } } - if (rss->rss_conf) - rss_config->rss_conf = *rss->rss_conf; - else - rss_config->rss_conf.rss_hf = - pf->adapter->flow_types_mask; - for (n = 0; n < rss->num; ++n) - rss_config->queue[n] = rss->queue[n]; - rss_config->num = rss->num; + if (rss->key_len && rss->key_len > RTE_DIM(rss_config->key)) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, + "RSS hash key too large"); + if (rss->queue_num > RTE_DIM(rss_config->queue)) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, + "too many queues for RSS context"); + if (i40e_rss_conf_init(rss_config, rss)) + return rte_flow_error_set + (error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, act, + "RSS context initialization failure"); + index++; /* check if the next not void action is END */ @@ -4877,7 +4884,7 @@ i40e_flow_flush_rss_filter(struct rte_eth_dev *dev) ret = i40e_flush_queue_region_all_conf(dev, hw, pf, 0); - if (rss_info->num) + if (rss_info->conf.queue_num) ret = i40e_config_rss_filter(pf, rss_info, FALSE); return ret; } diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c index 752a17af0..ea3624ba4 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.c +++ b/drivers/net/ixgbe/ixgbe_ethdev.c @@ -100,8 +100,6 @@ #define IXGBE_QUEUE_STAT_COUNTERS (sizeof(hw_stats->qprc) / sizeof(hw_stats->qprc[0])) -#define IXGBE_HKEY_MAX_INDEX 10 - /* Additional timesync values. */ #define NSEC_PER_SEC 1000000000L #define IXGBE_INCVAL_10GB 0x66666666 @@ -8276,7 +8274,7 @@ ixgbe_rss_filter_restore(struct rte_eth_dev *dev) struct ixgbe_filter_info *filter_info = IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private); - if (filter_info->rss_info.num) + if (filter_info->rss_info.conf.queue_num) ixgbe_config_rss_filter(dev, &filter_info->rss_info, TRUE); } diff --git a/drivers/net/ixgbe/ixgbe_ethdev.h b/drivers/net/ixgbe/ixgbe_ethdev.h index 655077700..9491b03f4 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.h +++ b/drivers/net/ixgbe/ixgbe_ethdev.h @@ -4,6 +4,9 @@ #ifndef _IXGBE_ETHDEV_H_ #define _IXGBE_ETHDEV_H_ + +#include <stdint.h> + #include "base/ixgbe_type.h" #include "base/ixgbe_dcb.h" #include "base/ixgbe_dcb_82599.h" @@ -12,6 +15,7 @@ #ifdef RTE_LIBRTE_SECURITY #include "ixgbe_ipsec.h" #endif +#include <rte_flow.h> #include <rte_time.h> #include <rte_hash.h> #include <rte_pci.h> @@ -39,6 +43,7 @@ #define IXGBE_EXTENDED_VLAN (uint32_t)(1 << 26) /* EXTENDED VLAN ENABLE */ #define IXGBE_VFTA_SIZE 128 #define IXGBE_VLAN_TAG_SIZE 4 +#define IXGBE_HKEY_MAX_INDEX 10 #define IXGBE_MAX_RX_QUEUE_NUM 128 #define IXGBE_MAX_INTR_QUEUE_NUM 15 #define IXGBE_VMDQ_DCB_NB_QUEUES IXGBE_MAX_RX_QUEUE_NUM @@ -196,8 +201,8 @@ struct ixgbe_hw_fdir_info { }; struct ixgbe_rte_flow_rss_conf { - struct rte_eth_rss_conf rss_conf; /**< RSS parameters. */ - uint16_t num; /**< Number of entries in queue[]. */ + struct rte_flow_action_rss conf; /**< RSS parameters. */ + uint8_t key[IXGBE_HKEY_MAX_INDEX * sizeof(uint32_t)]; /* Hash key. */ uint16_t queue[IXGBE_MAX_RX_QUEUE_NUM]; /**< Queues indices to use. */ }; @@ -696,6 +701,10 @@ void ixgbe_tm_conf_init(struct rte_eth_dev *dev); void ixgbe_tm_conf_uninit(struct rte_eth_dev *dev); int ixgbe_set_queue_rate_limit(struct rte_eth_dev *dev, uint16_t queue_idx, uint16_t tx_rate); +int ixgbe_rss_conf_init(struct ixgbe_rte_flow_rss_conf *out, + const struct rte_flow_action_rss *in); +int ixgbe_action_rss_same(const struct rte_flow_action_rss *comp, + const struct rte_flow_action_rss *with); int ixgbe_config_rss_filter(struct rte_eth_dev *dev, struct ixgbe_rte_flow_rss_conf *conf, bool add); diff --git a/drivers/net/ixgbe/ixgbe_flow.c b/drivers/net/ixgbe/ixgbe_flow.c index abdeac28b..4e31c7c56 100644 --- a/drivers/net/ixgbe/ixgbe_flow.c +++ b/drivers/net/ixgbe/ixgbe_flow.c @@ -2761,7 +2761,7 @@ ixgbe_parse_rss_filter(struct rte_eth_dev *dev, rss = (const struct rte_flow_action_rss *)act->conf; - if (!rss || !rss->num) { + if (!rss || !rss->queue_num) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, act, @@ -2769,7 +2769,7 @@ ixgbe_parse_rss_filter(struct rte_eth_dev *dev, return -rte_errno; } - for (n = 0; n < rss->num; n++) { + for (n = 0; n < rss->queue_num; n++) { if (rss->queue[n] >= dev->data->nb_rx_queues) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, @@ -2778,14 +2778,19 @@ ixgbe_parse_rss_filter(struct rte_eth_dev *dev, return -rte_errno; } } - if (rss->rss_conf) - rss_conf->rss_conf = *rss->rss_conf; - else - rss_conf->rss_conf.rss_hf = IXGBE_RSS_OFFLOAD_ALL; - for (n = 0; n < rss->num; ++n) - rss_conf->queue[n] = rss->queue[n]; - rss_conf->num = rss->num; + if (rss->key_len && rss->key_len != RTE_DIM(rss_conf->key)) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, + "RSS hash key must be exactly 40 bytes"); + if (rss->queue_num > RTE_DIM(rss_conf->queue)) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, + "too many queues for RSS context"); + if (ixgbe_rss_conf_init(rss_conf, rss)) + return rte_flow_error_set + (error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, act, + "RSS context initialization failure"); /* check if the next not void item is END */ act = next_no_void_action(actions, act); @@ -2834,7 +2839,7 @@ ixgbe_clear_rss_filter(struct rte_eth_dev *dev) struct ixgbe_filter_info *filter_info = IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private); - if (filter_info->rss_info.num) + if (filter_info->rss_info.conf.queue_num) ixgbe_config_rss_filter(dev, &filter_info->rss_info, FALSE); } @@ -3153,9 +3158,8 @@ ixgbe_flow_create(struct rte_eth_dev *dev, PMD_DRV_LOG(ERR, "failed to allocate memory"); goto out; } - rte_memcpy(&rss_filter_ptr->filter_info, - &rss_conf, - sizeof(struct ixgbe_rte_flow_rss_conf)); + ixgbe_rss_conf_init(&rss_filter_ptr->filter_info, + &rss_conf.conf); TAILQ_INSERT_TAIL(&filter_rss_list, rss_filter_ptr, entries); flow->rule = rss_filter_ptr; diff --git a/drivers/net/ixgbe/ixgbe_rxtx.c b/drivers/net/ixgbe/ixgbe_rxtx.c index 7511e183f..94ea7444d 100644 --- a/drivers/net/ixgbe/ixgbe_rxtx.c +++ b/drivers/net/ixgbe/ixgbe_rxtx.c @@ -5675,6 +5675,36 @@ ixgbevf_dev_rxtx_start(struct rte_eth_dev *dev) } int +ixgbe_rss_conf_init(struct ixgbe_rte_flow_rss_conf *out, + const struct rte_flow_action_rss *in) +{ + if (in->key_len > RTE_DIM(out->key) || + in->queue_num > RTE_DIM(out->queue)) + return -EINVAL; + out->conf = (struct rte_flow_action_rss){ + .types = in->types, + .key_len = in->key_len, + .queue_num = in->queue_num, + .key = memcpy(out->key, in->key, in->key_len), + .queue = memcpy(out->queue, in->queue, + sizeof(*in->queue) * in->queue_num), + }; + return 0; +} + +int +ixgbe_action_rss_same(const struct rte_flow_action_rss *comp, + const struct rte_flow_action_rss *with) +{ + return (comp->types == with->types && + comp->key_len == with->key_len && + comp->queue_num == with->queue_num && + !memcmp(comp->key, with->key, with->key_len) && + !memcmp(comp->queue, with->queue, + sizeof(*with->queue) * with->queue_num)); +} + +int ixgbe_config_rss_filter(struct rte_eth_dev *dev, struct ixgbe_rte_flow_rss_conf *conf, bool add) { @@ -5684,7 +5714,12 @@ ixgbe_config_rss_filter(struct rte_eth_dev *dev, uint16_t j; uint16_t sp_reta_size; uint32_t reta_reg; - struct rte_eth_rss_conf rss_conf = conf->rss_conf; + struct rte_eth_rss_conf rss_conf = { + .rss_key = conf->conf.key_len ? + (void *)(uintptr_t)conf->conf.key : NULL, + .rss_key_len = conf->conf.key_len, + .rss_hf = conf->conf.types, + }; struct ixgbe_filter_info *filter_info = IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private); @@ -5694,8 +5729,8 @@ ixgbe_config_rss_filter(struct rte_eth_dev *dev, sp_reta_size = ixgbe_reta_size_get(hw->mac.type); if (!add) { - if (memcmp(conf, &filter_info->rss_info, - sizeof(struct ixgbe_rte_flow_rss_conf)) == 0) { + if (ixgbe_action_rss_same(&filter_info->rss_info.conf, + &conf->conf)) { ixgbe_rss_disable(dev); memset(&filter_info->rss_info, 0, sizeof(struct ixgbe_rte_flow_rss_conf)); @@ -5704,7 +5739,7 @@ ixgbe_config_rss_filter(struct rte_eth_dev *dev, return -EINVAL; } - if (filter_info->rss_info.num) + if (filter_info->rss_info.conf.queue_num) return -EINVAL; /* Fill in redirection table * The byte-swap is needed because NIC registers are in @@ -5714,9 +5749,9 @@ ixgbe_config_rss_filter(struct rte_eth_dev *dev, for (i = 0, j = 0; i < sp_reta_size; i++, j++) { reta_reg = ixgbe_reta_reg_get(hw->mac.type, i); - if (j == conf->num) + if (j == conf->conf.queue_num) j = 0; - reta = (reta << 8) | conf->queue[j]; + reta = (reta << 8) | conf->conf.queue[j]; if ((i & 3) == 3) IXGBE_WRITE_REG(hw, reta_reg, rte_bswap32(reta)); @@ -5733,8 +5768,8 @@ ixgbe_config_rss_filter(struct rte_eth_dev *dev, rss_conf.rss_key = rss_intel_key; /* Default hash key */ ixgbe_hw_rss_hash_set(hw, &rss_conf); - rte_memcpy(&filter_info->rss_info, - conf, sizeof(struct ixgbe_rte_flow_rss_conf)); + if (ixgbe_rss_conf_init(&filter_info->rss_info, &conf->conf)) + return -EINVAL; return 0; } diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c index fb8a8b848..c7854bead 100644 --- a/drivers/net/mlx4/mlx4.c +++ b/drivers/net/mlx4/mlx4.c @@ -569,7 +569,7 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev) " for UDP RSS and inner VXLAN RSS"); /* Fake support for all possible RSS hash fields. */ priv->hw_rss_sup = ~UINT64_C(0); - priv->hw_rss_sup = mlx4_conv_rss_hf(priv, -1); + priv->hw_rss_sup = mlx4_conv_rss_types(priv, -1); /* Filter out known unsupported fields. */ priv->hw_rss_sup &= ~(uint64_t)(IBV_RX_HASH_SRC_PORT_UDP | diff --git a/drivers/net/mlx4/mlx4_flow.c b/drivers/net/mlx4/mlx4_flow.c index 5a1b7dedd..4dbcaa39c 100644 --- a/drivers/net/mlx4/mlx4_flow.c +++ b/drivers/net/mlx4/mlx4_flow.c @@ -76,22 +76,22 @@ struct mlx4_drop { }; /** - * Convert DPDK RSS hash fields to their Verbs equivalent. + * Convert DPDK RSS hash types to their Verbs equivalent. * - * This function returns the supported (default) set when @p rss_hf has + * This function returns the supported (default) set when @p types has * special value (uint64_t)-1. * * @param priv * Pointer to private structure. - * @param rss_hf - * Hash fields in DPDK format (see struct rte_eth_rss_conf). + * @param types + * Hash types in DPDK format (see struct rte_eth_rss_conf). * * @return * A valid Verbs RSS hash fields mask for mlx4 on success, (uint64_t)-1 * otherwise and rte_errno is set. */ uint64_t -mlx4_conv_rss_hf(struct priv *priv, uint64_t rss_hf) +mlx4_conv_rss_types(struct priv *priv, uint64_t types) { enum { IPV4, IPV6, TCP, UDP, }; const uint64_t in[] = { @@ -126,17 +126,17 @@ mlx4_conv_rss_hf(struct priv *priv, uint64_t rss_hf) unsigned int i; for (i = 0; i != RTE_DIM(in); ++i) - if (rss_hf & in[i]) { - seen |= rss_hf & in[i]; + if (types & in[i]) { + seen |= types & in[i]; conv |= out[i]; } if ((conv & priv->hw_rss_sup) == conv) { - if (rss_hf == (uint64_t)-1) { + if (types == (uint64_t)-1) { /* Include inner RSS by default if supported. */ conv |= priv->hw_rss_sup & IBV_RX_HASH_INNER; return conv; } - if (!(rss_hf & ~seen)) + if (!(types & ~seen)) return conv; } rte_errno = ENOTSUP; @@ -717,7 +717,8 @@ mlx4_flow_prepare(struct priv *priv, switch (action->type) { const struct rte_flow_action_queue *queue; const struct rte_flow_action_rss *rss; - const struct rte_eth_rss_conf *rss_conf; + const uint8_t *rss_key; + uint32_t rss_key_len; uint64_t fields; unsigned int i; @@ -747,58 +748,56 @@ mlx4_flow_prepare(struct priv *priv, break; rss = action->conf; /* Default RSS configuration if none is provided. */ - rss_conf = - rss->rss_conf ? - rss->rss_conf : - &(struct rte_eth_rss_conf){ - .rss_key = mlx4_rss_hash_key_default, - .rss_key_len = MLX4_RSS_HASH_KEY_SIZE, - .rss_hf = -1, - }; + if (rss->key_len) { + rss_key = rss->key; + rss_key_len = rss->key_len; + } else { + rss_key = mlx4_rss_hash_key_default; + rss_key_len = MLX4_RSS_HASH_KEY_SIZE; + } /* Sanity checks. */ - for (i = 0; i < rss->num; ++i) + for (i = 0; i < rss->queue_num; ++i) if (rss->queue[i] >= priv->dev->data->nb_rx_queues) break; - if (i != rss->num) { + if (i != rss->queue_num) { msg = "queue index target beyond number of" " configured Rx queues"; goto exit_action_not_supported; } - if (!rte_is_power_of_2(rss->num)) { + if (!rte_is_power_of_2(rss->queue_num)) { msg = "for RSS, mlx4 requires the number of" " queues to be a power of two"; goto exit_action_not_supported; } - if (rss_conf->rss_key_len != - sizeof(flow->rss->key)) { + if (rss_key_len != sizeof(flow->rss->key)) { msg = "mlx4 supports exactly one RSS hash key" " length: " MLX4_STR_EXPAND(MLX4_RSS_HASH_KEY_SIZE); goto exit_action_not_supported; } - for (i = 1; i < rss->num; ++i) + for (i = 1; i < rss->queue_num; ++i) if (rss->queue[i] - rss->queue[i - 1] != 1) break; - if (i != rss->num) { + if (i != rss->queue_num) { msg = "mlx4 requires RSS contexts to use" " consecutive queue indices only"; goto exit_action_not_supported; } - if (rss->queue[0] % rss->num) { + if (rss->queue[0] % rss->queue_num) { msg = "mlx4 requires the first queue of a RSS" " context to be aligned on a multiple" " of the context size"; goto exit_action_not_supported; } rte_errno = 0; - fields = mlx4_conv_rss_hf(priv, rss_conf->rss_hf); + fields = mlx4_conv_rss_types(priv, rss->types); if (fields == (uint64_t)-1 && rte_errno) { msg = "unsupported RSS hash type requested"; goto exit_action_not_supported; } flow->rss = mlx4_rss_get - (priv, fields, rss_conf->rss_key, rss->num, + (priv, fields, rss_key, rss->queue_num, rss->queue); if (!flow->rss) { msg = "either invalid parameters or not enough" @@ -1284,8 +1283,10 @@ mlx4_flow_internal(struct priv *priv, struct rte_flow_error *error) rte_align32pow2(priv->dev->data->nb_rx_queues + 1) >> 1; uint16_t queue[queues]; struct rte_flow_action_rss action_rss = { - .rss_conf = NULL, /* Rely on default fallback settings. */ - .num = queues, + .types = -1, + .key_len = MLX4_RSS_HASH_KEY_SIZE, + .queue_num = queues, + .key = mlx4_rss_hash_key_default, .queue = queue, }; struct rte_flow_action actions[] = { diff --git a/drivers/net/mlx4/mlx4_flow.h b/drivers/net/mlx4/mlx4_flow.h index 00188a65c..f71078ecc 100644 --- a/drivers/net/mlx4/mlx4_flow.h +++ b/drivers/net/mlx4/mlx4_flow.h @@ -47,7 +47,7 @@ struct rte_flow { /* mlx4_flow.c */ -uint64_t mlx4_conv_rss_hf(struct priv *priv, uint64_t rss_hf); +uint64_t mlx4_conv_rss_types(struct priv *priv, uint64_t rss_hf); int mlx4_flow_sync(struct priv *priv, struct rte_flow_error *error); void mlx4_flow_clean(struct priv *priv); int mlx4_filter_ctrl(struct rte_eth_dev *dev, diff --git a/drivers/net/mlx4/mlx4_rxq.c b/drivers/net/mlx4/mlx4_rxq.c index 7a036ed83..474614e4d 100644 --- a/drivers/net/mlx4/mlx4_rxq.c +++ b/drivers/net/mlx4/mlx4_rxq.c @@ -88,7 +88,7 @@ mlx4_rss_hash_key_default[MLX4_RSS_HASH_KEY_SIZE] = { */ struct mlx4_rss * mlx4_rss_get(struct priv *priv, uint64_t fields, - uint8_t key[MLX4_RSS_HASH_KEY_SIZE], + const uint8_t key[MLX4_RSS_HASH_KEY_SIZE], uint16_t queues, const uint16_t queue_id[]) { struct mlx4_rss *rss; diff --git a/drivers/net/mlx4/mlx4_rxtx.h b/drivers/net/mlx4/mlx4_rxtx.h index dd46ac006..521267724 100644 --- a/drivers/net/mlx4/mlx4_rxtx.h +++ b/drivers/net/mlx4/mlx4_rxtx.h @@ -126,7 +126,7 @@ uint8_t mlx4_rss_hash_key_default[MLX4_RSS_HASH_KEY_SIZE]; int mlx4_rss_init(struct priv *priv); void mlx4_rss_deinit(struct priv *priv); struct mlx4_rss *mlx4_rss_get(struct priv *priv, uint64_t fields, - uint8_t key[MLX4_RSS_HASH_KEY_SIZE], + const uint8_t key[MLX4_RSS_HASH_KEY_SIZE], uint16_t queues, const uint16_t queue_id[]); void mlx4_rss_put(struct mlx4_rss *rss); int mlx4_rss_attach(struct mlx4_rss *rss); diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index a52dcf263..7798052f9 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -214,9 +214,8 @@ struct rte_flow { TAILQ_ENTRY(rte_flow) next; /**< Pointer to the next flow structure. */ uint32_t mark:1; /**< Set if the flow is marked. */ uint32_t drop:1; /**< Drop queue. */ - uint16_t queues_n; /**< Number of entries in queue[]. */ + struct rte_flow_action_rss rss_conf; /**< RSS configuration */ uint16_t (*queues)[]; /**< Queues indexes to use. */ - struct rte_eth_rss_conf rss_conf; /**< RSS configuration */ uint8_t rss_key[40]; /**< copy of the RSS key. */ struct ibv_counter_set *cs; /**< Holds the counters for the rule. */ struct mlx5_flow_counter_stats counter_stats;/**<The counter stats. */ @@ -406,9 +405,8 @@ struct mlx5_flow_parse { uint32_t mark:1; /**< Mark is present in the flow. */ uint32_t count:1; /**< Count is present in the flow. */ uint32_t mark_id; /**< Mark identifier. */ + struct rte_flow_action_rss rss_conf; /**< RSS configuration */ uint16_t queues[RTE_MAX_QUEUES_PER_PORT]; /**< Queues indexes to use. */ - uint16_t queues_n; /**< Number of entries in queue[]. */ - struct rte_eth_rss_conf rss_conf; /**< RSS configuration */ uint8_t rss_key[40]; /**< copy of the RSS key. */ enum hash_rxq_type layer; /**< Last pattern layer detected. */ struct ibv_counter_set *cs; /**< Holds the counter set for the rule */ @@ -532,47 +530,6 @@ mlx5_flow_item_validate(const struct rte_flow_item *item, } /** - * Copy the RSS configuration from the user ones, of the rss_conf is null, - * uses the driver one. - * - * @param parser - * Internal parser structure. - * @param rss_conf - * User RSS configuration to save. - * - * @return - * 0 on success, a negative errno value otherwise and rte_errno is set. - */ -static int -mlx5_flow_convert_rss_conf(struct mlx5_flow_parse *parser, - const struct rte_eth_rss_conf *rss_conf) -{ - /* - * This function is also called at the beginning of - * mlx5_flow_convert_actions() to initialize the parser with the - * device default RSS configuration. - */ - if (rss_conf) { - if (rss_conf->rss_hf & MLX5_RSS_HF_MASK) { - rte_errno = EINVAL; - return -rte_errno; - } - if (rss_conf->rss_key_len != 40) { - rte_errno = EINVAL; - return -rte_errno; - } - if (rss_conf->rss_key_len && rss_conf->rss_key) { - parser->rss_conf.rss_key_len = rss_conf->rss_key_len; - memcpy(parser->rss_key, rss_conf->rss_key, - rss_conf->rss_key_len); - parser->rss_conf.rss_key = parser->rss_key; - } - parser->rss_conf.rss_hf = rss_conf->rss_hf; - } - return 0; -} - -/** * Extract attribute to the parser. * * @param[in] attr @@ -642,17 +599,7 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, enum { FATE = 1, MARK = 2, COUNT = 4, }; uint32_t overlap = 0; struct priv *priv = dev->data->dev_private; - int ret; - /* - * Add default RSS configuration necessary for Verbs to create QP even - * if no RSS is necessary. - */ - ret = mlx5_flow_convert_rss_conf(parser, - (const struct rte_eth_rss_conf *) - &priv->rss_conf); - if (ret) - return ret; for (; actions->type != RTE_FLOW_ACTION_TYPE_END; ++actions) { if (actions->type == RTE_FLOW_ACTION_TYPE_VOID) { continue; @@ -671,25 +618,53 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, overlap |= FATE; if (!queue || (queue->index > (priv->rxqs_n - 1))) goto exit_action_not_supported; - parser->queues_n = 1; parser->queues[0] = queue->index; + parser->rss_conf = (struct rte_flow_action_rss){ + .queue_num = 1, + .queue = parser->queues, + }; } else if (actions->type == RTE_FLOW_ACTION_TYPE_RSS) { const struct rte_flow_action_rss *rss = (const struct rte_flow_action_rss *) actions->conf; + const uint8_t *rss_key; + uint32_t rss_key_len; uint16_t n; if (overlap & FATE) goto exit_action_overlap; overlap |= FATE; - if (!rss || !rss->num) { + if (rss->types & MLX5_RSS_HF_MASK) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION, + actions, + "unsupported RSS type" + " requested"); + return -rte_errno; + } + if (rss->key_len) { + rss_key_len = rss->key_len; + rss_key = rss->key; + } else { + rss_key_len = rss_hash_default_key_len; + rss_key = rss_hash_default_key; + } + if (rss_key_len != RTE_DIM(parser->rss_key)) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION, + actions, + "RSS hash key must be" + " exactly 40 bytes long"); + return -rte_errno; + } + if (!rss->queue_num) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, actions, "no valid queues"); return -rte_errno; } - if (rss->num > RTE_DIM(parser->queues)) { + if (rss->queue_num > RTE_DIM(parser->queues)) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, actions, @@ -697,7 +672,7 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, " context"); return -rte_errno; } - for (n = 0; n < rss->num; ++n) { + for (n = 0; n < rss->queue_num; ++n) { if (rss->queue[n] >= priv->rxqs_n) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, @@ -707,16 +682,16 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, return -rte_errno; } } - for (n = 0; n < rss->num; ++n) - parser->queues[n] = rss->queue[n]; - parser->queues_n = rss->num; - if (mlx5_flow_convert_rss_conf(parser, rss->rss_conf)) { - rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ACTION, - actions, - "wrong RSS configuration"); - return -rte_errno; - } + parser->rss_conf = (struct rte_flow_action_rss){ + .types = rss->types, + .key_len = rss_key_len, + .queue_num = rss->queue_num, + .key = memcpy(parser->rss_key, rss_key, + sizeof(*rss_key) * rss_key_len), + .queue = memcpy(parser->queues, rss->queue, + sizeof(*rss->queue) * + rss->queue_num), + }; } else if (actions->type == RTE_FLOW_ACTION_TYPE_MARK) { const struct rte_flow_action_mark *mark = (const struct rte_flow_action_mark *) @@ -761,7 +736,7 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, parser->drop = 1; if (parser->drop && parser->mark) parser->mark = 0; - if (!parser->queues_n && !parser->drop) { + if (!parser->rss_conf.queue_num && !parser->drop) { rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_HANDLE, NULL, "no valid action"); return -rte_errno; @@ -941,7 +916,7 @@ mlx5_flow_convert_finalise(struct mlx5_flow_parse *parser) unsigned int i; /* Remove any other flow not matching the pattern. */ - if (parser->queues_n == 1 && !parser->rss_conf.rss_hf) { + if (parser->rss_conf.queue_num == 1 && !parser->rss_conf.types) { for (i = 0; i != hash_rxq_init_n; ++i) { if (i == HASH_RXQ_ETH) continue; @@ -969,7 +944,7 @@ mlx5_flow_convert_finalise(struct mlx5_flow_parse *parser) } /* Remove impossible flow according to the RSS configuration. */ if (hash_rxq_init[parser->layer].dpdk_rss_hf & - parser->rss_conf.rss_hf) { + parser->rss_conf.types) { /* Remove any other flow. */ for (i = hmin; i != (hmax + 1); ++i) { if ((i == parser->layer) || @@ -980,7 +955,7 @@ mlx5_flow_convert_finalise(struct mlx5_flow_parse *parser) } } else if (!parser->queue[ip].ibv_attr) { /* no RSS possible with the current configuration. */ - parser->queues_n = 1; + parser->rss_conf.queue_num = 1; return; } fill: @@ -1109,7 +1084,7 @@ mlx5_flow_convert(struct rte_eth_dev *dev, for (i = 0; i != hash_rxq_init_n; ++i) { unsigned int offset; - if (!(parser->rss_conf.rss_hf & + if (!(parser->rss_conf.types & hash_rxq_init[i].dpdk_rss_hf) && (i != HASH_RXQ_ETH)) continue; @@ -1777,20 +1752,20 @@ mlx5_flow_create_action_queue_rss(struct rte_eth_dev *dev, continue; flow->frxq[i].hrxq = mlx5_hrxq_get(dev, - parser->rss_conf.rss_key, - parser->rss_conf.rss_key_len, + parser->rss_conf.key, + parser->rss_conf.key_len, hash_fields, - parser->queues, - parser->queues_n); + parser->rss_conf.queue, + parser->rss_conf.queue_num); if (flow->frxq[i].hrxq) continue; flow->frxq[i].hrxq = mlx5_hrxq_new(dev, - parser->rss_conf.rss_key, - parser->rss_conf.rss_key_len, + parser->rss_conf.key, + parser->rss_conf.key_len, hash_fields, - parser->queues, - parser->queues_n); + parser->rss_conf.queue, + parser->rss_conf.queue_num); if (!flow->frxq[i].hrxq) { return rte_flow_error_set(error, ENOMEM, RTE_FLOW_ERROR_TYPE_HANDLE, @@ -1861,9 +1836,9 @@ mlx5_flow_create_action_queue(struct rte_eth_dev *dev, NULL, "internal error in flow creation"); goto error; } - for (i = 0; i != parser->queues_n; ++i) { + for (i = 0; i != parser->rss_conf.queue_num; ++i) { struct mlx5_rxq_data *q = - (*priv->rxqs)[parser->queues[i]]; + (*priv->rxqs)[parser->rss_conf.queue[i]]; q->mark |= parser->mark; } @@ -1927,7 +1902,8 @@ mlx5_flow_list_create(struct rte_eth_dev *dev, if (ret) goto exit; flow = rte_calloc(__func__, 1, - sizeof(*flow) + parser.queues_n * sizeof(uint16_t), + sizeof(*flow) + + parser.rss_conf.queue_num * sizeof(uint16_t), 0); if (!flow) { rte_flow_error_set(error, ENOMEM, @@ -1936,15 +1912,20 @@ mlx5_flow_list_create(struct rte_eth_dev *dev, "cannot allocate flow memory"); return NULL; } - /* Copy queues configuration. */ + /* Copy configuration. */ flow->queues = (uint16_t (*)[])(flow + 1); - memcpy(flow->queues, parser.queues, parser.queues_n * sizeof(uint16_t)); - flow->queues_n = parser.queues_n; + flow->rss_conf = (struct rte_flow_action_rss){ + .types = parser.rss_conf.types, + .key_len = parser.rss_conf.key_len, + .queue_num = parser.rss_conf.queue_num, + .key = memcpy(flow->rss_key, parser.rss_conf.key, + sizeof(*parser.rss_conf.key) * + parser.rss_conf.key_len), + .queue = memcpy(flow->queues, parser.rss_conf.queue, + sizeof(*parser.rss_conf.queue) * + parser.rss_conf.queue_num), + }; flow->mark = parser.mark; - /* Copy RSS configuration. */ - flow->rss_conf = parser.rss_conf; - flow->rss_conf.rss_key = flow->rss_key; - memcpy(flow->rss_key, parser.rss_key, parser.rss_conf.rss_key_len); /* finalise the flow. */ if (parser.drop) ret = mlx5_flow_create_action_queue_drop(dev, &parser, flow, @@ -2024,7 +2005,7 @@ mlx5_flow_list_destroy(struct rte_eth_dev *dev, struct mlx5_flows *list, if (flow->drop || !flow->mark) goto free; - for (i = 0; i != flow->queues_n; ++i) { + for (i = 0; i != flow->rss_conf.queue_num; ++i) { struct rte_flow *tmp; int mark = 0; @@ -2334,19 +2315,19 @@ mlx5_flow_start(struct rte_eth_dev *dev, struct mlx5_flows *list) if (!flow->frxq[i].ibv_attr) continue; flow->frxq[i].hrxq = - mlx5_hrxq_get(dev, flow->rss_conf.rss_key, - flow->rss_conf.rss_key_len, + mlx5_hrxq_get(dev, flow->rss_conf.key, + flow->rss_conf.key_len, hash_rxq_init[i].hash_fields, - (*flow->queues), - flow->queues_n); + flow->rss_conf.queue, + flow->rss_conf.queue_num); if (flow->frxq[i].hrxq) goto flow_create; flow->frxq[i].hrxq = - mlx5_hrxq_new(dev, flow->rss_conf.rss_key, - flow->rss_conf.rss_key_len, + mlx5_hrxq_new(dev, flow->rss_conf.key, + flow->rss_conf.key_len, hash_rxq_init[i].hash_fields, - (*flow->queues), - flow->queues_n); + flow->rss_conf.queue, + flow->rss_conf.queue_num); if (!flow->frxq[i].hrxq) { DRV_LOG(DEBUG, "port %u flow %p cannot be applied", @@ -2370,8 +2351,8 @@ mlx5_flow_start(struct rte_eth_dev *dev, struct mlx5_flows *list) } if (!flow->mark) continue; - for (i = 0; i != flow->queues_n; ++i) - (*priv->rxqs)[(*flow->queues)[i]]->mark = 1; + for (i = 0; i != flow->rss_conf.queue_num; ++i) + (*priv->rxqs)[flow->rss_conf.queue[i]]->mark = 1; } return 0; } @@ -2448,8 +2429,10 @@ mlx5_ctrl_flow_vlan(struct rte_eth_dev *dev, }; uint16_t queue[priv->reta_idx_n]; struct rte_flow_action_rss action_rss = { - .rss_conf = &priv->rss_conf, - .num = priv->reta_idx_n, + .types = priv->rss_conf.rss_hf, + .key_len = priv->rss_conf.rss_key_len, + .queue_num = priv->reta_idx_n, + .key = priv->rss_conf.rss_key, .queue = queue, }; struct rte_flow_action actions[] = { diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c index 1b4570586..1e4354ab3 100644 --- a/drivers/net/mlx5/mlx5_rxq.c +++ b/drivers/net/mlx5/mlx5_rxq.c @@ -1218,8 +1218,8 @@ mlx5_rxq_verify(struct rte_eth_dev *dev) * The Verbs object initialised, NULL otherwise and rte_errno is set. */ struct mlx5_ind_table_ibv * -mlx5_ind_table_ibv_new(struct rte_eth_dev *dev, uint16_t queues[], - uint16_t queues_n) +mlx5_ind_table_ibv_new(struct rte_eth_dev *dev, const uint16_t *queues, + uint32_t queues_n) { struct priv *priv = dev->data->dev_private; struct mlx5_ind_table_ibv *ind_tbl; @@ -1286,8 +1286,8 @@ mlx5_ind_table_ibv_new(struct rte_eth_dev *dev, uint16_t queues[], * An indirection table if found. */ struct mlx5_ind_table_ibv * -mlx5_ind_table_ibv_get(struct rte_eth_dev *dev, uint16_t queues[], - uint16_t queues_n) +mlx5_ind_table_ibv_get(struct rte_eth_dev *dev, const uint16_t *queues, + uint32_t queues_n) { struct priv *priv = dev->data->dev_private; struct mlx5_ind_table_ibv *ind_tbl; @@ -1391,8 +1391,10 @@ mlx5_ind_table_ibv_verify(struct rte_eth_dev *dev) * The Verbs object initialised, NULL otherwise and rte_errno is set. */ struct mlx5_hrxq * -mlx5_hrxq_new(struct rte_eth_dev *dev, uint8_t *rss_key, uint8_t rss_key_len, - uint64_t hash_fields, uint16_t queues[], uint16_t queues_n) +mlx5_hrxq_new(struct rte_eth_dev *dev, + const uint8_t *rss_key, uint32_t rss_key_len, + uint64_t hash_fields, + const uint16_t *queues, uint32_t queues_n) { struct priv *priv = dev->data->dev_private; struct mlx5_hrxq *hrxq; @@ -1419,7 +1421,7 @@ mlx5_hrxq_new(struct rte_eth_dev *dev, uint8_t *rss_key, uint8_t rss_key_len, .rx_hash_conf = (struct ibv_rx_hash_conf){ .rx_hash_function = IBV_RX_HASH_FUNC_TOEPLITZ, .rx_hash_key_len = rss_key_len, - .rx_hash_key = rss_key, + .rx_hash_key = (void *)(uintptr_t)rss_key, .rx_hash_fields_mask = hash_fields, }, .rwq_ind_tbl = ind_tbl->ind_table, @@ -1469,8 +1471,10 @@ mlx5_hrxq_new(struct rte_eth_dev *dev, uint8_t *rss_key, uint8_t rss_key_len, * An hash Rx queue on success. */ struct mlx5_hrxq * -mlx5_hrxq_get(struct rte_eth_dev *dev, uint8_t *rss_key, uint8_t rss_key_len, - uint64_t hash_fields, uint16_t queues[], uint16_t queues_n) +mlx5_hrxq_get(struct rte_eth_dev *dev, + const uint8_t *rss_key, uint32_t rss_key_len, + uint64_t hash_fields, + const uint16_t *queues, uint32_t queues_n) { struct priv *priv = dev->data->dev_private; struct mlx5_hrxq *hrxq; diff --git a/drivers/net/mlx5/mlx5_rxtx.h b/drivers/net/mlx5/mlx5_rxtx.h index f5af43735..a702cb603 100644 --- a/drivers/net/mlx5/mlx5_rxtx.h +++ b/drivers/net/mlx5/mlx5_rxtx.h @@ -134,7 +134,7 @@ struct mlx5_ind_table_ibv { LIST_ENTRY(mlx5_ind_table_ibv) next; /* Pointer to the next element. */ rte_atomic32_t refcnt; /* Reference counter. */ struct ibv_rwq_ind_table *ind_table; /**< Indirection table. */ - uint16_t queues_n; /**< Number of queues in the list. */ + uint32_t queues_n; /**< Number of queues in the list. */ uint16_t queues[]; /**< Queue list. */ }; @@ -145,7 +145,7 @@ struct mlx5_hrxq { struct mlx5_ind_table_ibv *ind_table; /* Indirection table. */ struct ibv_qp *qp; /* Verbs queue pair. */ uint64_t hash_fields; /* Verbs Hash fields. */ - uint8_t rss_key_len; /* Hash key length in bytes. */ + uint32_t rss_key_len; /* Hash key length in bytes. */ uint8_t rss_key[]; /* Hash key. */ }; @@ -237,20 +237,22 @@ int mlx5_rxq_releasable(struct rte_eth_dev *dev, uint16_t idx); int mlx5_rxq_verify(struct rte_eth_dev *dev); int rxq_alloc_elts(struct mlx5_rxq_ctrl *rxq_ctrl); struct mlx5_ind_table_ibv *mlx5_ind_table_ibv_new(struct rte_eth_dev *dev, - uint16_t queues[], - uint16_t queues_n); + const uint16_t *queues, + uint32_t queues_n); struct mlx5_ind_table_ibv *mlx5_ind_table_ibv_get(struct rte_eth_dev *dev, - uint16_t queues[], - uint16_t queues_n); + const uint16_t *queues, + uint32_t queues_n); int mlx5_ind_table_ibv_release(struct rte_eth_dev *dev, struct mlx5_ind_table_ibv *ind_tbl); int mlx5_ind_table_ibv_verify(struct rte_eth_dev *dev); -struct mlx5_hrxq *mlx5_hrxq_new(struct rte_eth_dev *dev, uint8_t *rss_key, - uint8_t rss_key_len, uint64_t hash_fields, - uint16_t queues[], uint16_t queues_n); -struct mlx5_hrxq *mlx5_hrxq_get(struct rte_eth_dev *dev, uint8_t *rss_key, - uint8_t rss_key_len, uint64_t hash_fields, - uint16_t queues[], uint16_t queues_n); +struct mlx5_hrxq *mlx5_hrxq_new(struct rte_eth_dev *dev, + const uint8_t *rss_key, uint32_t rss_key_len, + uint64_t hash_fields, + const uint16_t *queues, uint32_t queues_n); +struct mlx5_hrxq *mlx5_hrxq_get(struct rte_eth_dev *dev, + const uint8_t *rss_key, uint32_t rss_key_len, + uint64_t hash_fields, + const uint16_t *queues, uint32_t queues_n); int mlx5_hrxq_release(struct rte_eth_dev *dev, struct mlx5_hrxq *hxrq); int mlx5_hrxq_ibv_verify(struct rte_eth_dev *dev); uint64_t mlx5_get_rx_port_offloads(void); diff --git a/drivers/net/sfc/sfc_flow.c b/drivers/net/sfc/sfc_flow.c index 056405515..1a2c0299c 100644 --- a/drivers/net/sfc/sfc_flow.c +++ b/drivers/net/sfc/sfc_flow.c @@ -1234,13 +1234,11 @@ sfc_flow_parse_rss(struct sfc_adapter *sa, struct sfc_rxq *rxq; unsigned int rxq_hw_index_min; unsigned int rxq_hw_index_max; - const struct rte_eth_rss_conf *rss_conf = rss->rss_conf; - uint64_t rss_hf; - uint8_t *rss_key = NULL; + const uint8_t *rss_key; struct sfc_flow_rss *sfc_rss_conf = &flow->rss_conf; unsigned int i; - if (rss->num == 0) + if (rss->queue_num == 0) return -EINVAL; rxq_sw_index = sa->rxq_count - 1; @@ -1248,7 +1246,7 @@ sfc_flow_parse_rss(struct sfc_adapter *sa, rxq_hw_index_min = rxq->hw_index; rxq_hw_index_max = 0; - for (i = 0; i < rss->num; ++i) { + for (i = 0; i < rss->queue_num; ++i) { rxq_sw_index = rss->queue[i]; if (rxq_sw_index >= sa->rxq_count) @@ -1263,15 +1261,14 @@ sfc_flow_parse_rss(struct sfc_adapter *sa, rxq_hw_index_max = rxq->hw_index; } - rss_hf = (rss_conf != NULL) ? rss_conf->rss_hf : SFC_RSS_OFFLOADS; - if ((rss_hf & ~SFC_RSS_OFFLOADS) != 0) + if ((rss->types & ~SFC_RSS_OFFLOADS) != 0) return -EINVAL; - if (rss_conf != NULL) { - if (rss_conf->rss_key_len != sizeof(sa->rss_key)) + if (rss->key_len) { + if (rss->key_len != sizeof(sa->rss_key)) return -EINVAL; - rss_key = rss_conf->rss_key; + rss_key = rss->key; } else { rss_key = sa->rss_key; } @@ -1280,11 +1277,11 @@ sfc_flow_parse_rss(struct sfc_adapter *sa, sfc_rss_conf->rxq_hw_index_min = rxq_hw_index_min; sfc_rss_conf->rxq_hw_index_max = rxq_hw_index_max; - sfc_rss_conf->rss_hash_types = sfc_rte_to_efx_hash_type(rss_hf); + sfc_rss_conf->rss_hash_types = sfc_rte_to_efx_hash_type(rss->types); rte_memcpy(sfc_rss_conf->rss_key, rss_key, sizeof(sa->rss_key)); for (i = 0; i < RTE_DIM(sfc_rss_conf->rss_tbl); ++i) { - unsigned int rxq_sw_index = rss->queue[i % rss->num]; + unsigned int rxq_sw_index = rss->queue[i % rss->queue_num]; struct sfc_rxq *rxq = sa->rxq_info[rxq_sw_index].rxq; sfc_rss_conf->rss_tbl[i] = rxq->hw_index - rxq_hw_index_min; diff --git a/drivers/net/tap/tap_flow.c b/drivers/net/tap/tap_flow.c index aea3462a6..78f20913f 100644 --- a/drivers/net/tap/tap_flow.c +++ b/drivers/net/tap/tap_flow.c @@ -1215,7 +1215,7 @@ priv_flow_process(struct pmd_internals *pmd, if (err) goto exit_action_not_supported; } - if (flow && rss) + if (flow) err = rss_add_actions(flow, pmd, rss, error); } else { goto exit_action_not_supported; @@ -2050,7 +2050,7 @@ static int rss_add_actions(struct rte_flow *flow, struct pmd_internals *pmd, struct rte_flow_error *error) { /* 4096 is the maximum number of instructions for a BPF program */ - int i; + unsigned int i; int err; struct rss_key rss_entry = { .hash_fields = 0, .key_size = 0 }; @@ -2066,8 +2066,8 @@ static int rss_add_actions(struct rte_flow *flow, struct pmd_internals *pmd, } /* Update RSS map entry with queues */ - rss_entry.nb_queues = rss->num; - for (i = 0; i < rss->num; i++) + rss_entry.nb_queues = rss->queue_num; + for (i = 0; i < rss->queue_num; i++) rss_entry.queues[i] = rss->queue[i]; rss_entry.hash_fields = (1 << HASH_FIELD_IPV4_L3_L4) | (1 << HASH_FIELD_IPV6_L3_L4); diff --git a/examples/ipsec-secgw/ipsec.c b/examples/ipsec-secgw/ipsec.c index 8b2047adb..3ce76c413 100644 --- a/examples/ipsec-secgw/ipsec.c +++ b/examples/ipsec-secgw/ipsec.c @@ -202,9 +202,13 @@ create_session(struct ipsec_ctx *ipsec_ctx, struct ipsec_sa *sa) i < eth_dev->data->nb_rx_queues; ++i) if (eth_dev->data->rx_queues[i]) queue[j++] = i; - action_rss.rss_conf = &rss_conf; - action_rss.num = j; - action_rss.queue = queue; + action_rss = (struct rte_flow_action_rss){ + .types = rss_conf.rss_hf, + .key_len = rss_conf.rss_key_len, + .queue_num = j, + .key = rss_key, + .queue = queue, + }; ret = rte_flow_validate(sa->portid, &sa->attr, sa->pattern, sa->action, &err); diff --git a/lib/librte_ether/rte_flow.c b/lib/librte_ether/rte_flow.c index 550086411..2fabc9a29 100644 --- a/lib/librte_ether/rte_flow.c +++ b/lib/librte_ether/rte_flow.c @@ -330,40 +330,27 @@ flow_action_conf_copy(void *buf, const struct rte_flow_action *action) off = 0; if (dst.rss) *dst.rss = (struct rte_flow_action_rss){ - .num = src.rss->num, + .types = src.rss->types, + .key_len = src.rss->key_len, + .queue_num = src.rss->queue_num, }; off += sizeof(*src.rss); - if (src.rss->num) { + if (src.rss->key_len) { off = RTE_ALIGN_CEIL(off, sizeof(double)); - size = sizeof(*src.rss->queue) * src.rss->num; + size = sizeof(*src.rss->key) * src.rss->key_len; if (dst.rss) - dst.rss->queue = memcpy + dst.rss->key = memcpy ((void *)((uintptr_t)dst.rss + off), - src.rss->queue, size); + src.rss->key, size); off += size; } - off = RTE_ALIGN_CEIL(off, sizeof(double)); - if (dst.rss) { - dst.rss->rss_conf = (void *)((uintptr_t)dst.rss + off); - *(struct rte_eth_rss_conf *)(uintptr_t) - dst.rss->rss_conf = (struct rte_eth_rss_conf){ - .rss_key_len = src.rss->rss_conf->rss_key_len, - .rss_hf = src.rss->rss_conf->rss_hf, - }; - } - off += sizeof(*src.rss->rss_conf); - if (src.rss->rss_conf->rss_key_len) { + if (src.rss->queue_num) { off = RTE_ALIGN_CEIL(off, sizeof(double)); - size = sizeof(*src.rss->rss_conf->rss_key) * - src.rss->rss_conf->rss_key_len; - if (dst.rss) { - ((struct rte_eth_rss_conf *)(uintptr_t) - dst.rss->rss_conf)->rss_key = - (void *)((uintptr_t)dst.rss + off); - memcpy(dst.rss->rss_conf->rss_key, - src.rss->rss_conf->rss_key, - size); - } + size = sizeof(*src.rss->queue) * src.rss->queue_num; + if (dst.rss) + dst.rss->queue = memcpy + ((void *)((uintptr_t)dst.rss + off), + src.rss->queue, size); off += size; } size = off; diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index 895feb1a3..4385e7eaa 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -1033,13 +1033,21 @@ struct rte_flow_query_count { * Similar to QUEUE, except RSS is additionally performed on packets to * spread them among several queues according to the provided parameters. * + * Unlike global RSS settings used by other DPDK APIs, unsetting the + * @p types field does not disable RSS in a flow rule. Doing so instead + * requests safe unspecified "best-effort" settings from the underlying PMD, + * which depending on the flow rule, may result in anything ranging from + * empty (single queue) to all-inclusive RSS. + * * Note: RSS hash result is stored in the hash.rss mbuf field which overlaps * hash.fdir.lo. Since the MARK action sets the hash.fdir.hi field only, * both can be requested simultaneously. */ struct rte_flow_action_rss { - const struct rte_eth_rss_conf *rss_conf; /**< RSS parameters. */ - uint16_t num; /**< Number of entries in @p queue. */ + uint64_t types; /**< Specific RSS hash types (see ETH_RSS_*). */ + uint32_t key_len; /**< Hash key length in bytes. */ + uint32_t queue_num; /**< Number of entries in @p queue. */ + const uint8_t *key; /**< Hash key. */ const uint16_t *queue; /**< Queue indices to use. */ }; -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [dpdk-dev] [PATCH v3 07/16] ethdev: flatten RSS configuration in flow API 2018-04-10 16:36 ` [dpdk-dev] [PATCH v3 07/16] ethdev: flatten RSS configuration in " Adrien Mazarguil @ 2018-04-11 13:06 ` Andrew Rybchenko 0 siblings, 0 replies; 157+ messages in thread From: Andrew Rybchenko @ 2018-04-11 13:06 UTC (permalink / raw) To: Adrien Mazarguil, Thomas Monjalon, Ferruh Yigit, dev Cc: Xueming Li, Wenzhuo Lu, Jingjing Wu, Beilei Xing, Qi Zhang, Konstantin Ananyev, Nelio Laranjeiro, Yongseok Koh, Pascal Mazon, Radu Nicolau, Akhil Goyal On 04/10/2018 07:36 PM, Adrien Mazarguil wrote: > Since its inception, the rte_flow RSS action has been relying in part on > external struct rte_eth_rss_conf for compatibility with the legacy RSS API. > This structure lacks parameters such as the hash algorithm to use, and more > recently, a method to tell which layer RSS should be performed on [1]. > > Given struct rte_eth_rss_conf will never be flexible enough to represent a > complete RSS configuration (e.g. RETA table), this patch supersedes it by > extending the rte_flow RSS action directly. > > A subsequent patch will add a field to use a non-default RSS hash > algorithm. To that end, a field named "types" replaces the field formerly > known as "rss_hf" and standing for "RSS hash functions" as it was > confusing. Actual RSS hash function types are defined by enum > rte_eth_hash_function. > > This patch updates all PMDs and example applications accordingly. > > It breaks ABI compatibility for the following public functions: > > - rte_flow_copy() > - rte_flow_create() > - rte_flow_query() > - rte_flow_validate() > > [1] commit 676b605182a5 ("doc: announce ethdev API change for RSS > configuration") > > Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> > Cc: Xueming Li <xuemingl@mellanox.com> > Cc: Ferruh Yigit <ferruh.yigit@intel.com> > Cc: Thomas Monjalon <thomas@monjalon.net> > Cc: Wenzhuo Lu <wenzhuo.lu@intel.com> > Cc: Jingjing Wu <jingjing.wu@intel.com> > Cc: Beilei Xing <beilei.xing@intel.com> > Cc: Qi Zhang <qi.z.zhang@intel.com> > Cc: Konstantin Ananyev <konstantin.ananyev@intel.com> > Cc: Nelio Laranjeiro <nelio.laranjeiro@6wind.com> > Cc: Yongseok Koh <yskoh@mellanox.com> > Cc: Andrew Rybchenko <arybchenko@solarflare.com> > Cc: Pascal Mazon <pascal.mazon@6wind.com> > Cc: Radu Nicolau <radu.nicolau@intel.com> > Cc: Akhil Goyal <akhil.goyal@nxp.com> > > --- > > v3 changes: > > Documentation update regarding the meaning of a 0 value for RSS types in > flow rules. > > It used to implicitly mean "no RSS" but is redefined as requesting a kind > of "best-effort" mode from PMDs, i.e. anything ranging from empty to > all-inclusive RSS; what matters is it provides safe defaults that will work > regardless of PMD capabilities. > --- > app/test-pmd/cmdline_flow.c | 48 +++--- > app/test-pmd/config.c | 39 ++--- > doc/guides/prog_guide/rte_flow.rst | 28 ++-- > doc/guides/testpmd_app_ug/testpmd_funcs.rst | 6 +- > drivers/net/e1000/e1000_ethdev.h | 13 +- > drivers/net/e1000/igb_ethdev.c | 4 +- > drivers/net/e1000/igb_flow.c | 31 ++-- > drivers/net/e1000/igb_rxtx.c | 51 +++++- > drivers/net/i40e/i40e_ethdev.c | 53 +++++-- > drivers/net/i40e/i40e_ethdev.h | 15 +- > drivers/net/i40e/i40e_flow.c | 57 ++++--- > drivers/net/ixgbe/ixgbe_ethdev.c | 4 +- > drivers/net/ixgbe/ixgbe_ethdev.h | 13 +- > drivers/net/ixgbe/ixgbe_flow.c | 30 ++-- > drivers/net/ixgbe/ixgbe_rxtx.c | 51 +++++- > drivers/net/mlx4/mlx4.c | 2 +- > drivers/net/mlx4/mlx4_flow.c | 61 +++---- > drivers/net/mlx4/mlx4_flow.h | 2 +- > drivers/net/mlx4/mlx4_rxq.c | 2 +- > drivers/net/mlx4/mlx4_rxtx.h | 2 +- > drivers/net/mlx5/mlx5_flow.c | 193 +++++++++++------------ > drivers/net/mlx5/mlx5_rxq.c | 22 +-- > drivers/net/mlx5/mlx5_rxtx.h | 26 +-- > drivers/net/sfc/sfc_flow.c | 21 ++- > drivers/net/tap/tap_flow.c | 8 +- > examples/ipsec-secgw/ipsec.c | 10 +- > lib/librte_ether/rte_flow.c | 39 ++--- > lib/librte_ether/rte_flow.h | 12 +- > 28 files changed, 484 insertions(+), 359 deletions(-) Generic and net/sfc; Acked-by: Andrew Rybchenko <arybchenko@solarflare.com> ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v3 08/16] ethdev: add hash function to RSS flow API action 2018-04-10 16:36 ` [dpdk-dev] [PATCH v3 00/16] Flow API overhaul for switch offloads Adrien Mazarguil ` (6 preceding siblings ...) 2018-04-10 16:36 ` [dpdk-dev] [PATCH v3 07/16] ethdev: flatten RSS configuration in " Adrien Mazarguil @ 2018-04-10 16:36 ` Adrien Mazarguil 2018-04-11 12:40 ` Andrew Rybchenko 2018-04-10 16:36 ` [dpdk-dev] [PATCH v3 09/16] ethdev: add encap level " Adrien Mazarguil ` (8 subsequent siblings) 16 siblings, 1 reply; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-10 16:36 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev Cc: Wenzhuo Lu, Jingjing Wu, Beilei Xing, Qi Zhang, Konstantin Ananyev, Nelio Laranjeiro, Yongseok Koh, Andrew Rybchenko, Pascal Mazon By definition, RSS involves some kind of hash algorithm, usually Toeplitz. Until now it could not be modified on a flow rule basis and PMDs had to always assume RTE_ETH_HASH_FUNCTION_DEFAULT, which remains the default behavior when unspecified (0). This breaks ABI compatibility for the following public functions: - rte_flow_copy() - rte_flow_create() - rte_flow_query() - rte_flow_validate() Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Cc: Ferruh Yigit <ferruh.yigit@intel.com> Cc: Thomas Monjalon <thomas@monjalon.net> Cc: Wenzhuo Lu <wenzhuo.lu@intel.com> Cc: Jingjing Wu <jingjing.wu@intel.com> Cc: Beilei Xing <beilei.xing@intel.com> Cc: Qi Zhang <qi.z.zhang@intel.com> Cc: Konstantin Ananyev <konstantin.ananyev@intel.com> Cc: Nelio Laranjeiro <nelio.laranjeiro@6wind.com> Cc: Yongseok Koh <yskoh@mellanox.com> Cc: Andrew Rybchenko <arybchenko@solarflare.com> Cc: Pascal Mazon <pascal.mazon@6wind.com> --- v3 changes: - Although RTE_ETH_HASH_FUNCTION_DEFAULT is defined as 0, made comparisons more explicit where doing so would clarify the code. - Updated sfc to include Toeplitz as the other allowed value. Both according to Andrew's suggestions [1]. [1] http://dpdk.org/ml/archives/dev/2018-April/095840.html --- app/test-pmd/cmdline_flow.c | 72 ++++++++++++++++++++++++ app/test-pmd/config.c | 1 + doc/guides/prog_guide/rte_flow.rst | 2 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 3 + drivers/net/e1000/igb_flow.c | 4 ++ drivers/net/e1000/igb_rxtx.c | 4 +- drivers/net/i40e/i40e_ethdev.c | 4 +- drivers/net/i40e/i40e_flow.c | 4 ++ drivers/net/ixgbe/ixgbe_flow.c | 4 ++ drivers/net/ixgbe/ixgbe_rxtx.c | 4 +- drivers/net/mlx4/mlx4_flow.c | 7 +++ drivers/net/mlx5/mlx5_flow.c | 13 +++++ drivers/net/sfc/sfc_flow.c | 8 +++ drivers/net/tap/tap_flow.c | 6 ++ lib/librte_ether/rte_flow.c | 1 + lib/librte_ether/rte_flow.h | 2 + 16 files changed, 136 insertions(+), 3 deletions(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index f6b73ca6e..34f33f671 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -14,6 +14,7 @@ #include <sys/socket.h> #include <rte_common.h> +#include <rte_eth_ctrl.h> #include <rte_ethdev.h> #include <rte_byteorder.h> #include <cmdline_parse.h> @@ -165,6 +166,10 @@ enum index { ACTION_DROP, ACTION_COUNT, ACTION_RSS, + ACTION_RSS_FUNC, + ACTION_RSS_FUNC_DEFAULT, + ACTION_RSS_FUNC_TOEPLITZ, + ACTION_RSS_FUNC_SIMPLE_XOR, ACTION_RSS_TYPES, ACTION_RSS_TYPE, ACTION_RSS_KEY, @@ -632,6 +637,7 @@ static const enum index action_queue[] = { }; static const enum index action_rss[] = { + ACTION_RSS_FUNC, ACTION_RSS_TYPES, ACTION_RSS_KEY, ACTION_RSS_KEY_LEN, @@ -666,6 +672,9 @@ static int parse_vc_conf(struct context *, const struct token *, static int parse_vc_action_rss(struct context *, const struct token *, const char *, unsigned int, void *, unsigned int); +static int parse_vc_action_rss_func(struct context *, const struct token *, + const char *, unsigned int, void *, + unsigned int); static int parse_vc_action_rss_type(struct context *, const struct token *, const char *, unsigned int, void *, unsigned int); @@ -1584,6 +1593,29 @@ static const struct token token_list[] = { .next = NEXT(action_rss), .call = parse_vc_action_rss, }, + [ACTION_RSS_FUNC] = { + .name = "func", + .help = "RSS hash function to apply", + .next = NEXT(action_rss, + NEXT_ENTRY(ACTION_RSS_FUNC_DEFAULT, + ACTION_RSS_FUNC_TOEPLITZ, + ACTION_RSS_FUNC_SIMPLE_XOR)), + }, + [ACTION_RSS_FUNC_DEFAULT] = { + .name = "default", + .help = "default hash function", + .call = parse_vc_action_rss_func, + }, + [ACTION_RSS_FUNC_TOEPLITZ] = { + .name = "toeplitz", + .help = "Toeplitz hash function", + .call = parse_vc_action_rss_func, + }, + [ACTION_RSS_FUNC_SIMPLE_XOR] = { + .name = "simple_xor", + .help = "simple XOR hash function", + .call = parse_vc_action_rss_func, + }, [ACTION_RSS_TYPES] = { .name = "types", .help = "specific RSS hash types", @@ -2074,6 +2106,7 @@ parse_vc_action_rss(struct context *ctx, const struct token *token, action_rss_data = ctx->object; *action_rss_data = (struct action_rss_data){ .conf = (struct rte_flow_action_rss){ + .func = RTE_ETH_HASH_FUNCTION_DEFAULT, .types = rss_hf, .key_len = sizeof(action_rss_data->key), .queue_num = RTE_MIN(nb_rxq, ACTION_RSS_QUEUE_NUM), @@ -2099,6 +2132,45 @@ parse_vc_action_rss(struct context *ctx, const struct token *token, } /** + * Parse func field for RSS action. + * + * The RTE_ETH_HASH_FUNCTION_* value to assign is derived from the + * ACTION_RSS_FUNC_* index that called this function. + */ +static int +parse_vc_action_rss_func(struct context *ctx, const struct token *token, + const char *str, unsigned int len, + void *buf, unsigned int size) +{ + struct action_rss_data *action_rss_data; + enum rte_eth_hash_function func; + + (void)buf; + (void)size; + /* Token name must match. */ + if (parse_default(ctx, token, str, len, NULL, 0) < 0) + return -1; + switch (ctx->curr) { + case ACTION_RSS_FUNC_DEFAULT: + func = RTE_ETH_HASH_FUNCTION_DEFAULT; + break; + case ACTION_RSS_FUNC_TOEPLITZ: + func = RTE_ETH_HASH_FUNCTION_TOEPLITZ; + break; + case ACTION_RSS_FUNC_SIMPLE_XOR: + func = RTE_ETH_HASH_FUNCTION_SIMPLE_XOR; + break; + default: + return -1; + } + if (!ctx->object) + return len; + action_rss_data = ctx->object; + action_rss_data->conf.func = func; + return len; +} + +/** * Parse type field for RSS action. * * Valid tokens are type field names and the "end" token. diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 717f31774..b258c93e8 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -1084,6 +1084,7 @@ flow_action_conf_copy(void *buf, const struct rte_flow_action *action) off = 0; if (dst.rss) *dst.rss = (struct rte_flow_action_rss){ + .func = src.rss->func, .types = src.rss->types, .key_len = src.rss->key_len, .queue_num = src.rss->queue_num, diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index cf252eeba..e0c68495c 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -1318,6 +1318,8 @@ field only, both can be requested simultaneously. +---------------+---------------------------------------------+ | Field | Value | +===============+=============================================+ + | ``func`` | RSS hash function to apply | + +---------------+---------------------------------------------+ | ``types`` | specific RSS hash types (see ``ETH_RSS_*``) | +---------------+---------------------------------------------+ | ``key_len`` | hash key length in bytes | diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index 17336d163..546ef3ab7 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3398,6 +3398,9 @@ This section lists supported actions and their attributes, if any. - ``rss``: spread packets among several queues. + - ``func {hash function}``: RSS hash function to apply, allowed tokens are + the same as `set_hash_global_config`_. + - ``types [{RSS hash type} [...]] end``: specific RSS hash types, allowed tokens are the same as `set_hash_input_set`_, except that an empty list does not disable RSS but instead requests unspecified "best-effort" diff --git a/drivers/net/e1000/igb_flow.c b/drivers/net/e1000/igb_flow.c index 8dc5f75f2..82307ec5d 100644 --- a/drivers/net/e1000/igb_flow.c +++ b/drivers/net/e1000/igb_flow.c @@ -1310,6 +1310,10 @@ igb_parse_rss_filter(struct rte_eth_dev *dev, } } + if (rss->func != RTE_ETH_HASH_FUNCTION_DEFAULT) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, + "non-default RSS hash functions are not supported"); if (rss->key_len && rss->key_len != RTE_DIM(rss_conf->key)) return rte_flow_error_set (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, diff --git a/drivers/net/e1000/igb_rxtx.c b/drivers/net/e1000/igb_rxtx.c index 45bb3455c..d5c1cd3d3 100644 --- a/drivers/net/e1000/igb_rxtx.c +++ b/drivers/net/e1000/igb_rxtx.c @@ -2905,6 +2905,7 @@ igb_rss_conf_init(struct igb_rte_flow_rss_conf *out, in->queue_num > RTE_DIM(out->queue)) return -EINVAL; out->conf = (struct rte_flow_action_rss){ + .func = in->func, .types = in->types, .key_len = in->key_len, .queue_num = in->queue_num, @@ -2919,7 +2920,8 @@ int igb_action_rss_same(const struct rte_flow_action_rss *comp, const struct rte_flow_action_rss *with) { - return (comp->types == with->types && + return (comp->func == with->func && + comp->types == with->types && comp->key_len == with->key_len && comp->queue_num == with->queue_num && !memcmp(comp->key, with->key, with->key_len) && diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index 0242b5d59..5e313950c 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c @@ -11974,6 +11974,7 @@ i40e_rss_conf_init(struct i40e_rte_flow_rss_conf *out, in->queue_num > RTE_DIM(out->queue)) return -EINVAL; out->conf = (struct rte_flow_action_rss){ + .func = in->func, .types = in->types, .key_len = in->key_len, .queue_num = in->queue_num, @@ -11988,7 +11989,8 @@ int i40e_action_rss_same(const struct rte_flow_action_rss *comp, const struct rte_flow_action_rss *with) { - return (comp->types == with->types && + return (comp->func == with->func && + comp->types == with->types && comp->key_len == with->key_len && comp->queue_num == with->queue_num && !memcmp(comp->key, with->key, with->key_len) && diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c index db708fb5b..33f77cc80 100644 --- a/drivers/net/i40e/i40e_flow.c +++ b/drivers/net/i40e/i40e_flow.c @@ -4352,6 +4352,10 @@ i40e_flow_parse_rss_action(struct rte_eth_dev *dev, } } + if (rss->func != RTE_ETH_HASH_FUNCTION_DEFAULT) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, + "non-default RSS hash functions are not supported"); if (rss->key_len && rss->key_len > RTE_DIM(rss_config->key)) return rte_flow_error_set (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, diff --git a/drivers/net/ixgbe/ixgbe_flow.c b/drivers/net/ixgbe/ixgbe_flow.c index 4e31c7c56..00d975b93 100644 --- a/drivers/net/ixgbe/ixgbe_flow.c +++ b/drivers/net/ixgbe/ixgbe_flow.c @@ -2779,6 +2779,10 @@ ixgbe_parse_rss_filter(struct rte_eth_dev *dev, } } + if (rss->func != RTE_ETH_HASH_FUNCTION_DEFAULT) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, + "non-default RSS hash functions are not supported"); if (rss->key_len && rss->key_len != RTE_DIM(rss_conf->key)) return rte_flow_error_set (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, diff --git a/drivers/net/ixgbe/ixgbe_rxtx.c b/drivers/net/ixgbe/ixgbe_rxtx.c index 94ea7444d..e17f5a433 100644 --- a/drivers/net/ixgbe/ixgbe_rxtx.c +++ b/drivers/net/ixgbe/ixgbe_rxtx.c @@ -5682,6 +5682,7 @@ ixgbe_rss_conf_init(struct ixgbe_rte_flow_rss_conf *out, in->queue_num > RTE_DIM(out->queue)) return -EINVAL; out->conf = (struct rte_flow_action_rss){ + .func = in->func, .types = in->types, .key_len = in->key_len, .queue_num = in->queue_num, @@ -5696,7 +5697,8 @@ int ixgbe_action_rss_same(const struct rte_flow_action_rss *comp, const struct rte_flow_action_rss *with) { - return (comp->types == with->types && + return (comp->func == with->func && + comp->types == with->types && comp->key_len == with->key_len && comp->queue_num == with->queue_num && !memcmp(comp->key, with->key, with->key_len) && diff --git a/drivers/net/mlx4/mlx4_flow.c b/drivers/net/mlx4/mlx4_flow.c index 4dbcaa39c..dcaf8df44 100644 --- a/drivers/net/mlx4/mlx4_flow.c +++ b/drivers/net/mlx4/mlx4_flow.c @@ -790,6 +790,12 @@ mlx4_flow_prepare(struct priv *priv, " of the context size"; goto exit_action_not_supported; } + if (rss->func && + rss->func != RTE_ETH_HASH_FUNCTION_TOEPLITZ) { + msg = "the only supported RSS hash function" + " is Toeplitz"; + goto exit_action_not_supported; + } rte_errno = 0; fields = mlx4_conv_rss_types(priv, rss->types); if (fields == (uint64_t)-1 && rte_errno) { @@ -1283,6 +1289,7 @@ mlx4_flow_internal(struct priv *priv, struct rte_flow_error *error) rte_align32pow2(priv->dev->data->nb_rx_queues + 1) >> 1; uint16_t queue[queues]; struct rte_flow_action_rss action_rss = { + .func = RTE_ETH_HASH_FUNCTION_DEFAULT, .types = -1, .key_len = MLX4_RSS_HASH_KEY_SIZE, .queue_num = queues, diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 7798052f9..0771ad339 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -18,6 +18,7 @@ #endif #include <rte_common.h> +#include <rte_eth_ctrl.h> #include <rte_ethdev_driver.h> #include <rte_flow.h> #include <rte_flow_driver.h> @@ -634,6 +635,15 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, if (overlap & FATE) goto exit_action_overlap; overlap |= FATE; + if (rss->func && + rss->func != RTE_ETH_HASH_FUNCTION_TOEPLITZ) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION, + actions, + "the only supported RSS hash" + " function is Toeplitz"); + return -rte_errno; + } if (rss->types & MLX5_RSS_HF_MASK) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, @@ -683,6 +693,7 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, } } parser->rss_conf = (struct rte_flow_action_rss){ + .func = RTE_ETH_HASH_FUNCTION_DEFAULT, .types = rss->types, .key_len = rss_key_len, .queue_num = rss->queue_num, @@ -1915,6 +1926,7 @@ mlx5_flow_list_create(struct rte_eth_dev *dev, /* Copy configuration. */ flow->queues = (uint16_t (*)[])(flow + 1); flow->rss_conf = (struct rte_flow_action_rss){ + .func = RTE_ETH_HASH_FUNCTION_DEFAULT, .types = parser.rss_conf.types, .key_len = parser.rss_conf.key_len, .queue_num = parser.rss_conf.queue_num, @@ -2429,6 +2441,7 @@ mlx5_ctrl_flow_vlan(struct rte_eth_dev *dev, }; uint16_t queue[priv->reta_idx_n]; struct rte_flow_action_rss action_rss = { + .func = RTE_ETH_HASH_FUNCTION_DEFAULT, .types = priv->rss_conf.rss_hf, .key_len = priv->rss_conf.rss_key_len, .queue_num = priv->reta_idx_n, diff --git a/drivers/net/sfc/sfc_flow.c b/drivers/net/sfc/sfc_flow.c index 1a2c0299c..779edad0c 100644 --- a/drivers/net/sfc/sfc_flow.c +++ b/drivers/net/sfc/sfc_flow.c @@ -1261,6 +1261,14 @@ sfc_flow_parse_rss(struct sfc_adapter *sa, rxq_hw_index_max = rxq->hw_index; } + switch (rss->func) { + case RTE_ETH_HASH_FUNCTION_DEFAULT: + case RTE_ETH_HASH_FUNCTION_TOEPLITZ: + break; + default: + return -EINVAL; + } + if ((rss->types & ~SFC_RSS_OFFLOADS) != 0) return -EINVAL; diff --git a/drivers/net/tap/tap_flow.c b/drivers/net/tap/tap_flow.c index 78f20913f..7abf49ab1 100644 --- a/drivers/net/tap/tap_flow.c +++ b/drivers/net/tap/tap_flow.c @@ -2055,6 +2055,12 @@ static int rss_add_actions(struct rte_flow *flow, struct pmd_internals *pmd, struct rss_key rss_entry = { .hash_fields = 0, .key_size = 0 }; + /* Check supported hash functions */ + if (rss->func != RTE_ETH_HASH_FUNCTION_DEFAULT) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, + "non-default RSS hash functions are not supported"); + /* Get a new map key for a new RSS rule */ err = bpf_rss_key(KEY_CMD_GET, &flow->key_idx); if (err < 0) { diff --git a/lib/librte_ether/rte_flow.c b/lib/librte_ether/rte_flow.c index 2fabc9a29..0a2c0ac00 100644 --- a/lib/librte_ether/rte_flow.c +++ b/lib/librte_ether/rte_flow.c @@ -330,6 +330,7 @@ flow_action_conf_copy(void *buf, const struct rte_flow_action *action) off = 0; if (dst.rss) *dst.rss = (struct rte_flow_action_rss){ + .func = src.rss->func, .types = src.rss->types, .key_len = src.rss->key_len, .queue_num = src.rss->queue_num, diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index 4385e7eaa..acf6031ec 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -19,6 +19,7 @@ #include <rte_arp.h> #include <rte_ether.h> +#include <rte_eth_ctrl.h> #include <rte_icmp.h> #include <rte_ip.h> #include <rte_sctp.h> @@ -1044,6 +1045,7 @@ struct rte_flow_query_count { * both can be requested simultaneously. */ struct rte_flow_action_rss { + enum rte_eth_hash_function func; /**< RSS hash function to apply. */ uint64_t types; /**< Specific RSS hash types (see ETH_RSS_*). */ uint32_t key_len; /**< Hash key length in bytes. */ uint32_t queue_num; /**< Number of entries in @p queue. */ -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [dpdk-dev] [PATCH v3 08/16] ethdev: add hash function to RSS flow API action 2018-04-10 16:36 ` [dpdk-dev] [PATCH v3 08/16] ethdev: add hash function to RSS flow API action Adrien Mazarguil @ 2018-04-11 12:40 ` Andrew Rybchenko 0 siblings, 0 replies; 157+ messages in thread From: Andrew Rybchenko @ 2018-04-11 12:40 UTC (permalink / raw) To: Adrien Mazarguil, Thomas Monjalon, Ferruh Yigit, dev Cc: Wenzhuo Lu, Jingjing Wu, Beilei Xing, Qi Zhang, Konstantin Ananyev, Nelio Laranjeiro, Yongseok Koh, Pascal Mazon On 04/10/2018 07:36 PM, Adrien Mazarguil wrote: > By definition, RSS involves some kind of hash algorithm, usually Toeplitz. > > Until now it could not be modified on a flow rule basis and PMDs had to > always assume RTE_ETH_HASH_FUNCTION_DEFAULT, which remains the default > behavior when unspecified (0). > > This breaks ABI compatibility for the following public functions: > > - rte_flow_copy() > - rte_flow_create() > - rte_flow_query() > - rte_flow_validate() > > Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> > Cc: Ferruh Yigit <ferruh.yigit@intel.com> > Cc: Thomas Monjalon <thomas@monjalon.net> > Cc: Wenzhuo Lu <wenzhuo.lu@intel.com> > Cc: Jingjing Wu <jingjing.wu@intel.com> > Cc: Beilei Xing <beilei.xing@intel.com> > Cc: Qi Zhang <qi.z.zhang@intel.com> > Cc: Konstantin Ananyev <konstantin.ananyev@intel.com> > Cc: Nelio Laranjeiro <nelio.laranjeiro@6wind.com> > Cc: Yongseok Koh <yskoh@mellanox.com> > Cc: Andrew Rybchenko <arybchenko@solarflare.com> > Cc: Pascal Mazon <pascal.mazon@6wind.com> > > --- > > v3 changes: > > - Although RTE_ETH_HASH_FUNCTION_DEFAULT is defined as 0, made comparisons > more explicit where doing so would clarify the code. > > - Updated sfc to include Toeplitz as the other allowed value. > > Both according to Andrew's suggestions [1]. > > [1] http://dpdk.org/ml/archives/dev/2018-April/095840.html > --- > app/test-pmd/cmdline_flow.c | 72 ++++++++++++++++++++++++ > app/test-pmd/config.c | 1 + > doc/guides/prog_guide/rte_flow.rst | 2 + > doc/guides/testpmd_app_ug/testpmd_funcs.rst | 3 + > drivers/net/e1000/igb_flow.c | 4 ++ > drivers/net/e1000/igb_rxtx.c | 4 +- > drivers/net/i40e/i40e_ethdev.c | 4 +- > drivers/net/i40e/i40e_flow.c | 4 ++ > drivers/net/ixgbe/ixgbe_flow.c | 4 ++ > drivers/net/ixgbe/ixgbe_rxtx.c | 4 +- > drivers/net/mlx4/mlx4_flow.c | 7 +++ > drivers/net/mlx5/mlx5_flow.c | 13 +++++ > drivers/net/sfc/sfc_flow.c | 8 +++ > drivers/net/tap/tap_flow.c | 6 ++ > lib/librte_ether/rte_flow.c | 1 + > lib/librte_ether/rte_flow.h | 2 + > 16 files changed, 136 insertions(+), 3 deletions(-) Generic and net/sfc Acked-by: Andrew Rybchenko <arybchenko@solarflare.com> ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v3 09/16] ethdev: add encap level to RSS flow API action 2018-04-10 16:36 ` [dpdk-dev] [PATCH v3 00/16] Flow API overhaul for switch offloads Adrien Mazarguil ` (7 preceding siblings ...) 2018-04-10 16:36 ` [dpdk-dev] [PATCH v3 08/16] ethdev: add hash function to RSS flow API action Adrien Mazarguil @ 2018-04-10 16:36 ` Adrien Mazarguil 2018-04-10 16:36 ` [dpdk-dev] [PATCH v3 10/16] ethdev: refine TPID handling in flow API Adrien Mazarguil ` (7 subsequent siblings) 16 siblings, 0 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-10 16:36 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev Cc: Xueming Li, Wenzhuo Lu, Jingjing Wu, Beilei Xing, Qi Zhang, Konstantin Ananyev, Nelio Laranjeiro, Yongseok Koh, Andrew Rybchenko, Pascal Mazon RSS hash types (ETH_RSS_* macros defined in rte_ethdev.h) describe the protocol header fields of a packet that must be taken into account while computing RSS. When facing encapsulated (e.g. tunneled) packets, there is an ambiguity as to whether these should apply to inner or outer packets. Applications need the ability to tell exactly "where" RSS must be performed. This is addressed by adding encapsulation level information to the RSS flow action. Its default value is 0 and stands for the usual unspecified behavior. Other values provide a specific encapsulation level. Contrary to the change announced by commit 676b605182a5 ("doc: announce ethdev API change for RSS configuration"), this patch does not affect struct rte_eth_rss_conf but struct rte_flow_action_rss as the former is not used anymore by the RSS flow action. ABI impact is therefore limited to rte_flow. This breaks ABI compatibility for the following public functions: - rte_flow_copy() - rte_flow_create() - rte_flow_query() - rte_flow_validate() Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Acked-by: Andrew Rybchenko <arybchenko@solarflare.com> Cc: Xueming Li <xuemingl@mellanox.com> Cc: Ferruh Yigit <ferruh.yigit@intel.com> Cc: Thomas Monjalon <thomas@monjalon.net> Cc: Wenzhuo Lu <wenzhuo.lu@intel.com> Cc: Jingjing Wu <jingjing.wu@intel.com> Cc: Beilei Xing <beilei.xing@intel.com> Cc: Qi Zhang <qi.z.zhang@intel.com> Cc: Konstantin Ananyev <konstantin.ananyev@intel.com> Cc: Nelio Laranjeiro <nelio.laranjeiro@6wind.com> Cc: Yongseok Koh <yskoh@mellanox.com> Cc: Andrew Rybchenko <arybchenko@solarflare.com> Cc: Pascal Mazon <pascal.mazon@6wind.com> --- app/test-pmd/cmdline_flow.c | 13 ++++++++++++ app/test-pmd/config.c | 1 + doc/guides/prog_guide/rte_flow.rst | 24 ++++++++++++++++++++++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 2 ++ drivers/net/e1000/igb_flow.c | 4 ++++ drivers/net/e1000/igb_rxtx.c | 2 ++ drivers/net/i40e/i40e_ethdev.c | 2 ++ drivers/net/i40e/i40e_flow.c | 4 ++++ drivers/net/ixgbe/ixgbe_flow.c | 4 ++++ drivers/net/ixgbe/ixgbe_rxtx.c | 2 ++ drivers/net/mlx4/mlx4_flow.c | 6 ++++++ drivers/net/mlx5/mlx5_flow.c | 11 ++++++++++ drivers/net/sfc/sfc_flow.c | 3 +++ drivers/net/tap/tap_flow.c | 6 +++++- lib/librte_ether/rte_flow.c | 1 + lib/librte_ether/rte_flow.h | 26 ++++++++++++++++++++++++ 16 files changed, 110 insertions(+), 1 deletion(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 34f33f671..9b6004176 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -167,6 +167,7 @@ enum index { ACTION_COUNT, ACTION_RSS, ACTION_RSS_FUNC, + ACTION_RSS_LEVEL, ACTION_RSS_FUNC_DEFAULT, ACTION_RSS_FUNC_TOEPLITZ, ACTION_RSS_FUNC_SIMPLE_XOR, @@ -638,6 +639,7 @@ static const enum index action_queue[] = { static const enum index action_rss[] = { ACTION_RSS_FUNC, + ACTION_RSS_LEVEL, ACTION_RSS_TYPES, ACTION_RSS_KEY, ACTION_RSS_KEY_LEN, @@ -1616,6 +1618,16 @@ static const struct token token_list[] = { .help = "simple XOR hash function", .call = parse_vc_action_rss_func, }, + [ACTION_RSS_LEVEL] = { + .name = "level", + .help = "encapsulation level for \"types\"", + .next = NEXT(action_rss, NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY_ARB + (offsetof(struct action_rss_data, conf) + + offsetof(struct rte_flow_action_rss, level), + sizeof(((struct rte_flow_action_rss *)0)-> + level))), + }, [ACTION_RSS_TYPES] = { .name = "types", .help = "specific RSS hash types", @@ -2107,6 +2119,7 @@ parse_vc_action_rss(struct context *ctx, const struct token *token, *action_rss_data = (struct action_rss_data){ .conf = (struct rte_flow_action_rss){ .func = RTE_ETH_HASH_FUNCTION_DEFAULT, + .level = 0, .types = rss_hf, .key_len = sizeof(action_rss_data->key), .queue_num = RTE_MIN(nb_rxq, ACTION_RSS_QUEUE_NUM), diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index b258c93e8..c0fefe475 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -1085,6 +1085,7 @@ flow_action_conf_copy(void *buf, const struct rte_flow_action *action) if (dst.rss) *dst.rss = (struct rte_flow_action_rss){ .func = src.rss->func, + .level = src.rss->level, .types = src.rss->types, .key_len = src.rss->key_len, .queue_num = src.rss->queue_num, diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index e0c68495c..1a09e8a0f 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -1311,6 +1311,28 @@ Note: RSS hash result is stored in the ``hash.rss`` mbuf field which overlaps ``hash.fdir.lo``. Since `Action: MARK`_ sets the ``hash.fdir.hi`` field only, both can be requested simultaneously. +Also, regarding packet encapsulation ``level``: + +- ``0`` requests the default behavior. Depending on the packet type, it can + mean outermost, innermost, anything in between or even no RSS. + + It basically stands for the innermost encapsulation level RSS can be + performed on according to PMD and device capabilities. + +- ``1`` requests RSS to be performed on the outermost packet encapsulation + level. + +- ``2`` and subsequent values request RSS to be performed on the specified + inner packet encapsulation level, from outermost to innermost (lower to + higher values). + +Values other than ``0`` are not necessarily supported. + +Requesting a specific RSS level on unrecognized traffic results in undefined +behavior. For predictable results, it is recommended to make the flow rule +pattern match packet headers up to the requested encapsulation level so that +only matching traffic goes through. + .. _table_rte_flow_action_rss: .. table:: RSS @@ -1320,6 +1342,8 @@ field only, both can be requested simultaneously. +===============+=============================================+ | ``func`` | RSS hash function to apply | +---------------+---------------------------------------------+ + | ``level`` | encapsulation level for ``types`` | + +---------------+---------------------------------------------+ | ``types`` | specific RSS hash types (see ``ETH_RSS_*``) | +---------------+---------------------------------------------+ | ``key_len`` | hash key length in bytes | diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index 546ef3ab7..3b1073bfc 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3401,6 +3401,8 @@ This section lists supported actions and their attributes, if any. - ``func {hash function}``: RSS hash function to apply, allowed tokens are the same as `set_hash_global_config`_. + - ``level {unsigned}``: encapsulation level for ``types``. + - ``types [{RSS hash type} [...]] end``: specific RSS hash types, allowed tokens are the same as `set_hash_input_set`_, except that an empty list does not disable RSS but instead requests unspecified "best-effort" diff --git a/drivers/net/e1000/igb_flow.c b/drivers/net/e1000/igb_flow.c index 82307ec5d..d1c0b4b8d 100644 --- a/drivers/net/e1000/igb_flow.c +++ b/drivers/net/e1000/igb_flow.c @@ -1314,6 +1314,10 @@ igb_parse_rss_filter(struct rte_eth_dev *dev, return rte_flow_error_set (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, "non-default RSS hash functions are not supported"); + if (rss->level) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, + "a nonzero RSS encapsulation level is not supported"); if (rss->key_len && rss->key_len != RTE_DIM(rss_conf->key)) return rte_flow_error_set (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, diff --git a/drivers/net/e1000/igb_rxtx.c b/drivers/net/e1000/igb_rxtx.c index d5c1cd3d3..a3776a0d7 100644 --- a/drivers/net/e1000/igb_rxtx.c +++ b/drivers/net/e1000/igb_rxtx.c @@ -2906,6 +2906,7 @@ igb_rss_conf_init(struct igb_rte_flow_rss_conf *out, return -EINVAL; out->conf = (struct rte_flow_action_rss){ .func = in->func, + .level = in->level, .types = in->types, .key_len = in->key_len, .queue_num = in->queue_num, @@ -2921,6 +2922,7 @@ igb_action_rss_same(const struct rte_flow_action_rss *comp, const struct rte_flow_action_rss *with) { return (comp->func == with->func && + comp->level == with->level && comp->types == with->types && comp->key_len == with->key_len && comp->queue_num == with->queue_num && diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index 5e313950c..b104b551c 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c @@ -11975,6 +11975,7 @@ i40e_rss_conf_init(struct i40e_rte_flow_rss_conf *out, return -EINVAL; out->conf = (struct rte_flow_action_rss){ .func = in->func, + .level = in->level, .types = in->types, .key_len = in->key_len, .queue_num = in->queue_num, @@ -11990,6 +11991,7 @@ i40e_action_rss_same(const struct rte_flow_action_rss *comp, const struct rte_flow_action_rss *with) { return (comp->func == with->func && + comp->level == with->level && comp->types == with->types && comp->key_len == with->key_len && comp->queue_num == with->queue_num && diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c index 33f77cc80..fef812c6b 100644 --- a/drivers/net/i40e/i40e_flow.c +++ b/drivers/net/i40e/i40e_flow.c @@ -4356,6 +4356,10 @@ i40e_flow_parse_rss_action(struct rte_eth_dev *dev, return rte_flow_error_set (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, "non-default RSS hash functions are not supported"); + if (rss->level) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, + "a nonzero RSS encapsulation level is not supported"); if (rss->key_len && rss->key_len > RTE_DIM(rss_config->key)) return rte_flow_error_set (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, diff --git a/drivers/net/ixgbe/ixgbe_flow.c b/drivers/net/ixgbe/ixgbe_flow.c index 00d975b93..438bfcdfb 100644 --- a/drivers/net/ixgbe/ixgbe_flow.c +++ b/drivers/net/ixgbe/ixgbe_flow.c @@ -2783,6 +2783,10 @@ ixgbe_parse_rss_filter(struct rte_eth_dev *dev, return rte_flow_error_set (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, "non-default RSS hash functions are not supported"); + if (rss->level) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, + "a nonzero RSS encapsulation level is not supported"); if (rss->key_len && rss->key_len != RTE_DIM(rss_conf->key)) return rte_flow_error_set (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, diff --git a/drivers/net/ixgbe/ixgbe_rxtx.c b/drivers/net/ixgbe/ixgbe_rxtx.c index e17f5a433..23af21712 100644 --- a/drivers/net/ixgbe/ixgbe_rxtx.c +++ b/drivers/net/ixgbe/ixgbe_rxtx.c @@ -5683,6 +5683,7 @@ ixgbe_rss_conf_init(struct ixgbe_rte_flow_rss_conf *out, return -EINVAL; out->conf = (struct rte_flow_action_rss){ .func = in->func, + .level = in->level, .types = in->types, .key_len = in->key_len, .queue_num = in->queue_num, @@ -5698,6 +5699,7 @@ ixgbe_action_rss_same(const struct rte_flow_action_rss *comp, const struct rte_flow_action_rss *with) { return (comp->func == with->func && + comp->level == with->level && comp->types == with->types && comp->key_len == with->key_len && comp->queue_num == with->queue_num && diff --git a/drivers/net/mlx4/mlx4_flow.c b/drivers/net/mlx4/mlx4_flow.c index dcaf8df44..779641e11 100644 --- a/drivers/net/mlx4/mlx4_flow.c +++ b/drivers/net/mlx4/mlx4_flow.c @@ -796,6 +796,11 @@ mlx4_flow_prepare(struct priv *priv, " is Toeplitz"; goto exit_action_not_supported; } + if (rss->level) { + msg = "a nonzero RSS encapsulation level is" + " not supported"; + goto exit_action_not_supported; + } rte_errno = 0; fields = mlx4_conv_rss_types(priv, rss->types); if (fields == (uint64_t)-1 && rte_errno) { @@ -1290,6 +1295,7 @@ mlx4_flow_internal(struct priv *priv, struct rte_flow_error *error) uint16_t queue[queues]; struct rte_flow_action_rss action_rss = { .func = RTE_ETH_HASH_FUNCTION_DEFAULT, + .level = 0, .types = -1, .key_len = MLX4_RSS_HASH_KEY_SIZE, .queue_num = queues, diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 0771ad339..bc1176819 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -644,6 +644,14 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, " function is Toeplitz"); return -rte_errno; } + if (rss->level) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION, + actions, + "a nonzero RSS encapsulation" + " level is not supported"); + return -rte_errno; + } if (rss->types & MLX5_RSS_HF_MASK) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, @@ -694,6 +702,7 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, } parser->rss_conf = (struct rte_flow_action_rss){ .func = RTE_ETH_HASH_FUNCTION_DEFAULT, + .level = 0, .types = rss->types, .key_len = rss_key_len, .queue_num = rss->queue_num, @@ -1927,6 +1936,7 @@ mlx5_flow_list_create(struct rte_eth_dev *dev, flow->queues = (uint16_t (*)[])(flow + 1); flow->rss_conf = (struct rte_flow_action_rss){ .func = RTE_ETH_HASH_FUNCTION_DEFAULT, + .level = 0, .types = parser.rss_conf.types, .key_len = parser.rss_conf.key_len, .queue_num = parser.rss_conf.queue_num, @@ -2442,6 +2452,7 @@ mlx5_ctrl_flow_vlan(struct rte_eth_dev *dev, uint16_t queue[priv->reta_idx_n]; struct rte_flow_action_rss action_rss = { .func = RTE_ETH_HASH_FUNCTION_DEFAULT, + .level = 0, .types = priv->rss_conf.rss_hf, .key_len = priv->rss_conf.rss_key_len, .queue_num = priv->reta_idx_n, diff --git a/drivers/net/sfc/sfc_flow.c b/drivers/net/sfc/sfc_flow.c index 779edad0c..3028efbf9 100644 --- a/drivers/net/sfc/sfc_flow.c +++ b/drivers/net/sfc/sfc_flow.c @@ -1269,6 +1269,9 @@ sfc_flow_parse_rss(struct sfc_adapter *sa, return -EINVAL; } + if (rss->level) + return -EINVAL; + if ((rss->types & ~SFC_RSS_OFFLOADS) != 0) return -EINVAL; diff --git a/drivers/net/tap/tap_flow.c b/drivers/net/tap/tap_flow.c index 7abf49ab1..1caefff43 100644 --- a/drivers/net/tap/tap_flow.c +++ b/drivers/net/tap/tap_flow.c @@ -2055,11 +2055,15 @@ static int rss_add_actions(struct rte_flow *flow, struct pmd_internals *pmd, struct rss_key rss_entry = { .hash_fields = 0, .key_size = 0 }; - /* Check supported hash functions */ + /* Check supported RSS features */ if (rss->func != RTE_ETH_HASH_FUNCTION_DEFAULT) return rte_flow_error_set (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, "non-default RSS hash functions are not supported"); + if (rss->level) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, + "a nonzero RSS encapsulation level is not supported"); /* Get a new map key for a new RSS rule */ err = bpf_rss_key(KEY_CMD_GET, &flow->key_idx); diff --git a/lib/librte_ether/rte_flow.c b/lib/librte_ether/rte_flow.c index 0a2c0ac00..1f247d656 100644 --- a/lib/librte_ether/rte_flow.c +++ b/lib/librte_ether/rte_flow.c @@ -331,6 +331,7 @@ flow_action_conf_copy(void *buf, const struct rte_flow_action *action) if (dst.rss) *dst.rss = (struct rte_flow_action_rss){ .func = src.rss->func, + .level = src.rss->level, .types = src.rss->types, .key_len = src.rss->key_len, .queue_num = src.rss->queue_num, diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index acf6031ec..cf4a3faf2 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -1046,6 +1046,32 @@ struct rte_flow_query_count { */ struct rte_flow_action_rss { enum rte_eth_hash_function func; /**< RSS hash function to apply. */ + /** + * Packet encapsulation level RSS hash @p types apply to. + * + * - @p 0 requests the default behavior. Depending on the packet + * type, it can mean outermost, innermost, anything in between or + * even no RSS. + * + * It basically stands for the innermost encapsulation level RSS + * can be performed on according to PMD and device capabilities. + * + * - @p 1 requests RSS to be performed on the outermost packet + * encapsulation level. + * + * - @p 2 and subsequent values request RSS to be performed on the + * specified inner packet encapsulation level, from outermost to + * innermost (lower to higher values). + * + * Values other than @p 0 are not necessarily supported. + * + * Requesting a specific RSS level on unrecognized traffic results + * in undefined behavior. For predictable results, it is recommended + * to make the flow rule pattern match packet headers up to the + * requested encapsulation level so that only matching traffic goes + * through. + */ + uint32_t level; uint64_t types; /**< Specific RSS hash types (see ETH_RSS_*). */ uint32_t key_len; /**< Hash key length in bytes. */ uint32_t queue_num; /**< Number of entries in @p queue. */ -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v3 10/16] ethdev: refine TPID handling in flow API 2018-04-10 16:36 ` [dpdk-dev] [PATCH v3 00/16] Flow API overhaul for switch offloads Adrien Mazarguil ` (8 preceding siblings ...) 2018-04-10 16:36 ` [dpdk-dev] [PATCH v3 09/16] ethdev: add encap level " Adrien Mazarguil @ 2018-04-10 16:36 ` Adrien Mazarguil 2018-04-11 12:45 ` Andrew Rybchenko 2018-04-10 16:36 ` [dpdk-dev] [PATCH v3 11/16] ethdev: limit default VLAN TCI mask " Adrien Mazarguil ` (6 subsequent siblings) 16 siblings, 1 reply; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-10 16:36 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev Cc: Wenzhuo Lu, Jingjing Wu, Ajit Khaparde, Somnath Kotur, John Daley, Hyong Youb Kim, Beilei Xing, Qi Zhang, Konstantin Ananyev, Nelio Laranjeiro, Yongseok Koh, Tomasz Duszynski, Dmitri Epshtein, Natalie Samsonov, Jianbo Liu, Andrew Rybchenko, Pascal Mazon TPID handling in rte_flow VLAN and E_TAG pattern item definitions is not consistent with the normal stacking order of pattern items, which is confusing to applications. Problem is that when followed by one of these layers, the EtherType field of the preceding layer keeps its "inner" definition, and the "outer" TPID is provided by the subsequent layer, the reverse of how a packet looks like on the wire: Wire: [ ETH TPID = A | VLAN EtherType = B | B DATA ] rte_flow: [ ETH EtherType = B | VLAN TPID = A | B DATA ] Worse, when QinQ is involved, the stacking order of VLAN layers is unspecified. It is unclear whether it should be reversed (innermost to outermost) as well given TPID applies to the previous layer: Wire: [ ETH TPID = A | VLAN TPID = B | VLAN EtherType = C | C DATA ] rte_flow 1: [ ETH EtherType = C | VLAN TPID = B | VLAN TPID = A | C DATA ] rte_flow 2: [ ETH EtherType = C | VLAN TPID = A | VLAN TPID = B | C DATA ] While specifying EtherType/TPID is hopefully rarely necessary, the stacking order in case of QinQ and the lack of documentation remain an issue. This patch replaces TPID in the VLAN pattern item with an inner EtherType/TPID as is usually done everywhere else (e.g. struct vlan_hdr), clarifies documentation and updates all relevant code. It breaks ABI compatibility for the following public functions: - rte_flow_copy() - rte_flow_create() - rte_flow_query() - rte_flow_validate() Summary of changes for PMDs that implement ETH, VLAN or E_TAG pattern items: - bnxt: EtherType matching is supported with and without VLAN, but TPID matching is not and triggers an error. - e1000: EtherType matching is only supported with the ETHERTYPE filter, which does not support VLAN matching, therefore no impact. - enic: same as bnxt. - i40e: same as bnxt with existing FDIR limitations on allowed EtherType values. The remaining filter types (VXLAN, NVGRE, QINQ) do not support EtherType matching. - ixgbe: same as e1000, with additional minor change to rely on the new E-Tag macro definition. - mlx4: EtherType/TPID matching is not supported, no impact. - mlx5: same as bnxt. - mvpp2: same as bnxt. - sfc: same as bnxt. - tap: same as bnxt. Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Cc: Ferruh Yigit <ferruh.yigit@intel.com> Cc: Thomas Monjalon <thomas@monjalon.net> Cc: Wenzhuo Lu <wenzhuo.lu@intel.com> Cc: Jingjing Wu <jingjing.wu@intel.com> Cc: Ajit Khaparde <ajit.khaparde@broadcom.com> Cc: Somnath Kotur <somnath.kotur@broadcom.com> Cc: John Daley <johndale@cisco.com> Cc: Hyong Youb Kim <hyonkim@cisco.com> Cc: Beilei Xing <beilei.xing@intel.com> Cc: Qi Zhang <qi.z.zhang@intel.com> Cc: Konstantin Ananyev <konstantin.ananyev@intel.com> Cc: Nelio Laranjeiro <nelio.laranjeiro@6wind.com> Cc: Yongseok Koh <yskoh@mellanox.com> Cc: Tomasz Duszynski <tdu@semihalf.com> Cc: Dmitri Epshtein <dima@marvell.com> Cc: Natalie Samsonov <nsamsono@marvell.com> Cc: Jianbo Liu <jianbo.liu@arm.com> Cc: Andrew Rybchenko <arybchenko@solarflare.com> Cc: Pascal Mazon <pascal.mazon@6wind.com> --- v3 changes: Updated mrvl to mvpp2. Moved unrelated default TCI mask update to separate patch. Fixed sfc according to Andrew's comments [1], which made so much sense that I standardized on the same behavior for all other PMDs: matching outer TPID is never supported when a VLAN pattern item is present. This is done because many devices accept several TPIDs but do not provide means to match a given one explicitly, it's all or nothing, and that makes the resulting flow rule inaccurate. [1] http://dpdk.org/ml/archives/dev/2018-April/095870.html --- app/test-pmd/cmdline_flow.c | 17 +++---- doc/guides/nics/tap.rst | 2 +- doc/guides/prog_guide/rte_flow.rst | 19 ++++++-- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 4 +- drivers/net/bnxt/bnxt_filter.c | 35 +++++++++++--- drivers/net/enic/enic_flow.c | 19 +++++--- drivers/net/i40e/i40e_flow.c | 60 ++++++++++++++++++++---- drivers/net/ixgbe/ixgbe_ethdev.c | 3 +- drivers/net/mlx5/mlx5_flow.c | 13 ++++- drivers/net/mvpp2/mrvl_flow.c | 26 +++++++--- drivers/net/sfc/sfc_flow.c | 18 +++++++ drivers/net/tap/tap_flow.c | 14 ++++-- lib/librte_ether/rte_flow.h | 22 ++++++--- lib/librte_net/rte_ether.h | 1 + 14 files changed, 198 insertions(+), 55 deletions(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 9b6004176..49217d5bc 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -99,11 +99,11 @@ enum index { ITEM_ETH_SRC, ITEM_ETH_TYPE, ITEM_VLAN, - ITEM_VLAN_TPID, ITEM_VLAN_TCI, ITEM_VLAN_PCP, ITEM_VLAN_DEI, ITEM_VLAN_VID, + ITEM_VLAN_INNER_TYPE, ITEM_IPV4, ITEM_IPV4_TOS, ITEM_IPV4_TTL, @@ -505,11 +505,11 @@ static const enum index item_eth[] = { }; static const enum index item_vlan[] = { - ITEM_VLAN_TPID, ITEM_VLAN_TCI, ITEM_VLAN_PCP, ITEM_VLAN_DEI, ITEM_VLAN_VID, + ITEM_VLAN_INNER_TYPE, ITEM_NEXT, ZERO, }; @@ -1142,12 +1142,6 @@ static const struct token token_list[] = { .next = NEXT(item_vlan), .call = parse_vc, }, - [ITEM_VLAN_TPID] = { - .name = "tpid", - .help = "tag protocol identifier", - .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param), - .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vlan, tpid)), - }, [ITEM_VLAN_TCI] = { .name = "tci", .help = "tag control information", @@ -1175,6 +1169,13 @@ static const struct token token_list[] = { .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan, tci, "\x0f\xff")), }, + [ITEM_VLAN_INNER_TYPE] = { + .name = "inner_type", + .help = "inner EtherType", + .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vlan, + inner_type)), + }, [ITEM_IPV4] = { .name = "ipv4", .help = "match IPv4 header", diff --git a/doc/guides/nics/tap.rst b/doc/guides/nics/tap.rst index c97786aca..3f7a15147 100644 --- a/doc/guides/nics/tap.rst +++ b/doc/guides/nics/tap.rst @@ -108,7 +108,7 @@ The kernel support can be checked with this command:: Supported items: - eth: src and dst (with variable masks), and eth_type (0xffff mask). -- vlan: vid, pcp, tpid, but not eid. (requires kernel 4.9) +- vlan: vid, pcp, but not eid. (requires kernel 4.9) - ipv4/6: src and dst (with variable masks), and ip_proto (0xffff mask). - udp/tcp: src and dst port (0xffff) mask. diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 1a09e8a0f..fd317b48c 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -784,9 +784,15 @@ Item: ``ETH`` Matches an Ethernet header. +The ``type`` field either stands for "EtherType" or "TPID" when followed by +so-called layer 2.5 pattern items such as ``RTE_FLOW_ITEM_TYPE_VLAN``. In +the latter case, ``type`` refers to that of the outer header, with the inner +EtherType/TPID provided by the subsequent pattern item. This is the same +order as on the wire. + - ``dst``: destination MAC. - ``src``: source MAC. -- ``type``: EtherType. +- ``type``: EtherType or TPID. - Default ``mask`` matches destination and source addresses only. Item: ``VLAN`` @@ -794,8 +800,12 @@ Item: ``VLAN`` Matches an 802.1Q/ad VLAN tag. -- ``tpid``: tag protocol identifier. +The corresponding standard outer EtherType (TPID) values are +``ETHER_TYPE_VLAN`` or ``ETHER_TYPE_QINQ``. It can be overridden by the +preceding pattern item. + - ``tci``: tag control information. +- ``inner_type``: inner EtherType or TPID. - Default ``mask`` matches TCI only. Item: ``IPV4`` @@ -866,12 +876,15 @@ Item: ``E_TAG`` Matches an IEEE 802.1BR E-Tag header. -- ``tpid``: tag protocol identifier (0x893F) +The corresponding standard outer EtherType (TPID) value is +``ETHER_TYPE_ETAG``. It can be overridden by the preceding pattern item. + - ``epcp_edei_in_ecid_b``: E-Tag control information (E-TCI), E-PCP (3b), E-DEI (1b), ingress E-CID base (12b). - ``rsvd_grp_ecid_b``: reserved (2b), GRP (2b), E-CID base (12b). - ``in_ecid_e``: ingress E-CID ext. - ``ecid_e``: E-CID ext. +- ``inner_type``: inner EtherType or TPID. - Default ``mask`` simultaneously matches GRP and E-CID base. Item: ``NVGRE`` diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index 3b1073bfc..923664f7d 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3223,15 +3223,15 @@ This section lists supported pattern items and their attributes, if any. - ``dst {MAC-48}``: destination MAC. - ``src {MAC-48}``: source MAC. - - ``type {unsigned}``: EtherType. + - ``type {unsigned}``: EtherType or TPID. - ``vlan``: match 802.1Q/ad VLAN tag. - - ``tpid {unsigned}``: tag protocol identifier. - ``tci {unsigned}``: tag control information. - ``pcp {unsigned}``: priority code point. - ``dei {unsigned}``: drop eligible indicator. - ``vid {unsigned}``: VLAN identifier. + - ``inner_type {unsigned}``: inner EtherType or TPID. - ``ipv4``: match IPv4 header. diff --git a/drivers/net/bnxt/bnxt_filter.c b/drivers/net/bnxt/bnxt_filter.c index 0f9c1c9ae..9bb1575cb 100644 --- a/drivers/net/bnxt/bnxt_filter.c +++ b/drivers/net/bnxt/bnxt_filter.c @@ -299,6 +299,7 @@ bnxt_validate_and_parse_flow_type(struct bnxt *bp, uint32_t vf = 0; int use_ntuple; uint32_t en = 0; + uint32_t en_ethertype; int dflt_vnic; use_ntuple = bnxt_filter_type_check(pattern, error); @@ -308,6 +309,9 @@ bnxt_validate_and_parse_flow_type(struct bnxt *bp, filter->filter_type = use_ntuple ? HWRM_CFA_NTUPLE_FILTER : HWRM_CFA_EM_FILTER; + en_ethertype = use_ntuple ? + NTUPLE_FLTR_ALLOC_INPUT_EN_ETHERTYPE : + EM_FLOW_ALLOC_INPUT_EN_ETHERTYPE; while (item->type != RTE_FLOW_ITEM_TYPE_END) { if (item->last) { @@ -377,30 +381,49 @@ bnxt_validate_and_parse_flow_type(struct bnxt *bp, if (eth_mask->type) { filter->ethertype = rte_be_to_cpu_16(eth_spec->type); - en |= use_ntuple ? - NTUPLE_FLTR_ALLOC_INPUT_EN_ETHERTYPE : - EM_FLOW_ALLOC_INPUT_EN_ETHERTYPE; + en |= en_ethertype; } break; case RTE_FLOW_ITEM_TYPE_VLAN: vlan_spec = item->spec; vlan_mask = item->mask; + if (en & en_ethertype) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, + item, + "VLAN TPID matching is not" + " supported"); + return -rte_errno; + } if (vlan_mask->tci && - vlan_mask->tci == RTE_BE16(0x0fff) && - !vlan_mask->tpid) { + vlan_mask->tci == RTE_BE16(0x0fff)) { /* Only the VLAN ID can be matched. */ filter->l2_ovlan = rte_be_to_cpu_16(vlan_spec->tci & RTE_BE16(0x0fff)); en |= EM_FLOW_ALLOC_INPUT_EN_OVLAN_VID; - } else if (vlan_mask->tci || vlan_mask->tpid) { + } else if (vlan_mask->tci) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM, item, "VLAN mask is invalid"); return -rte_errno; } + if (vlan_mask->inner_type && + vlan_mask->inner_type != RTE_BE16(0xffff)) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, + item, + "inner ethertype mask not" + " valid"); + return -rte_errno; + } + if (vlan_mask->inner_type) { + filter->ethertype = + rte_be_to_cpu_16(vlan_spec->inner_type); + en |= en_ethertype; + } break; case RTE_FLOW_ITEM_TYPE_IPV4: diff --git a/drivers/net/enic/enic_flow.c b/drivers/net/enic/enic_flow.c index a5c6a1670..20d6b9d59 100644 --- a/drivers/net/enic/enic_flow.c +++ b/drivers/net/enic/enic_flow.c @@ -557,16 +557,21 @@ enic_copy_item_vlan_v2(const struct rte_flow_item *item, if (!spec) return 0; - /* Don't support filtering in tpid */ - if (mask) { - if (mask->tpid != 0) - return ENOTSUP; - } else { + if (!mask) mask = &rte_flow_item_vlan_mask; - RTE_ASSERT(mask->tpid == 0); - } if (*inner_ofst == 0) { + struct ether_hdr *eth_mask = + (void *)gp->layer[FILTER_GENERIC_1_L2].mask; + struct ether_hdr *eth_val = + (void *)gp->layer[FILTER_GENERIC_1_L2].val; + + /* Outer TPID cannot be matched */ + if (eth_mask->ether_type) + return ENOTSUP; + eth_mask->ether_type = mask->inner_type; + eth_val->ether_type = spec->inner_type; + /* Outer header. Use the vlan mask/val fields */ gp->mask_vlan = mask->tci; gp->val_vlan = spec->tci; diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c index fef812c6b..e3d83eac7 100644 --- a/drivers/net/i40e/i40e_flow.c +++ b/drivers/net/i40e/i40e_flow.c @@ -10,6 +10,7 @@ #include <unistd.h> #include <stdarg.h> +#include <rte_debug.h> #include <rte_ether.h> #include <rte_ethdev_driver.h> #include <rte_log.h> @@ -2491,16 +2492,22 @@ i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev, "Invalid MAC_addr mask."); return -rte_errno; } + } + if (eth_spec && eth_mask && eth_mask->type) { + enum rte_flow_item_type next = (item + 1)->type; - if ((eth_mask->type & UINT16_MAX) == - UINT16_MAX) { - input_set |= I40E_INSET_LAST_ETHER_TYPE; - filter->input.flow.l2_flow.ether_type = - eth_spec->type; + if (eth_mask->type != RTE_BE16(0xffff)) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, + item, + "Invalid type mask."); + return -rte_errno; } ether_type = rte_be_to_cpu_16(eth_spec->type); - if (ether_type == ETHER_TYPE_IPv4 || + + if (next == RTE_FLOW_ITEM_TYPE_VLAN || + ether_type == ETHER_TYPE_IPv4 || ether_type == ETHER_TYPE_IPv6 || ether_type == ETHER_TYPE_ARP || ether_type == outer_tpid) { @@ -2510,6 +2517,9 @@ i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev, "Unsupported ether_type."); return -rte_errno; } + input_set |= I40E_INSET_LAST_ETHER_TYPE; + filter->input.flow.l2_flow.ether_type = + eth_spec->type; } pctype = I40E_FILTER_PCTYPE_L2_PAYLOAD; @@ -2519,6 +2529,8 @@ i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev, case RTE_FLOW_ITEM_TYPE_VLAN: vlan_spec = item->spec; vlan_mask = item->mask; + + RTE_ASSERT(!(input_set & I40E_INSET_LAST_ETHER_TYPE)); if (vlan_spec && vlan_mask) { if (vlan_mask->tci == rte_cpu_to_be_16(I40E_TCI_MASK)) { @@ -2527,6 +2539,33 @@ i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev, vlan_spec->tci; } } + if (vlan_spec && vlan_mask && vlan_mask->inner_type) { + if (vlan_mask->inner_type != RTE_BE16(0xffff)) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, + item, + "Invalid inner_type" + " mask."); + return -rte_errno; + } + + ether_type = + rte_be_to_cpu_16(vlan_spec->inner_type); + + if (ether_type == ETHER_TYPE_IPv4 || + ether_type == ETHER_TYPE_IPv6 || + ether_type == ETHER_TYPE_ARP || + ether_type == outer_tpid) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, + item, + "Unsupported inner_type."); + return -rte_errno; + } + input_set |= I40E_INSET_LAST_ETHER_TYPE; + filter->input.flow.l2_flow.ether_type = + vlan_spec->inner_type; + } pctype = I40E_FILTER_PCTYPE_L2_PAYLOAD; layer_idx = I40E_FLXPLD_L2_IDX; @@ -3285,7 +3324,8 @@ i40e_flow_parse_vxlan_pattern(__rte_unused struct rte_eth_dev *dev, case RTE_FLOW_ITEM_TYPE_VLAN: vlan_spec = item->spec; vlan_mask = item->mask; - if (!(vlan_spec && vlan_mask)) { + if (!(vlan_spec && vlan_mask) || + vlan_mask->inner_type) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM, item, @@ -3515,7 +3555,8 @@ i40e_flow_parse_nvgre_pattern(__rte_unused struct rte_eth_dev *dev, case RTE_FLOW_ITEM_TYPE_VLAN: vlan_spec = item->spec; vlan_mask = item->mask; - if (!(vlan_spec && vlan_mask)) { + if (!(vlan_spec && vlan_mask) || + vlan_mask->inner_type) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM, item, @@ -4023,7 +4064,8 @@ i40e_flow_parse_qinq_pattern(__rte_unused struct rte_eth_dev *dev, vlan_spec = item->spec; vlan_mask = item->mask; - if (!(vlan_spec && vlan_mask)) { + if (!(vlan_spec && vlan_mask) || + vlan_mask->inner_type) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM, item, diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c index ea3624ba4..94fba2908 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.c +++ b/drivers/net/ixgbe/ixgbe_ethdev.c @@ -115,7 +115,6 @@ #define IXGBE_VT_CTL_POOLING_MODE_MASK 0x00030000 #define IXGBE_VT_CTL_POOLING_MODE_ETAG 0x00010000 -#define DEFAULT_ETAG_ETYPE 0x893f #define IXGBE_ETAG_ETYPE 0x00005084 #define IXGBE_ETAG_ETYPE_MASK 0x0000ffff #define IXGBE_ETAG_ETYPE_VALID 0x80000000 @@ -1481,7 +1480,7 @@ static int ixgbe_l2_tn_filter_init(struct rte_eth_dev *eth_dev) } l2_tn_info->e_tag_en = FALSE; l2_tn_info->e_tag_fwd_en = FALSE; - l2_tn_info->e_tag_ether_type = DEFAULT_ETAG_ETYPE; + l2_tn_info->e_tag_ether_type = ETHER_TYPE_ETAG; return 0; } diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index bc1176819..292e579d1 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -18,6 +18,7 @@ #endif #include <rte_common.h> +#include <rte_ether.h> #include <rte_eth_ctrl.h> #include <rte_ethdev_driver.h> #include <rte_flow.h> @@ -306,6 +307,7 @@ static const struct mlx5_flow_items mlx5_flow_items[] = { .actions = valid_actions, .mask = &(const struct rte_flow_item_vlan){ .tci = -1, + .inner_type = -1, }, .default_mask = &rte_flow_item_vlan_mask, .mask_sz = sizeof(struct rte_flow_item_vlan), @@ -1285,6 +1287,7 @@ mlx5_flow_create_vlan(const struct rte_flow_item *item, struct mlx5_flow_parse *parser = data->parser; struct ibv_flow_spec_eth *eth; const unsigned int eth_size = sizeof(struct ibv_flow_spec_eth); + const char *msg = "VLAN cannot be empty"; if (spec) { unsigned int i; @@ -1306,12 +1309,20 @@ mlx5_flow_create_vlan(const struct rte_flow_item *item, */ if (!eth->mask.vlan_tag) goto error; + /* Outer TPID cannot be matched. */ + if (eth->mask.ether_type) { + msg = "VLAN TPID matching is not supported"; + goto error; + } + eth->val.ether_type = spec->inner_type; + eth->mask.ether_type = mask->inner_type; + eth->val.ether_type &= eth->mask.ether_type; } return 0; } error: return rte_flow_error_set(data->error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM, - item, "VLAN cannot be empty"); + item, msg); } /** diff --git a/drivers/net/mvpp2/mrvl_flow.c b/drivers/net/mvpp2/mrvl_flow.c index 8fd4dbfb1..6478eb2fe 100644 --- a/drivers/net/mvpp2/mrvl_flow.c +++ b/drivers/net/mvpp2/mrvl_flow.c @@ -1091,12 +1091,6 @@ mrvl_parse_vlan(const struct rte_flow_item *item, if (ret) return ret; - if (mask->tpid) { - rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM, - NULL, "Not supported by classifier\n"); - return -rte_errno; - } - m = rte_be_to_cpu_16(mask->tci); if (m & MRVL_VLAN_ID_MASK) { RTE_LOG(WARNING, PMD, "vlan id mask is ignored\n"); @@ -1112,6 +1106,26 @@ mrvl_parse_vlan(const struct rte_flow_item *item, goto out; } + if (flow->pattern & F_TYPE) { + rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ITEM, item, + "VLAN TPID matching is not supported\n"); + return -rte_errno; + } + if (mask->inner_type) { + struct rte_flow_item_eth spec_eth = { + .type = spec->inner_type, + }; + struct rte_flow_item_eth mask_eth = { + .type = mask->inner_type, + }; + + RTE_LOG(WARNING, PMD, "inner eth type mask is ignored\n"); + ret = mrvl_parse_type(spec_eth, mask_eth, flow); + if (ret) + goto out; + } + return 0; out: rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, diff --git a/drivers/net/sfc/sfc_flow.c b/drivers/net/sfc/sfc_flow.c index 3028efbf9..cd6a61b39 100644 --- a/drivers/net/sfc/sfc_flow.c +++ b/drivers/net/sfc/sfc_flow.c @@ -7,6 +7,7 @@ * for Solarflare) and Solarflare Communications, Inc. */ +#include <rte_byteorder.h> #include <rte_tailq.h> #include <rte_common.h> #include <rte_ethdev_driver.h> @@ -351,6 +352,7 @@ sfc_flow_parse_vlan(const struct rte_flow_item *item, const struct rte_flow_item_vlan *mask = NULL; const struct rte_flow_item_vlan supp_mask = { .tci = rte_cpu_to_be_16(ETH_VLAN_ID_MAX), + .inner_type = RTE_BE16(0xffff), }; rc = sfc_flow_parse_init(item, @@ -393,6 +395,22 @@ sfc_flow_parse_vlan(const struct rte_flow_item *item, return -rte_errno; } + if (efx_spec->efs_match_flags & EFX_FILTER_MATCH_ETHER_TYPE) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, item, + "VLAN TPID matching is not supported"); + return -rte_errno; + } + if (mask->inner_type == supp_mask.inner_type) { + efx_spec->efs_match_flags |= EFX_FILTER_MATCH_ETHER_TYPE; + efx_spec->efs_ether_type = rte_bswap16(spec->inner_type); + } else if (mask->inner_type) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, item, + "Bad mask for VLAN inner_type"); + return -rte_errno; + } + return 0; } diff --git a/drivers/net/tap/tap_flow.c b/drivers/net/tap/tap_flow.c index 1caefff43..e90e5165f 100644 --- a/drivers/net/tap/tap_flow.c +++ b/drivers/net/tap/tap_flow.c @@ -270,13 +270,13 @@ static const struct tap_flow_items tap_flow_items[] = { .items = ITEMS(RTE_FLOW_ITEM_TYPE_IPV4, RTE_FLOW_ITEM_TYPE_IPV6), .mask = &(const struct rte_flow_item_vlan){ - .tpid = -1, /* DEI matching is not supported */ #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN .tci = 0xffef, #else .tci = 0xefff, #endif + .inner_type = -1, }, .mask_sz = sizeof(struct rte_flow_item_vlan), .default_mask = &rte_flow_item_vlan_mask, @@ -578,13 +578,19 @@ tap_flow_create_vlan(const struct rte_flow_item *item, void *data) /* use default mask if none provided */ if (!mask) mask = tap_flow_items[RTE_FLOW_ITEM_TYPE_VLAN].default_mask; - /* TC does not support tpid masking. Only accept if exact match. */ - if (mask->tpid && mask->tpid != 0xffff) + /* Outer TPID cannot be matched. */ + if (info->eth_type) return -1; /* Double-tagging not supported. */ - if (spec && mask->tpid && spec->tpid != htons(ETH_P_8021Q)) + if (info->vlan) return -1; info->vlan = 1; + if (mask->inner_type) { + /* TC does not support partial eth_type masking */ + if (mask->inner_type != RTE_BE16(0xffff)) + return -1; + info->eth_type = spec->inner_type; + } if (!flow) return 0; msg = &flow->msg; diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index cf4a3faf2..f6ee28929 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -454,11 +454,17 @@ static const struct rte_flow_item_raw rte_flow_item_raw_mask = { * RTE_FLOW_ITEM_TYPE_ETH * * Matches an Ethernet header. + * + * The @p type field either stands for "EtherType" or "TPID" when followed + * by so-called layer 2.5 pattern items such as RTE_FLOW_ITEM_TYPE_VLAN. In + * the latter case, @p type refers to that of the outer header, with the + * inner EtherType/TPID provided by the subsequent pattern item. This is the + * same order as on the wire. */ struct rte_flow_item_eth { struct ether_addr dst; /**< Destination MAC. */ struct ether_addr src; /**< Source MAC. */ - rte_be16_t type; /**< EtherType. */ + rte_be16_t type; /**< EtherType or TPID. */ }; /** Default mask for RTE_FLOW_ITEM_TYPE_ETH. */ @@ -475,19 +481,20 @@ static const struct rte_flow_item_eth rte_flow_item_eth_mask = { * * Matches an 802.1Q/ad VLAN tag. * - * This type normally follows either RTE_FLOW_ITEM_TYPE_ETH or - * RTE_FLOW_ITEM_TYPE_VLAN. + * The corresponding standard outer EtherType (TPID) values are + * ETHER_TYPE_VLAN or ETHER_TYPE_QINQ. It can be overridden by the preceding + * pattern item. */ struct rte_flow_item_vlan { - rte_be16_t tpid; /**< Tag protocol identifier. */ rte_be16_t tci; /**< Tag control information. */ + rte_be16_t inner_type; /**< Inner EtherType or TPID. */ }; /** Default mask for RTE_FLOW_ITEM_TYPE_VLAN. */ #ifndef __cplusplus static const struct rte_flow_item_vlan rte_flow_item_vlan_mask = { - .tpid = RTE_BE16(0x0000), .tci = RTE_BE16(0xffff), + .inner_type = RTE_BE16(0x0000), }; #endif @@ -636,9 +643,11 @@ static const struct rte_flow_item_vxlan rte_flow_item_vxlan_mask = { * RTE_FLOW_ITEM_TYPE_E_TAG. * * Matches a E-tag header. + * + * The corresponding standard outer EtherType (TPID) value is + * ETHER_TYPE_ETAG. It can be overridden by the preceding pattern item. */ struct rte_flow_item_e_tag { - rte_be16_t tpid; /**< Tag protocol identifier (0x893F). */ /** * E-Tag control information (E-TCI). * E-PCP (3b), E-DEI (1b), ingress E-CID base (12b). @@ -648,6 +657,7 @@ struct rte_flow_item_e_tag { rte_be16_t rsvd_grp_ecid_b; uint8_t in_ecid_e; /**< Ingress E-CID ext. */ uint8_t ecid_e; /**< E-CID ext. */ + rte_be16_t inner_type; /**< Inner EtherType or TPID. */ }; /** Default mask for RTE_FLOW_ITEM_TYPE_E_TAG. */ diff --git a/lib/librte_net/rte_ether.h b/lib/librte_net/rte_ether.h index 45daa911a..a271d1c86 100644 --- a/lib/librte_net/rte_ether.h +++ b/lib/librte_net/rte_ether.h @@ -301,6 +301,7 @@ struct vxlan_hdr { #define ETHER_TYPE_RARP 0x8035 /**< Reverse Arp Protocol. */ #define ETHER_TYPE_VLAN 0x8100 /**< IEEE 802.1Q VLAN tagging. */ #define ETHER_TYPE_QINQ 0x88A8 /**< IEEE 802.1ad QinQ tagging. */ +#define ETHER_TYPE_ETAG 0x893F /**< IEEE 802.1BR E-Tag. */ #define ETHER_TYPE_1588 0x88F7 /**< IEEE 802.1AS 1588 Precise Time Protocol. */ #define ETHER_TYPE_SLOW 0x8809 /**< Slow protocols (LACP and Marker). */ #define ETHER_TYPE_TEB 0x6558 /**< Transparent Ethernet Bridging. */ -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [dpdk-dev] [PATCH v3 10/16] ethdev: refine TPID handling in flow API 2018-04-10 16:36 ` [dpdk-dev] [PATCH v3 10/16] ethdev: refine TPID handling in flow API Adrien Mazarguil @ 2018-04-11 12:45 ` Andrew Rybchenko 0 siblings, 0 replies; 157+ messages in thread From: Andrew Rybchenko @ 2018-04-11 12:45 UTC (permalink / raw) To: Adrien Mazarguil, Thomas Monjalon, Ferruh Yigit, dev Cc: Wenzhuo Lu, Jingjing Wu, Ajit Khaparde, Somnath Kotur, John Daley, Hyong Youb Kim, Beilei Xing, Qi Zhang, Konstantin Ananyev, Nelio Laranjeiro, Yongseok Koh, Tomasz Duszynski, Dmitri Epshtein, Natalie Samsonov, Jianbo Liu, Pascal Mazon On 04/10/2018 07:36 PM, Adrien Mazarguil wrote: > TPID handling in rte_flow VLAN and E_TAG pattern item definitions is not > consistent with the normal stacking order of pattern items, which is > confusing to applications. > > Problem is that when followed by one of these layers, the EtherType field > of the preceding layer keeps its "inner" definition, and the "outer" TPID > is provided by the subsequent layer, the reverse of how a packet looks like > on the wire: > > Wire: [ ETH TPID = A | VLAN EtherType = B | B DATA ] > rte_flow: [ ETH EtherType = B | VLAN TPID = A | B DATA ] > > Worse, when QinQ is involved, the stacking order of VLAN layers is > unspecified. It is unclear whether it should be reversed (innermost to > outermost) as well given TPID applies to the previous layer: > > Wire: [ ETH TPID = A | VLAN TPID = B | VLAN EtherType = C | C DATA ] > rte_flow 1: [ ETH EtherType = C | VLAN TPID = B | VLAN TPID = A | C DATA ] > rte_flow 2: [ ETH EtherType = C | VLAN TPID = A | VLAN TPID = B | C DATA ] > > While specifying EtherType/TPID is hopefully rarely necessary, the stacking > order in case of QinQ and the lack of documentation remain an issue. > > This patch replaces TPID in the VLAN pattern item with an inner > EtherType/TPID as is usually done everywhere else (e.g. struct vlan_hdr), > clarifies documentation and updates all relevant code. > > It breaks ABI compatibility for the following public functions: > > - rte_flow_copy() > - rte_flow_create() > - rte_flow_query() > - rte_flow_validate() > > Summary of changes for PMDs that implement ETH, VLAN or E_TAG pattern > items: > > - bnxt: EtherType matching is supported with and without VLAN, but TPID > matching is not and triggers an error. > > - e1000: EtherType matching is only supported with the ETHERTYPE filter, > which does not support VLAN matching, therefore no impact. > > - enic: same as bnxt. > > - i40e: same as bnxt with existing FDIR limitations on allowed EtherType > values. The remaining filter types (VXLAN, NVGRE, QINQ) do not support > EtherType matching. > > - ixgbe: same as e1000, with additional minor change to rely on the new > E-Tag macro definition. > > - mlx4: EtherType/TPID matching is not supported, no impact. > > - mlx5: same as bnxt. > > - mvpp2: same as bnxt. > > - sfc: same as bnxt. > > - tap: same as bnxt. > > Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> > Cc: Ferruh Yigit <ferruh.yigit@intel.com> > Cc: Thomas Monjalon <thomas@monjalon.net> > Cc: Wenzhuo Lu <wenzhuo.lu@intel.com> > Cc: Jingjing Wu <jingjing.wu@intel.com> > Cc: Ajit Khaparde <ajit.khaparde@broadcom.com> > Cc: Somnath Kotur <somnath.kotur@broadcom.com> > Cc: John Daley <johndale@cisco.com> > Cc: Hyong Youb Kim <hyonkim@cisco.com> > Cc: Beilei Xing <beilei.xing@intel.com> > Cc: Qi Zhang <qi.z.zhang@intel.com> > Cc: Konstantin Ananyev <konstantin.ananyev@intel.com> > Cc: Nelio Laranjeiro <nelio.laranjeiro@6wind.com> > Cc: Yongseok Koh <yskoh@mellanox.com> > Cc: Tomasz Duszynski <tdu@semihalf.com> > Cc: Dmitri Epshtein <dima@marvell.com> > Cc: Natalie Samsonov <nsamsono@marvell.com> > Cc: Jianbo Liu <jianbo.liu@arm.com> > Cc: Andrew Rybchenko <arybchenko@solarflare.com> > Cc: Pascal Mazon <pascal.mazon@6wind.com> > > --- > > v3 changes: > > Updated mrvl to mvpp2. > > Moved unrelated default TCI mask update to separate patch. > > Fixed sfc according to Andrew's comments [1], which made so much sense that > I standardized on the same behavior for all other PMDs: matching outer TPID > is never supported when a VLAN pattern item is present. > > This is done because many devices accept several TPIDs but do not provide > means to match a given one explicitly, it's all or nothing, and that makes > the resulting flow rule inaccurate. > > [1] http://dpdk.org/ml/archives/dev/2018-April/095870.html > --- > app/test-pmd/cmdline_flow.c | 17 +++---- > doc/guides/nics/tap.rst | 2 +- > doc/guides/prog_guide/rte_flow.rst | 19 ++++++-- > doc/guides/testpmd_app_ug/testpmd_funcs.rst | 4 +- > drivers/net/bnxt/bnxt_filter.c | 35 +++++++++++--- > drivers/net/enic/enic_flow.c | 19 +++++--- > drivers/net/i40e/i40e_flow.c | 60 ++++++++++++++++++++---- > drivers/net/ixgbe/ixgbe_ethdev.c | 3 +- > drivers/net/mlx5/mlx5_flow.c | 13 ++++- > drivers/net/mvpp2/mrvl_flow.c | 26 +++++++--- > drivers/net/sfc/sfc_flow.c | 18 +++++++ > drivers/net/tap/tap_flow.c | 14 ++++-- > lib/librte_ether/rte_flow.h | 22 ++++++--- > lib/librte_net/rte_ether.h | 1 + > 14 files changed, 198 insertions(+), 55 deletions(-) Generic and net/sfc Acked-by: Andrew Rybchenko <arybchenko@solarflare.com> ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v3 11/16] ethdev: limit default VLAN TCI mask in flow API 2018-04-10 16:36 ` [dpdk-dev] [PATCH v3 00/16] Flow API overhaul for switch offloads Adrien Mazarguil ` (9 preceding siblings ...) 2018-04-10 16:36 ` [dpdk-dev] [PATCH v3 10/16] ethdev: refine TPID handling in flow API Adrien Mazarguil @ 2018-04-10 16:36 ` Adrien Mazarguil 2018-04-11 12:48 ` Andrew Rybchenko 2018-04-10 16:37 ` [dpdk-dev] [PATCH v3 12/16] ethdev: add transfer attribute to " Adrien Mazarguil ` (5 subsequent siblings) 16 siblings, 1 reply; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-10 16:36 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev Cc: Wenzhuo Lu, Jingjing Wu, Ajit Khaparde, Somnath Kotur, John Daley, Hyong Youb Kim, Beilei Xing, Qi Zhang, Konstantin Ananyev, Nelio Laranjeiro, Yongseok Koh, Tomasz Duszynski, Dmitri Epshtein, Natalie Samsonov, Jianbo Liu, Andrew Rybchenko, Pascal Mazon VLAN TCI is a 16-bit field broken down as PCP (3b), DEI (1b) and VID (12b). The default mask used by PMDs for the VLAN pattern when one isn't provided by the application comprises the entire TCI, which is problematic because most devices only support VID matching. This forces applications to always provide a mask limited to the VID part in order to successfully apply a flow rule with a VLAN pattern item. Moreover, applications rarely want to match PCP and DEI intentionally. Given the above and since VID is what is commonly referred to when talking about VLAN, this commit excludes PCP and DEI from the default mask. Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Cc: Ferruh Yigit <ferruh.yigit@intel.com> Cc: Thomas Monjalon <thomas@monjalon.net> Cc: Wenzhuo Lu <wenzhuo.lu@intel.com> Cc: Jingjing Wu <jingjing.wu@intel.com> Cc: Ajit Khaparde <ajit.khaparde@broadcom.com> Cc: Somnath Kotur <somnath.kotur@broadcom.com> Cc: John Daley <johndale@cisco.com> Cc: Hyong Youb Kim <hyonkim@cisco.com> Cc: Beilei Xing <beilei.xing@intel.com> Cc: Qi Zhang <qi.z.zhang@intel.com> Cc: Konstantin Ananyev <konstantin.ananyev@intel.com> Cc: Nelio Laranjeiro <nelio.laranjeiro@6wind.com> Cc: Yongseok Koh <yskoh@mellanox.com> Cc: Tomasz Duszynski <tdu@semihalf.com> Cc: Dmitri Epshtein <dima@marvell.com> Cc: Natalie Samsonov <nsamsono@marvell.com> Cc: Jianbo Liu <jianbo.liu@arm.com> Cc: Andrew Rybchenko <arybchenko@solarflare.com> Cc: Pascal Mazon <pascal.mazon@6wind.com> --- v3 changes: These changes were previously mistakenly made part of the previous patch ("ethdev: refine TPID handling in flow API") from which they were split following Andrew's rightful comment [1]. [1] http://dpdk.org/ml/archives/dev/2018-April/095870.html --- doc/guides/prog_guide/rte_flow.rst | 2 +- lib/librte_ether/rte_flow.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index fd317b48c..c62a80566 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -806,7 +806,7 @@ preceding pattern item. - ``tci``: tag control information. - ``inner_type``: inner EtherType or TPID. -- Default ``mask`` matches TCI only. +- Default ``mask`` matches the VID part of TCI only (lower 12 bits). Item: ``IPV4`` ^^^^^^^^^^^^^^ diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index f6ee28929..73d29ed32 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -493,7 +493,7 @@ struct rte_flow_item_vlan { /** Default mask for RTE_FLOW_ITEM_TYPE_VLAN. */ #ifndef __cplusplus static const struct rte_flow_item_vlan rte_flow_item_vlan_mask = { - .tci = RTE_BE16(0xffff), + .tci = RTE_BE16(0x0fff), .inner_type = RTE_BE16(0x0000), }; #endif -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [dpdk-dev] [PATCH v3 11/16] ethdev: limit default VLAN TCI mask in flow API 2018-04-10 16:36 ` [dpdk-dev] [PATCH v3 11/16] ethdev: limit default VLAN TCI mask " Adrien Mazarguil @ 2018-04-11 12:48 ` Andrew Rybchenko 0 siblings, 0 replies; 157+ messages in thread From: Andrew Rybchenko @ 2018-04-11 12:48 UTC (permalink / raw) To: Adrien Mazarguil, Thomas Monjalon, Ferruh Yigit, dev Cc: Wenzhuo Lu, Jingjing Wu, Ajit Khaparde, Somnath Kotur, John Daley, Hyong Youb Kim, Beilei Xing, Qi Zhang, Konstantin Ananyev, Nelio Laranjeiro, Yongseok Koh, Tomasz Duszynski, Dmitri Epshtein, Natalie Samsonov, Jianbo Liu, Pascal Mazon On 04/10/2018 07:36 PM, Adrien Mazarguil wrote: > VLAN TCI is a 16-bit field broken down as PCP (3b), DEI (1b) and VID (12b). > > The default mask used by PMDs for the VLAN pattern when one isn't provided > by the application comprises the entire TCI, which is problematic because > most devices only support VID matching. > > This forces applications to always provide a mask limited to the VID part > in order to successfully apply a flow rule with a VLAN pattern item. > Moreover, applications rarely want to match PCP and DEI intentionally. > > Given the above and since VID is what is commonly referred to when talking > about VLAN, this commit excludes PCP and DEI from the default mask. > > Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> > Cc: Ferruh Yigit <ferruh.yigit@intel.com> > Cc: Thomas Monjalon <thomas@monjalon.net> > Cc: Wenzhuo Lu <wenzhuo.lu@intel.com> > Cc: Jingjing Wu <jingjing.wu@intel.com> > Cc: Ajit Khaparde <ajit.khaparde@broadcom.com> > Cc: Somnath Kotur <somnath.kotur@broadcom.com> > Cc: John Daley <johndale@cisco.com> > Cc: Hyong Youb Kim <hyonkim@cisco.com> > Cc: Beilei Xing <beilei.xing@intel.com> > Cc: Qi Zhang <qi.z.zhang@intel.com> > Cc: Konstantin Ananyev <konstantin.ananyev@intel.com> > Cc: Nelio Laranjeiro <nelio.laranjeiro@6wind.com> > Cc: Yongseok Koh <yskoh@mellanox.com> > Cc: Tomasz Duszynski <tdu@semihalf.com> > Cc: Dmitri Epshtein <dima@marvell.com> > Cc: Natalie Samsonov <nsamsono@marvell.com> > Cc: Jianbo Liu <jianbo.liu@arm.com> > Cc: Andrew Rybchenko <arybchenko@solarflare.com> > Cc: Pascal Mazon <pascal.mazon@6wind.com> > > --- > > v3 changes: > > These changes were previously mistakenly made part of the previous patch > ("ethdev: refine TPID handling in flow API") from which they were split > following Andrew's rightful comment [1]. > > [1] http://dpdk.org/ml/archives/dev/2018-April/095870.html > --- > doc/guides/prog_guide/rte_flow.rst | 2 +- > lib/librte_ether/rte_flow.h | 2 +- > 2 files changed, 2 insertions(+), 2 deletions(-) Acked-by: Andrew Rybchenko <arybchenko@solarflare.com> ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v3 12/16] ethdev: add transfer attribute to flow API 2018-04-10 16:36 ` [dpdk-dev] [PATCH v3 00/16] Flow API overhaul for switch offloads Adrien Mazarguil ` (10 preceding siblings ...) 2018-04-10 16:36 ` [dpdk-dev] [PATCH v3 11/16] ethdev: limit default VLAN TCI mask " Adrien Mazarguil @ 2018-04-10 16:37 ` Adrien Mazarguil 2018-04-10 16:37 ` [dpdk-dev] [PATCH v3 13/16] ethdev: update behavior of VF/PF in " Adrien Mazarguil ` (4 subsequent siblings) 16 siblings, 0 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-10 16:37 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev; +Cc: Andrew Rybchenko This new attribute enables applications to create flow rules that do not simply match traffic whose origin is specified in the pattern (e.g. some non-default physical port or VF), but actively affect it by applying the flow rule at the lowest possible level in the underlying device. It breaks ABI compatibility for the following public functions: - rte_flow_copy() - rte_flow_create() - rte_flow_validate() Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Cc: Andrew Rybchenko <arybchenko@solarflare.com> --- v3 changes: Clarified definition for ingress and egress following Andrew's comment on subsequent patch. [1] http://dpdk.org/ml/archives/dev/2018-April/095961.html --- app/test-pmd/cmdline_flow.c | 11 +++++ app/test-pmd/config.c | 6 ++- doc/guides/prog_guide/rte_flow.rst | 26 +++++++++++- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 11 ++--- drivers/net/bnxt/bnxt_filter.c | 8 ++++ drivers/net/e1000/igb_flow.c | 44 ++++++++++++++++++++ drivers/net/enic/enic_flow.c | 6 +++ drivers/net/i40e/i40e_flow.c | 8 ++++ drivers/net/ixgbe/ixgbe_flow.c | 53 ++++++++++++++++++++++++ drivers/net/mlx4/mlx4_flow.c | 4 ++ drivers/net/mlx5/mlx5_flow.c | 7 ++++ drivers/net/mvpp2/mrvl_flow.c | 6 +++ drivers/net/sfc/sfc_flow.c | 6 +++ drivers/net/tap/tap_flow.c | 6 +++ lib/librte_ether/rte_flow.h | 22 +++++++++- 15 files changed, 215 insertions(+), 9 deletions(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 49217d5bc..a06f3f82b 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -69,6 +69,7 @@ enum index { PRIORITY, INGRESS, EGRESS, + TRANSFER, /* Validate/create pattern. */ PATTERN, @@ -407,6 +408,7 @@ static const enum index next_vc_attr[] = { PRIORITY, INGRESS, EGRESS, + TRANSFER, PATTERN, ZERO, }; @@ -960,6 +962,12 @@ static const struct token token_list[] = { .next = NEXT(next_vc_attr), .call = parse_vc, }, + [TRANSFER] = { + .name = "transfer", + .help = "apply rule directly to endpoints found in pattern", + .next = NEXT(next_vc_attr), + .call = parse_vc, + }, /* Validate/create pattern. */ [PATTERN] = { .name = "pattern", @@ -1945,6 +1953,9 @@ parse_vc(struct context *ctx, const struct token *token, case EGRESS: out->args.vc.attr.egress = 1; return len; + case TRANSFER: + out->args.vc.attr.transfer = 1; + return len; case PATTERN: out->args.vc.pattern = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1), diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index c0fefe475..49ef87782 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -1223,6 +1223,7 @@ port_flow_complain(struct rte_flow_error *error) [RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY] = "priority field", [RTE_FLOW_ERROR_TYPE_ATTR_INGRESS] = "ingress field", [RTE_FLOW_ERROR_TYPE_ATTR_EGRESS] = "egress field", + [RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER] = "transfer field", [RTE_FLOW_ERROR_TYPE_ATTR] = "attributes structure", [RTE_FLOW_ERROR_TYPE_ITEM_NUM] = "pattern length", [RTE_FLOW_ERROR_TYPE_ITEM_SPEC] = "item specification", @@ -1488,12 +1489,13 @@ port_flow_list(portid_t port_id, uint32_t n, const uint32_t group[n]) const struct rte_flow_item *item = pf->pattern; const struct rte_flow_action *action = pf->actions; - printf("%" PRIu32 "\t%" PRIu32 "\t%" PRIu32 "\t%c%c\t", + printf("%" PRIu32 "\t%" PRIu32 "\t%" PRIu32 "\t%c%c%c\t", pf->id, pf->attr.group, pf->attr.priority, pf->attr.ingress ? 'i' : '-', - pf->attr.egress ? 'e' : '-'); + pf->attr.egress ? 'e' : '-', + pf->attr.transfer ? 't' : '-'); while (item->type != RTE_FLOW_ITEM_TYPE_END) { if (item->type != RTE_FLOW_ITEM_TYPE_VOID) printf("%s ", flow_item[item->type].name); diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index c62a80566..550a4c95b 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -170,7 +170,13 @@ Note that support for more than a single priority level is not guaranteed. Attribute: Traffic direction ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Flow rules can apply to inbound and/or outbound traffic (ingress/egress). +Flow rule patterns apply to inbound and/or outbound traffic. + +In the context of this API, **ingress** and **egress** respectively stand +for **inbound** and **outbound** based on the standpoint of the application +creating a flow rule. + +There are no exceptions to this definition. Several pattern items and actions are valid and can be used in both directions. At least one direction must be specified. @@ -178,6 +184,24 @@ directions. At least one direction must be specified. Specifying both directions at once for a given rule is not recommended but may be valid in a few cases (e.g. shared counters). +Attribute: Transfer +^^^^^^^^^^^^^^^^^^^ + +Instead of simply matching the properties of traffic as it would appear on a +given DPDK port ID, enabling this attribute transfers a flow rule to the +lowest possible level of any device endpoints found in the pattern. + +When supported, this effectively enables an application to reroute traffic +not necessarily intended for it (e.g. coming from or addressed to different +physical ports, VFs or applications) at the device level. + +It complements the behavior of some pattern items such as `Item: PORT`_ and +is meaningless without them. + +When transferring flow rules, **ingress** and **egress** attributes +(`Attribute: Traffic direction`_) keep their original meaning, as if +processing traffic emitted or received by the application. + Pattern item ~~~~~~~~~~~~ diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index 923664f7d..0bf6c33c9 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -2970,14 +2970,14 @@ following sections. - Check whether a flow rule can be created:: flow validate {port_id} - [group {group_id}] [priority {level}] [ingress] [egress] + [group {group_id}] [priority {level}] [ingress] [egress] [transfer] pattern {item} [/ {item} [...]] / end actions {action} [/ {action} [...]] / end - Create a flow rule:: flow create {port_id} - [group {group_id}] [priority {level}] [ingress] [egress] + [group {group_id}] [priority {level}] [ingress] [egress] [transfer] pattern {item} [/ {item} [...]] / end actions {action} [/ {action} [...]] / end @@ -3010,7 +3010,7 @@ underlying device in its current state but stops short of creating it. It is bound to ``rte_flow_validate()``:: flow validate {port_id} - [group {group_id}] [priority {level}] [ingress] [egress] + [group {group_id}] [priority {level}] [ingress] [egress] [transfer] pattern {item} [/ {item} [...]] / end actions {action} [/ {action} [...]] / end @@ -3047,7 +3047,7 @@ Creating flow rules to ``rte_flow_create()``:: flow create {port_id} - [group {group_id}] [priority {level}] [ingress] [egress] + [group {group_id}] [priority {level}] [ingress] [egress] [transfer] pattern {item} [/ {item} [...]] / end actions {action} [/ {action} [...]] / end @@ -3061,7 +3061,7 @@ Otherwise it will show an error message of the form:: Parameters describe in the following order: -- Attributes (*group*, *priority*, *ingress*, *egress* tokens). +- Attributes (*group*, *priority*, *ingress*, *egress*, *transfer* tokens). - A matching pattern, starting with the *pattern* token and terminated by an *end* pattern item. - Actions, starting with the *actions* token and terminated by an *end* @@ -3089,6 +3089,7 @@ specified before the ``pattern`` token. - ``priority {level}``: priority level within group. - ``ingress``: rule applies to ingress traffic. - ``egress``: rule applies to egress traffic. +- ``transfer``: apply rule directly to endpoints found in pattern. Each instance of an attribute specified several times overrides the previous value as shown below (group 4 is used):: diff --git a/drivers/net/bnxt/bnxt_filter.c b/drivers/net/bnxt/bnxt_filter.c index 9bb1575cb..bd166370a 100644 --- a/drivers/net/bnxt/bnxt_filter.c +++ b/drivers/net/bnxt/bnxt_filter.c @@ -746,6 +746,14 @@ bnxt_flow_parse_attr(const struct rte_flow_attr *attr, } /* Not supported */ + if (attr->transfer) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + attr, "No support for transfer."); + return -rte_errno; + } + + /* Not supported */ if (attr->priority) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, diff --git a/drivers/net/e1000/igb_flow.c b/drivers/net/e1000/igb_flow.c index d1c0b4b8d..073852913 100644 --- a/drivers/net/e1000/igb_flow.c +++ b/drivers/net/e1000/igb_flow.c @@ -379,6 +379,15 @@ cons_parse_ntuple_filter(const struct rte_flow_attr *attr, return -rte_errno; } + /* not supported */ + if (attr->transfer) { + memset(filter, 0, sizeof(struct rte_eth_ntuple_filter)); + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + attr, "No support for transfer."); + return -rte_errno; + } + if (attr->priority > 0xFFFF) { memset(filter, 0, sizeof(struct rte_eth_ntuple_filter)); rte_flow_error_set(error, EINVAL, @@ -624,6 +633,14 @@ cons_parse_ethertype_filter(const struct rte_flow_attr *attr, } /* Not supported */ + if (attr->transfer) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + attr, "No support for transfer."); + return -rte_errno; + } + + /* Not supported */ if (attr->priority) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, @@ -923,6 +940,15 @@ cons_parse_syn_filter(const struct rte_flow_attr *attr, return -rte_errno; } + /* not supported */ + if (attr->transfer) { + memset(filter, 0, sizeof(struct rte_eth_syn_filter)); + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + attr, "No support for transfer."); + return -rte_errno; + } + /* Support 2 priorities, the lowest or highest. */ if (!attr->priority) { filter->hig_pri = 0; @@ -1211,6 +1237,15 @@ cons_parse_flex_filter(const struct rte_flow_attr *attr, return -rte_errno; } + /* not supported */ + if (attr->transfer) { + memset(filter, 0, sizeof(struct rte_eth_flex_filter)); + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + attr, "No support for transfer."); + return -rte_errno; + } + if (attr->priority > 0xFFFF) { memset(filter, 0, sizeof(struct rte_eth_flex_filter)); rte_flow_error_set(error, EINVAL, @@ -1361,6 +1396,15 @@ igb_parse_rss_filter(struct rte_eth_dev *dev, return -rte_errno; } + /* not supported */ + if (attr->transfer) { + memset(rss_conf, 0, sizeof(struct igb_rte_flow_rss_conf)); + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + attr, "No support for transfer."); + return -rte_errno; + } + if (attr->priority > 0xFFFF) { memset(rss_conf, 0, sizeof(struct igb_rte_flow_rss_conf)); rte_flow_error_set(error, EINVAL, diff --git a/drivers/net/enic/enic_flow.c b/drivers/net/enic/enic_flow.c index 20d6b9d59..3a0086399 100644 --- a/drivers/net/enic/enic_flow.c +++ b/drivers/net/enic/enic_flow.c @@ -1318,6 +1318,12 @@ enic_flow_parse(struct rte_eth_dev *dev, NULL, "egress is not supported"); return -rte_errno; + } else if (attrs->transfer) { + rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + NULL, + "transfer is not supported"); + return -rte_errno; } else if (!attrs->ingress) { rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c index e3d83eac7..b004357f1 100644 --- a/drivers/net/i40e/i40e_flow.c +++ b/drivers/net/i40e/i40e_flow.c @@ -1918,6 +1918,14 @@ i40e_flow_parse_attr(const struct rte_flow_attr *attr, } /* Not supported */ + if (attr->transfer) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + attr, "No support for transfer."); + return -rte_errno; + } + + /* Not supported */ if (attr->priority) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, diff --git a/drivers/net/ixgbe/ixgbe_flow.c b/drivers/net/ixgbe/ixgbe_flow.c index 438bfcdfb..eb0644c82 100644 --- a/drivers/net/ixgbe/ixgbe_flow.c +++ b/drivers/net/ixgbe/ixgbe_flow.c @@ -557,6 +557,15 @@ cons_parse_ntuple_filter(const struct rte_flow_attr *attr, return -rte_errno; } + /* not supported */ + if (attr->transfer) { + memset(filter, 0, sizeof(struct rte_eth_ntuple_filter)); + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + attr, "No support for transfer."); + return -rte_errno; + } + if (attr->priority > 0xFFFF) { memset(filter, 0, sizeof(struct rte_eth_ntuple_filter)); rte_flow_error_set(error, EINVAL, @@ -787,6 +796,14 @@ cons_parse_ethertype_filter(const struct rte_flow_attr *attr, } /* Not supported */ + if (attr->transfer) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + attr, "No support for transfer."); + return -rte_errno; + } + + /* Not supported */ if (attr->priority) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, @@ -1078,6 +1095,15 @@ cons_parse_syn_filter(const struct rte_flow_attr *attr, return -rte_errno; } + /* not supported */ + if (attr->transfer) { + memset(filter, 0, sizeof(struct rte_eth_syn_filter)); + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + attr, "No support for transfer."); + return -rte_errno; + } + /* Support 2 priorities, the lowest or highest. */ if (!attr->priority) { filter->hig_pri = 0; @@ -1250,6 +1276,15 @@ cons_parse_l2_tn_filter(struct rte_eth_dev *dev, } /* not supported */ + if (attr->transfer) { + memset(filter, 0, sizeof(struct rte_eth_l2_tunnel_conf)); + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + attr, "No support for transfer."); + return -rte_errno; + } + + /* not supported */ if (attr->priority) { memset(filter, 0, sizeof(struct rte_eth_l2_tunnel_conf)); rte_flow_error_set(error, EINVAL, @@ -1354,6 +1389,15 @@ ixgbe_parse_fdir_act_attr(const struct rte_flow_attr *attr, } /* not supported */ + if (attr->transfer) { + memset(rule, 0, sizeof(struct ixgbe_fdir_rule)); + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + attr, "No support for transfer."); + return -rte_errno; + } + + /* not supported */ if (attr->priority) { memset(rule, 0, sizeof(struct ixgbe_fdir_rule)); rte_flow_error_set(error, EINVAL, @@ -2829,6 +2873,15 @@ ixgbe_parse_rss_filter(struct rte_eth_dev *dev, return -rte_errno; } + /* not supported */ + if (attr->transfer) { + memset(rss_conf, 0, sizeof(struct ixgbe_rte_flow_rss_conf)); + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + attr, "No support for transfer."); + return -rte_errno; + } + if (attr->priority > 0xFFFF) { memset(rss_conf, 0, sizeof(struct ixgbe_rte_flow_rss_conf)); rte_flow_error_set(error, EINVAL, diff --git a/drivers/net/mlx4/mlx4_flow.c b/drivers/net/mlx4/mlx4_flow.c index 779641e11..480442f87 100644 --- a/drivers/net/mlx4/mlx4_flow.c +++ b/drivers/net/mlx4/mlx4_flow.c @@ -652,6 +652,10 @@ mlx4_flow_prepare(struct priv *priv, return rte_flow_error_set (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, NULL, "egress is not supported"); + if (attr->transfer) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + NULL, "transfer is not supported"); if (!attr->ingress) return rte_flow_error_set (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 292e579d1..de8ac9610 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -568,6 +568,13 @@ mlx5_flow_convert_attributes(const struct rte_flow_attr *attr, "egress is not supported"); return -rte_errno; } + if (attr->transfer) { + rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + NULL, + "transfer is not supported"); + return -rte_errno; + } if (!attr->ingress) { rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, diff --git a/drivers/net/mvpp2/mrvl_flow.c b/drivers/net/mvpp2/mrvl_flow.c index 6478eb2fe..a2e2129cc 100644 --- a/drivers/net/mvpp2/mrvl_flow.c +++ b/drivers/net/mvpp2/mrvl_flow.c @@ -2187,6 +2187,12 @@ mrvl_flow_parse_attr(struct mrvl_priv *priv __rte_unused, "Egress is not supported"); return -rte_errno; } + if (attr->transfer) { + rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, NULL, + "Transfer is not supported"); + return -rte_errno; + } return 0; } diff --git a/drivers/net/sfc/sfc_flow.c b/drivers/net/sfc/sfc_flow.c index cd6a61b39..bcde2c2f7 100644 --- a/drivers/net/sfc/sfc_flow.c +++ b/drivers/net/sfc/sfc_flow.c @@ -1116,6 +1116,12 @@ sfc_flow_parse_attr(const struct rte_flow_attr *attr, "Egress is not supported"); return -rte_errno; } + if (attr->transfer != 0) { + rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, attr, + "Transfer is not supported"); + return -rte_errno; + } if (attr->ingress == 0) { rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, attr, diff --git a/drivers/net/tap/tap_flow.c b/drivers/net/tap/tap_flow.c index e90e5165f..dc1491990 100644 --- a/drivers/net/tap/tap_flow.c +++ b/drivers/net/tap/tap_flow.c @@ -1039,6 +1039,12 @@ priv_flow_process(struct pmd_internals *pmd, }; int action = 0; /* Only one action authorized for now */ + if (attr->transfer) { + rte_flow_error_set( + error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + NULL, "transfer is not supported"); + return -rte_errno; + } if (attr->group > MAX_GROUP) { rte_flow_error_set( error, EINVAL, RTE_FLOW_ERROR_TYPE_ATTR_GROUP, diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index 73d29ed32..fc7df68d3 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -72,7 +72,26 @@ struct rte_flow_attr { uint32_t priority; /**< Priority level within group. */ uint32_t ingress:1; /**< Rule applies to ingress traffic. */ uint32_t egress:1; /**< Rule applies to egress traffic. */ - uint32_t reserved:30; /**< Reserved, must be zero. */ + /** + * Instead of simply matching the properties of traffic as it would + * appear on a given DPDK port ID, enabling this attribute transfers + * a flow rule to the lowest possible level of any device endpoints + * found in the pattern. + * + * When supported, this effectively enables an application to + * re-route traffic not necessarily intended for it (e.g. coming + * from or addressed to different physical ports, VFs or + * applications) at the device level. + * + * It complements the behavior of some pattern items such as + * RTE_FLOW_ITEM_TYPE_PORT and is meaningless without them. + * + * When transferring flow rules, ingress and egress attributes keep + * their original meaning, as if processing traffic emitted or + * received by the application. + */ + uint32_t transfer:1; + uint32_t reserved:29; /**< Reserved, must be zero. */ }; /** @@ -1181,6 +1200,7 @@ enum rte_flow_error_type { RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, /**< Priority field. */ RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, /**< Ingress field. */ RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, /**< Egress field. */ + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, /**< Transfer field. */ RTE_FLOW_ERROR_TYPE_ATTR, /**< Attributes structure. */ RTE_FLOW_ERROR_TYPE_ITEM_NUM, /**< Pattern length. */ RTE_FLOW_ERROR_TYPE_ITEM_SPEC, /**< Item specification. */ -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v3 13/16] ethdev: update behavior of VF/PF in flow API 2018-04-10 16:36 ` [dpdk-dev] [PATCH v3 00/16] Flow API overhaul for switch offloads Adrien Mazarguil ` (11 preceding siblings ...) 2018-04-10 16:37 ` [dpdk-dev] [PATCH v3 12/16] ethdev: add transfer attribute to " Adrien Mazarguil @ 2018-04-10 16:37 ` Adrien Mazarguil 2018-04-10 16:37 ` [dpdk-dev] [PATCH v3 14/16] ethdev: rename physical port item " Adrien Mazarguil ` (3 subsequent siblings) 16 siblings, 0 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-10 16:37 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev Cc: Ajit Khaparde, Somnath Kotur, Beilei Xing, Qi Zhang Contrary to all other pattern items, these are inconsistently documented as affecting traffic instead of simply matching its origin, without provision for the latter. This commit clarifies documentation and updates PMDs since the original behavior now has to be explicitly requested using the new transfer attribute. It breaks ABI compatibility for the following public functions: - rte_flow_create() - rte_flow_validate() Impacted PMDs are bnxt and i40e, for which the VF pattern item is now only supported when a transfer attribute is also present. Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Cc: Ajit Khaparde <ajit.khaparde@broadcom.com> Cc: Somnath Kotur <somnath.kotur@broadcom.com> Cc: Beilei Xing <beilei.xing@intel.com> Cc: Qi Zhang <qi.z.zhang@intel.com> --- app/test-pmd/cmdline_flow.c | 12 +++--- doc/guides/prog_guide/rte_flow.rst | 36 +++++++++--------- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 12 +++--- drivers/net/bnxt/bnxt_filter.c | 22 ++++++----- drivers/net/i40e/i40e_flow.c | 23 +++++++----- lib/librte_ether/rte_flow.h | 47 ++++++++++-------------- 6 files changed, 77 insertions(+), 75 deletions(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index a06f3f82b..af0631036 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -1041,21 +1041,21 @@ static const struct token token_list[] = { }, [ITEM_PF] = { .name = "pf", - .help = "match packets addressed to the physical function", + .help = "match traffic from/to the physical function", .priv = PRIV_ITEM(PF, 0), .next = NEXT(NEXT_ENTRY(ITEM_NEXT)), .call = parse_vc, }, [ITEM_VF] = { .name = "vf", - .help = "match packets addressed to a virtual function ID", + .help = "match traffic from/to a virtual function ID", .priv = PRIV_ITEM(VF, sizeof(struct rte_flow_item_vf)), .next = NEXT(item_vf), .call = parse_vc, }, [ITEM_VF_ID] = { .name = "id", - .help = "destination VF ID", + .help = "VF ID", .next = NEXT(item_vf, NEXT_ENTRY(UNSIGNED), item_param), .args = ARGS(ARGS_ENTRY(struct rte_flow_item_vf, id)), }, @@ -1686,14 +1686,14 @@ static const struct token token_list[] = { }, [ACTION_PF] = { .name = "pf", - .help = "redirect packets to physical device function", + .help = "direct traffic to physical function", .priv = PRIV_ACTION(PF, 0), .next = NEXT(NEXT_ENTRY(ACTION_NEXT)), .call = parse_vc, }, [ACTION_VF] = { .name = "vf", - .help = "redirect packets to virtual device function", + .help = "direct traffic to a virtual function ID", .priv = PRIV_ACTION(VF, sizeof(struct rte_flow_action_vf)), .next = NEXT(action_vf), .call = parse_vc, @@ -1708,7 +1708,7 @@ static const struct token token_list[] = { }, [ACTION_VF_ID] = { .name = "id", - .help = "VF ID to redirect packets to", + .help = "VF ID", .next = NEXT(action_vf, NEXT_ENTRY(UNSIGNED)), .args = ARGS(ARGS_ENTRY(struct rte_flow_action_vf, id)), .call = parse_vc_conf, diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 550a4c95b..a0a124aa2 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -528,15 +528,12 @@ Usage example, matching non-TCPv4 packets only: Item: ``PF`` ^^^^^^^^^^^^ -Matches packets addressed to the physical function of the device. +Matches traffic originating from (ingress) or going to (egress) the physical +function of the current device. -If the underlying device function differs from the one that would normally -receive the matched traffic, specifying this item prevents it from reaching -that device unless the flow rule contains a `Action: PF`_. Packets are not -duplicated between device instances by default. +If supported, should work even if the physical function is not managed by +the application and thus not associated with a DPDK port ID. -- Likely to return an error or never match any traffic if applied to a VF - device. - Can be combined with any number of `Item: VF`_ to match both PF and VF traffic. - ``spec``, ``last`` and ``mask`` must not be set. @@ -558,15 +555,15 @@ duplicated between device instances by default. Item: ``VF`` ^^^^^^^^^^^^ -Matches packets addressed to a virtual function ID of the device. +Matches traffic originating from (ingress) or going to (egress) a given +virtual function of the current device. -If the underlying device function differs from the one that would normally -receive the matched traffic, specifying this item prevents it from reaching -that device unless the flow rule contains a `Action: VF`_. Packets are not -duplicated between device instances by default. +If supported, should work even if the virtual function is not managed by the +application and thus not associated with a DPDK port ID. + +Note this pattern item does not match VF representors traffic which, as +separate entities, should be addressed through their own DPDK port IDs. -- Likely to return an error or never match any traffic if this causes a VF - device to match traffic addressed to a different VF. - Can be specified multiple times to match traffic addressed to several VF IDs. - Can be combined with a PF item to match both PF and VF traffic. @@ -1395,7 +1392,10 @@ only matching traffic goes through. Action: ``PF`` ^^^^^^^^^^^^^^ -Redirects packets to the physical function (PF) of the current device. +Directs matching traffic to the physical function (PF) of the current +device. + +See `Item: PF`_. - No configurable properties. @@ -1412,13 +1412,15 @@ Redirects packets to the physical function (PF) of the current device. Action: ``VF`` ^^^^^^^^^^^^^^ -Redirects packets to a virtual function (VF) of the current device. +Directs matching traffic to a given virtual function of the current device. Packets matched by a VF pattern item can be redirected to their original VF ID instead of the specified one. This parameter may not be available and is not guaranteed to work properly if the VF part is matched by a prior flow rule or if packets are not addressed to a VF in the first place. +See `Item: VF`_. + .. _table_rte_flow_action_vf: .. table:: VF @@ -1428,7 +1430,7 @@ rule or if packets are not addressed to a VF in the first place. +==============+================================+ | ``original`` | use original VF ID if possible | +--------------+--------------------------------+ - | ``vf`` | VF ID to redirect packets to | + | ``id`` | VF ID | +--------------+--------------------------------+ Action: ``METER`` diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index 0bf6c33c9..af37c3d82 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3202,11 +3202,11 @@ This section lists supported pattern items and their attributes, if any. - ``num {unsigned}``: number of layers covered. -- ``pf``: match packets addressed to the physical function. +- ``pf``: match traffic from/to the physical function. -- ``vf``: match packets addressed to a virtual function ID. +- ``vf``: match traffic from/to a virtual function ID. - - ``id {unsigned}``: destination VF ID. + - ``id {unsigned}``: VF ID. - ``port``: device-specific physical port index to use. @@ -3416,12 +3416,12 @@ This section lists supported actions and their attributes, if any. - ``queues [{unsigned} [...]] end``: queue indices to use. -- ``pf``: redirect packets to physical device function. +- ``pf``: direct traffic to physical function. -- ``vf``: redirect packets to virtual device function. +- ``vf``: direct traffic to a virtual function ID. - ``original {boolean}``: use original VF ID if possible. - - ``id {unsigned}``: VF ID to redirect packets to. + - ``id {unsigned}``: VF ID. Destroying flow rules ~~~~~~~~~~~~~~~~~~~~~ diff --git a/drivers/net/bnxt/bnxt_filter.c b/drivers/net/bnxt/bnxt_filter.c index bd166370a..f964b5ea4 100644 --- a/drivers/net/bnxt/bnxt_filter.c +++ b/drivers/net/bnxt/bnxt_filter.c @@ -275,6 +275,7 @@ bnxt_filter_type_check(const struct rte_flow_item pattern[], static int bnxt_validate_and_parse_flow_type(struct bnxt *bp, + const struct rte_flow_attr *attr, const struct rte_flow_item pattern[], struct rte_flow_error *error, struct bnxt_filter_info *filter) @@ -699,6 +700,16 @@ bnxt_validate_and_parse_flow_type(struct bnxt *bp, return -rte_errno; } + if (!attr->transfer) { + rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ITEM, + item, + "Matching VF traffic without" + " affecting it (transfer attribute)" + " is unsupported"); + return -rte_errno; + } + filter->mirror_vnic_id = dflt_vnic = bnxt_hwrm_func_qcfg_vf_dflt_vnic_id(bp, vf); if (dflt_vnic < 0) { @@ -746,14 +757,6 @@ bnxt_flow_parse_attr(const struct rte_flow_attr *attr, } /* Not supported */ - if (attr->transfer) { - rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, - attr, "No support for transfer."); - return -rte_errno; - } - - /* Not supported */ if (attr->priority) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, @@ -833,7 +836,8 @@ bnxt_validate_and_parse_flow(struct rte_eth_dev *dev, goto ret; } - rc = bnxt_validate_and_parse_flow_type(bp, pattern, error, filter); + rc = bnxt_validate_and_parse_flow_type(bp, attr, pattern, error, + filter); if (rc != 0) goto ret; diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c index b004357f1..b0aee0ef7 100644 --- a/drivers/net/i40e/i40e_flow.c +++ b/drivers/net/i40e/i40e_flow.c @@ -54,6 +54,7 @@ static int i40e_flow_parse_ethertype_action(struct rte_eth_dev *dev, struct rte_flow_error *error, struct rte_eth_ethertype_filter *filter); static int i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev, + const struct rte_flow_attr *attr, const struct rte_flow_item *pattern, struct rte_flow_error *error, struct i40e_fdir_filter_conf *filter); @@ -1918,14 +1919,6 @@ i40e_flow_parse_attr(const struct rte_flow_attr *attr, } /* Not supported */ - if (attr->transfer) { - rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, - attr, "No support for transfer."); - return -rte_errno; - } - - /* Not supported */ if (attr->priority) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, @@ -2429,6 +2422,7 @@ i40e_flow_fdir_get_pctype_value(struct i40e_pf *pf, */ static int i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev, + const struct rte_flow_attr *attr, const struct rte_flow_item *pattern, struct rte_flow_error *error, struct i40e_fdir_filter_conf *filter) @@ -2966,6 +2960,16 @@ i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev, break; case RTE_FLOW_ITEM_TYPE_VF: vf_spec = item->spec; + if (!attr->transfer) { + rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ITEM, + item, + "Matching VF traffic" + " without affecting it" + " (transfer attribute)" + " is unsupported"); + return -rte_errno; + } filter->input.flow_ext.is_vf = 1; filter->input.flow_ext.dst_id = vf_spec->id; if (filter->input.flow_ext.is_vf && @@ -3128,7 +3132,8 @@ i40e_flow_parse_fdir_filter(struct rte_eth_dev *dev, &filter->fdir_filter; int ret; - ret = i40e_flow_parse_fdir_pattern(dev, pattern, error, fdir_filter); + ret = i40e_flow_parse_fdir_pattern(dev, attr, pattern, error, + fdir_filter); if (ret) return ret; diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index fc7df68d3..f3db2ec01 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -152,13 +152,8 @@ enum rte_flow_item_type { /** * [META] * - * Matches packets addressed to the physical function of the device. - * - * If the underlying device function differs from the one that would - * normally receive the matched traffic, specifying this item - * prevents it from reaching that device unless the flow rule - * contains a PF action. Packets are not duplicated between device - * instances by default. + * Matches traffic originating from (ingress) or going to (egress) + * the physical function of the current device. * * No associated specification structure. */ @@ -167,13 +162,8 @@ enum rte_flow_item_type { /** * [META] * - * Matches packets addressed to a virtual function ID of the device. - * - * If the underlying device function differs from the one that would - * normally receive the matched traffic, specifying this item - * prevents it from reaching that device unless the flow rule - * contains a VF action. Packets are not duplicated between device - * instances by default. + * Matches traffic originating from (ingress) or going to (egress) a + * given virtual function of the current device. * * See struct rte_flow_item_vf. */ @@ -371,15 +361,15 @@ static const struct rte_flow_item_any rte_flow_item_any_mask = { /** * RTE_FLOW_ITEM_TYPE_VF * - * Matches packets addressed to a virtual function ID of the device. + * Matches traffic originating from (ingress) or going to (egress) a given + * virtual function of the current device. * - * If the underlying device function differs from the one that would - * normally receive the matched traffic, specifying this item prevents it - * from reaching that device unless the flow rule contains a VF - * action. Packets are not duplicated between device instances by default. + * If supported, should work even if the virtual function is not managed by + * the application and thus not associated with a DPDK port ID. + * + * Note this pattern item does not match VF representors traffic which, as + * separate entities, should be addressed through their own DPDK port IDs. * - * - Likely to return an error or never match any traffic if this causes a - * VF device to match traffic addressed to a different VF. * - Can be specified multiple times to match traffic addressed to several * VF IDs. * - Can be combined with a PF item to match both PF and VF traffic. @@ -387,7 +377,7 @@ static const struct rte_flow_item_any rte_flow_item_any_mask = { * A zeroed mask can be used to match any VF ID. */ struct rte_flow_item_vf { - uint32_t id; /**< Destination VF ID. */ + uint32_t id; /**< VF ID. */ }; /** Default mask for RTE_FLOW_ITEM_TYPE_VF. */ @@ -988,16 +978,16 @@ enum rte_flow_action_type { RTE_FLOW_ACTION_TYPE_RSS, /** - * Redirects packets to the physical function (PF) of the current - * device. + * Directs matching traffic to the physical function (PF) of the + * current device. * * No associated configuration structure. */ RTE_FLOW_ACTION_TYPE_PF, /** - * Redirects packets to the virtual function (VF) of the current - * device with the specified ID. + * Directs matching traffic to a given virtual function of the + * current device. * * See struct rte_flow_action_vf. */ @@ -1111,7 +1101,8 @@ struct rte_flow_action_rss { /** * RTE_FLOW_ACTION_TYPE_VF * - * Redirects packets to a virtual function (VF) of the current device. + * Directs matching traffic to a given virtual function of the current + * device. * * Packets matched by a VF pattern item can be redirected to their original * VF ID instead of the specified one. This parameter may not be available @@ -1122,7 +1113,7 @@ struct rte_flow_action_rss { struct rte_flow_action_vf { uint32_t original:1; /**< Use original VF ID if possible. */ uint32_t reserved:31; /**< Reserved, must be zero. */ - uint32_t id; /**< VF ID to redirect packets to. */ + uint32_t id; /**< VF ID. */ }; /** -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v3 14/16] ethdev: rename physical port item in flow API 2018-04-10 16:36 ` [dpdk-dev] [PATCH v3 00/16] Flow API overhaul for switch offloads Adrien Mazarguil ` (12 preceding siblings ...) 2018-04-10 16:37 ` [dpdk-dev] [PATCH v3 13/16] ethdev: update behavior of VF/PF in " Adrien Mazarguil @ 2018-04-10 16:37 ` Adrien Mazarguil 2018-04-11 12:57 ` Andrew Rybchenko 2018-04-10 16:37 ` [dpdk-dev] [PATCH v3 15/16] ethdev: add physical port action to " Adrien Mazarguil ` (2 subsequent siblings) 16 siblings, 1 reply; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-10 16:37 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev While RTE_FLOW_ITEM_TYPE_PORT refers to physical ports of the underlying device using specific identifiers, these are often confused with DPDK port IDs exposed to applications in the global name space. Since this pattern item is seldom used, rename it RTE_FLOW_ITEM_PHY_PORT for better clarity. No ABI impact. Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> --- app/test-pmd/cmdline_flow.c | 27 +++++++++++---------- app/test-pmd/config.c | 2 +- doc/guides/prog_guide/rte_flow.rst | 22 ++++++++--------- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 2 +- lib/librte_ether/rte_flow.c | 2 +- lib/librte_ether/rte_flow.h | 31 ++++++++++-------------- 6 files changed, 41 insertions(+), 45 deletions(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index af0631036..a0dbec119 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -87,8 +87,8 @@ enum index { ITEM_PF, ITEM_VF, ITEM_VF_ID, - ITEM_PORT, - ITEM_PORT_INDEX, + ITEM_PHY_PORT, + ITEM_PHY_PORT_INDEX, ITEM_RAW, ITEM_RAW_RELATIVE, ITEM_RAW_SEARCH, @@ -441,7 +441,7 @@ static const enum index next_item[] = { ITEM_ANY, ITEM_PF, ITEM_VF, - ITEM_PORT, + ITEM_PHY_PORT, ITEM_RAW, ITEM_ETH, ITEM_VLAN, @@ -482,8 +482,8 @@ static const enum index item_vf[] = { ZERO, }; -static const enum index item_port[] = { - ITEM_PORT_INDEX, +static const enum index item_phy_port[] = { + ITEM_PHY_PORT_INDEX, ITEM_NEXT, ZERO, }; @@ -1059,18 +1059,19 @@ static const struct token token_list[] = { .next = NEXT(item_vf, NEXT_ENTRY(UNSIGNED), item_param), .args = ARGS(ARGS_ENTRY(struct rte_flow_item_vf, id)), }, - [ITEM_PORT] = { - .name = "port", - .help = "device-specific physical port index to use", - .priv = PRIV_ITEM(PORT, sizeof(struct rte_flow_item_port)), - .next = NEXT(item_port), + [ITEM_PHY_PORT] = { + .name = "phy_port", + .help = "match traffic from/to a specific physical port", + .priv = PRIV_ITEM(PHY_PORT, + sizeof(struct rte_flow_item_phy_port)), + .next = NEXT(item_phy_port), .call = parse_vc, }, - [ITEM_PORT_INDEX] = { + [ITEM_PHY_PORT_INDEX] = { .name = "index", .help = "physical port index", - .next = NEXT(item_port, NEXT_ENTRY(UNSIGNED), item_param), - .args = ARGS(ARGS_ENTRY(struct rte_flow_item_port, index)), + .next = NEXT(item_phy_port, NEXT_ENTRY(UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_phy_port, index)), }, [ITEM_RAW] = { .name = "raw", diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 49ef87782..9f968919e 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -960,7 +960,7 @@ static const struct { MK_FLOW_ITEM(ANY, sizeof(struct rte_flow_item_any)), MK_FLOW_ITEM(PF, 0), MK_FLOW_ITEM(VF, sizeof(struct rte_flow_item_vf)), - MK_FLOW_ITEM(PORT, sizeof(struct rte_flow_item_port)), + MK_FLOW_ITEM(PHY_PORT, sizeof(struct rte_flow_item_phy_port)), MK_FLOW_ITEM(RAW, sizeof(struct rte_flow_item_raw)), MK_FLOW_ITEM(ETH, sizeof(struct rte_flow_item_eth)), MK_FLOW_ITEM(VLAN, sizeof(struct rte_flow_item_vlan)), diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index a0a124aa2..4e053c24b 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -195,8 +195,8 @@ When supported, this effectively enables an application to reroute traffic not necessarily intended for it (e.g. coming from or addressed to different physical ports, VFs or applications) at the device level. -It complements the behavior of some pattern items such as `Item: PORT`_ and -is meaningless without them. +It complements the behavior of some pattern items such as `Item: PHY_PORT`_ +and is meaningless without them. When transferring flow rules, **ingress** and **egress** attributes (`Attribute: Traffic direction`_) keep their original meaning, as if @@ -583,15 +583,15 @@ separate entities, should be addressed through their own DPDK port IDs. | ``mask`` | ``id`` | zeroed to match any VF ID | +----------+----------+---------------------------+ -Item: ``PORT`` -^^^^^^^^^^^^^^ +Item: ``PHY_PORT`` +^^^^^^^^^^^^^^^^^^ -Matches packets coming from the specified physical port of the underlying -device. +Matches traffic originating from (ingress) or going to (egress) a physical +port of the underlying device. -The first PORT item overrides the physical port normally associated with the -specified DPDK input port (port_id). This item can be provided several times -to match additional physical ports. +The first PHY_PORT item overrides the physical port normally associated with +the specified DPDK input port (port_id). This item can be provided several +times to match additional physical ports. Note that physical ports are not necessarily tied to DPDK input ports (port_id) when those are not under DPDK control. Possible values are @@ -603,9 +603,9 @@ associated with a port_id should be retrieved by other means. - Default ``mask`` matches any port index. -.. _table_rte_flow_item_port: +.. _table_rte_flow_item_phy_port: -.. table:: PORT +.. table:: PHY_PORT +----------+-----------+--------------------------------+ | Field | Subfield | Value | diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index af37c3d82..a2bbd1930 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3208,7 +3208,7 @@ This section lists supported pattern items and their attributes, if any. - ``id {unsigned}``: VF ID. -- ``port``: device-specific physical port index to use. +- ``phy_port``: match traffic from/to a specific physical port. - ``index {unsigned}``: physical port index. diff --git a/lib/librte_ether/rte_flow.c b/lib/librte_ether/rte_flow.c index 1f247d656..6d4d7f5ed 100644 --- a/lib/librte_ether/rte_flow.c +++ b/lib/librte_ether/rte_flow.c @@ -38,7 +38,7 @@ static const struct rte_flow_desc_data rte_flow_desc_item[] = { MK_FLOW_ITEM(ANY, sizeof(struct rte_flow_item_any)), MK_FLOW_ITEM(PF, 0), MK_FLOW_ITEM(VF, sizeof(struct rte_flow_item_vf)), - MK_FLOW_ITEM(PORT, sizeof(struct rte_flow_item_port)), + MK_FLOW_ITEM(PHY_PORT, sizeof(struct rte_flow_item_phy_port)), MK_FLOW_ITEM(RAW, sizeof(struct rte_flow_item_raw)), MK_FLOW_ITEM(ETH, sizeof(struct rte_flow_item_eth)), MK_FLOW_ITEM(VLAN, sizeof(struct rte_flow_item_vlan)), diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index f3db2ec01..ed211a8eb 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -84,7 +84,7 @@ struct rte_flow_attr { * applications) at the device level. * * It complements the behavior of some pattern items such as - * RTE_FLOW_ITEM_TYPE_PORT and is meaningless without them. + * RTE_FLOW_ITEM_TYPE_PHY_PORT and is meaningless without them. * * When transferring flow rules, ingress and egress attributes keep * their original meaning, as if processing traffic emitted or @@ -172,17 +172,12 @@ enum rte_flow_item_type { /** * [META] * - * Matches packets coming from the specified physical port of the - * underlying device. - * - * The first PORT item overrides the physical port normally - * associated with the specified DPDK input port (port_id). This - * item can be provided several times to match additional physical - * ports. + * Matches traffic originating from (ingress) or going to (egress) a + * physical port of the underlying device. * - * See struct rte_flow_item_port. + * See struct rte_flow_item_phy_port. */ - RTE_FLOW_ITEM_TYPE_PORT, + RTE_FLOW_ITEM_TYPE_PHY_PORT, /** * Matches a byte string of a given length at a given offset. @@ -388,13 +383,13 @@ static const struct rte_flow_item_vf rte_flow_item_vf_mask = { #endif /** - * RTE_FLOW_ITEM_TYPE_PORT + * RTE_FLOW_ITEM_TYPE_PHY_PORT * - * Matches packets coming from the specified physical port of the underlying - * device. + * Matches traffic originating from (ingress) or going to (egress) a + * physical port of the underlying device. * - * The first PORT item overrides the physical port normally associated with - * the specified DPDK input port (port_id). This item can be provided + * The first PHY_PORT item overrides the physical port normally associated + * with the specified DPDK input port (port_id). This item can be provided * several times to match additional physical ports. * * Note that physical ports are not necessarily tied to DPDK input ports @@ -407,13 +402,13 @@ static const struct rte_flow_item_vf rte_flow_item_vf_mask = { * * A zeroed mask can be used to match any port index. */ -struct rte_flow_item_port { +struct rte_flow_item_phy_port { uint32_t index; /**< Physical port index. */ }; -/** Default mask for RTE_FLOW_ITEM_TYPE_PORT. */ +/** Default mask for RTE_FLOW_ITEM_TYPE_PHY_PORT. */ #ifndef __cplusplus -static const struct rte_flow_item_port rte_flow_item_port_mask = { +static const struct rte_flow_item_phy_port rte_flow_item_phy_port_mask = { .index = 0x00000000, }; #endif -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [dpdk-dev] [PATCH v3 14/16] ethdev: rename physical port item in flow API 2018-04-10 16:37 ` [dpdk-dev] [PATCH v3 14/16] ethdev: rename physical port item " Adrien Mazarguil @ 2018-04-11 12:57 ` Andrew Rybchenko 0 siblings, 0 replies; 157+ messages in thread From: Andrew Rybchenko @ 2018-04-11 12:57 UTC (permalink / raw) To: Adrien Mazarguil, Thomas Monjalon, Ferruh Yigit, dev On 04/10/2018 07:37 PM, Adrien Mazarguil wrote: > While RTE_FLOW_ITEM_TYPE_PORT refers to physical ports of the underlying > device using specific identifiers, these are often confused with DPDK port > IDs exposed to applications in the global name space. > > Since this pattern item is seldom used, rename it RTE_FLOW_ITEM_PHY_PORT > for better clarity. > > No ABI impact. > > Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> > --- > app/test-pmd/cmdline_flow.c | 27 +++++++++++---------- > app/test-pmd/config.c | 2 +- > doc/guides/prog_guide/rte_flow.rst | 22 ++++++++--------- > doc/guides/testpmd_app_ug/testpmd_funcs.rst | 2 +- > lib/librte_ether/rte_flow.c | 2 +- > lib/librte_ether/rte_flow.h | 31 ++++++++++-------------- > 6 files changed, 41 insertions(+), 45 deletions(-) Acked-by: Andrew Rybchenko <arybchenko@solarflare.com> ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v3 15/16] ethdev: add physical port action to flow API 2018-04-10 16:36 ` [dpdk-dev] [PATCH v3 00/16] Flow API overhaul for switch offloads Adrien Mazarguil ` (13 preceding siblings ...) 2018-04-10 16:37 ` [dpdk-dev] [PATCH v3 14/16] ethdev: rename physical port item " Adrien Mazarguil @ 2018-04-10 16:37 ` Adrien Mazarguil 2018-04-11 13:00 ` Andrew Rybchenko 2018-04-10 16:37 ` [dpdk-dev] [PATCH v3 16/16] ethdev: add port ID item and " Adrien Mazarguil 2018-04-16 16:22 ` [dpdk-dev] [PATCH v4 00/16] Flow API overhaul for switch offloads Adrien Mazarguil 16 siblings, 1 reply; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-10 16:37 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev; +Cc: Zhang, Qi Z This patch adds the missing action counterpart to the PHY_PORT pattern item, that is, the ability to directly inject matching traffic into a physical port of the underlying device. It breaks ABI compatibility for the following public functions: - rte_flow_copy() - rte_flow_create() - rte_flow_query() - rte_flow_validate() Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Cc: "Zhang, Qi Z" <qi.z.zhang@intel.com> --- app/test-pmd/cmdline_flow.c | 35 ++++++++++++++++++++++++ app/test-pmd/config.c | 1 + doc/guides/prog_guide/rte_flow.rst | 20 ++++++++++++++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 5 ++++ lib/librte_ether/rte_flow.c | 1 + lib/librte_ether/rte_flow.h | 22 +++++++++++++++ 6 files changed, 84 insertions(+) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index a0dbec119..cc78b4f2c 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -182,6 +182,9 @@ enum index { ACTION_VF, ACTION_VF_ORIGINAL, ACTION_VF_ID, + ACTION_PHY_PORT, + ACTION_PHY_PORT_ORIGINAL, + ACTION_PHY_PORT_INDEX, ACTION_METER, ACTION_METER_ID, }; @@ -623,6 +626,7 @@ static const enum index next_action[] = { ACTION_RSS, ACTION_PF, ACTION_VF, + ACTION_PHY_PORT, ACTION_METER, ZERO, }; @@ -657,6 +661,13 @@ static const enum index action_vf[] = { ZERO, }; +static const enum index action_phy_port[] = { + ACTION_PHY_PORT_ORIGINAL, + ACTION_PHY_PORT_INDEX, + ACTION_NEXT, + ZERO, +}; + static const enum index action_meter[] = { ACTION_METER_ID, ACTION_NEXT, @@ -1714,6 +1725,30 @@ static const struct token token_list[] = { .args = ARGS(ARGS_ENTRY(struct rte_flow_action_vf, id)), .call = parse_vc_conf, }, + [ACTION_PHY_PORT] = { + .name = "phy_port", + .help = "direct packets to physical port index", + .priv = PRIV_ACTION(PHY_PORT, + sizeof(struct rte_flow_action_phy_port)), + .next = NEXT(action_phy_port), + .call = parse_vc, + }, + [ACTION_PHY_PORT_ORIGINAL] = { + .name = "original", + .help = "use original port index if possible", + .next = NEXT(action_phy_port, NEXT_ENTRY(BOOLEAN)), + .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_phy_port, + original, 1)), + .call = parse_vc_conf, + }, + [ACTION_PHY_PORT_INDEX] = { + .name = "index", + .help = "physical port index", + .next = NEXT(action_phy_port, NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_phy_port, + index)), + .call = parse_vc_conf, + }, [ACTION_METER] = { .name = "meter", .help = "meter the directed packets at given id", diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 9f968919e..effb4ff81 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -1058,6 +1058,7 @@ static const struct { MK_FLOW_ACTION(RSS, sizeof(struct rte_flow_action_rss)), MK_FLOW_ACTION(PF, 0), MK_FLOW_ACTION(VF, sizeof(struct rte_flow_action_vf)), + MK_FLOW_ACTION(PHY_PORT, sizeof(struct rte_flow_action_phy_port)), MK_FLOW_ACTION(METER, sizeof(struct rte_flow_action_meter)), }; diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 4e053c24b..a39c1e1b0 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -1433,6 +1433,26 @@ See `Item: VF`_. | ``id`` | VF ID | +--------------+--------------------------------+ +Action: ``PHY_PORT`` +^^^^^^^^^^^^^^^^^^^^ + +Directs matching traffic to a given physical port index of the underlying +device. + +See `Item: PHY_PORT`_. + +.. _table_rte_flow_action_phy_port: + +.. table:: PHY_PORT + + +--------------+-------------------------------------+ + | Field | Value | + +==============+=====================================+ + | ``original`` | use original port index if possible | + +--------------+-------------------------------------+ + | ``index`` | physical port index | + +--------------+-------------------------------------+ + Action: ``METER`` ^^^^^^^^^^^^^^^^^ diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index a2bbd1930..64d8dfddb 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3423,6 +3423,11 @@ This section lists supported actions and their attributes, if any. - ``original {boolean}``: use original VF ID if possible. - ``id {unsigned}``: VF ID. +- ``phy_port``: direct packets to physical port index. + + - ``original {boolean}``: use original port index if possible. + - ``index {unsigned}``: physical port index. + Destroying flow rules ~~~~~~~~~~~~~~~~~~~~~ diff --git a/lib/librte_ether/rte_flow.c b/lib/librte_ether/rte_flow.c index 6d4d7f5ed..e0fd78dd5 100644 --- a/lib/librte_ether/rte_flow.c +++ b/lib/librte_ether/rte_flow.c @@ -76,6 +76,7 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = { MK_FLOW_ACTION(RSS, sizeof(struct rte_flow_action_rss)), MK_FLOW_ACTION(PF, 0), MK_FLOW_ACTION(VF, sizeof(struct rte_flow_action_vf)), + MK_FLOW_ACTION(PHY_PORT, sizeof(struct rte_flow_action_phy_port)), }; static int diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index ed211a8eb..c3ae0c6a8 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -989,6 +989,14 @@ enum rte_flow_action_type { RTE_FLOW_ACTION_TYPE_VF, /** + * Directs packets to a given physical port index of the underlying + * device. + * + * See struct rte_flow_action_phy_port. + */ + RTE_FLOW_ACTION_TYPE_PHY_PORT, + + /** * Traffic metering and policing (MTR). * * See struct rte_flow_action_meter. @@ -1112,6 +1120,20 @@ struct rte_flow_action_vf { }; /** + * RTE_FLOW_ACTION_TYPE_PHY_PORT + * + * Directs packets to a given physical port index of the underlying + * device. + * + * @see RTE_FLOW_ITEM_TYPE_PHY_PORT + */ +struct rte_flow_action_phy_port { + uint32_t original:1; /**< Use original port index if possible. */ + uint32_t reserved:31; /**< Reserved, must be zero. */ + uint32_t index; /**< Physical port index. */ +}; + +/** * RTE_FLOW_ACTION_TYPE_METER * * Traffic metering and policing (MTR). -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [dpdk-dev] [PATCH v3 15/16] ethdev: add physical port action to flow API 2018-04-10 16:37 ` [dpdk-dev] [PATCH v3 15/16] ethdev: add physical port action to " Adrien Mazarguil @ 2018-04-11 13:00 ` Andrew Rybchenko 0 siblings, 0 replies; 157+ messages in thread From: Andrew Rybchenko @ 2018-04-11 13:00 UTC (permalink / raw) To: Adrien Mazarguil, Thomas Monjalon, Ferruh Yigit, dev; +Cc: Zhang, Qi Z On 04/10/2018 07:37 PM, Adrien Mazarguil wrote: > This patch adds the missing action counterpart to the PHY_PORT pattern > item, that is, the ability to directly inject matching traffic into a > physical port of the underlying device. > > It breaks ABI compatibility for the following public functions: > > - rte_flow_copy() > - rte_flow_create() > - rte_flow_query() > - rte_flow_validate() > > Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> > Cc: "Zhang, Qi Z" <qi.z.zhang@intel.com> > --- > app/test-pmd/cmdline_flow.c | 35 ++++++++++++++++++++++++ > app/test-pmd/config.c | 1 + > doc/guides/prog_guide/rte_flow.rst | 20 ++++++++++++++ > doc/guides/testpmd_app_ug/testpmd_funcs.rst | 5 ++++ > lib/librte_ether/rte_flow.c | 1 + > lib/librte_ether/rte_flow.h | 22 +++++++++++++++ > 6 files changed, 84 insertions(+) Acked-by: Andrew Rybchenko <arybchenko@solarflare.com> ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v3 16/16] ethdev: add port ID item and action to flow API 2018-04-10 16:36 ` [dpdk-dev] [PATCH v3 00/16] Flow API overhaul for switch offloads Adrien Mazarguil ` (14 preceding siblings ...) 2018-04-10 16:37 ` [dpdk-dev] [PATCH v3 15/16] ethdev: add physical port action to " Adrien Mazarguil @ 2018-04-10 16:37 ` Adrien Mazarguil 2018-04-11 13:02 ` Andrew Rybchenko 2018-04-16 16:22 ` [dpdk-dev] [PATCH v4 00/16] Flow API overhaul for switch offloads Adrien Mazarguil 16 siblings, 1 reply; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-10 16:37 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev; +Cc: Zhang, Qi Z, Declan Doherty RTE_FLOW_ACTION_TYPE_PORT_ID brings the ability to inject matching traffic into a different device, as identified by its DPDK port ID. This is normally only supported when the target port ID has some kind of relationship with the port ID the flow rule is created against, such as being exposed by a common physical device (e.g. a different port of an Ethernet switch). The converse pattern item, RTE_FLOW_ITEM_TYPE_PORT_ID, makes the resulting flow rule match traffic whose origin is the specified port ID. Note that specifying a port ID that differs from the one the flow rule is created against is normally meaningless (if even accepted), but can make sense if combined with the transfer attribute. These must not be confused with their PHY_PORT counterparts, which refer to physical ports using device-specific indices, but unlike PORT_ID are not necessarily tied to DPDK port IDs. This breaks ABI compatibility for the following public functions: - rte_flow_copy() - rte_flow_create() - rte_flow_query() - rte_flow_validate() Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Reviewed-by: Qi Zhang <qi.z.zhang@intel.com> Cc: "Zhang, Qi Z" <qi.z.zhang@intel.com> Cc: Declan Doherty <declan.doherty@intel.com> --- This patch provides the same functionality and supersedes Qi Zhang's "ether: add flow action to redirect packet to a port" [1]. The main differences are: - Action is named PORT_ID instead of PORT. - Addition of a PORT_ID pattern item. - More extensive documentation. - Testpmd support. - rte_flow_copy() support. [1] http://dpdk.org/ml/archives/dev/2018-April/094648.html --- app/test-pmd/cmdline_flow.c | 57 ++++++++++++++++++++++++ app/test-pmd/config.c | 2 + doc/guides/prog_guide/rte_flow.rst | 48 ++++++++++++++++++++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 9 ++++ lib/librte_ether/rte_flow.c | 2 + lib/librte_ether/rte_flow.h | 56 +++++++++++++++++++++++ 6 files changed, 174 insertions(+) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index cc78b4f2c..fae3c4b12 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -89,6 +89,8 @@ enum index { ITEM_VF_ID, ITEM_PHY_PORT, ITEM_PHY_PORT_INDEX, + ITEM_PORT_ID, + ITEM_PORT_ID_ID, ITEM_RAW, ITEM_RAW_RELATIVE, ITEM_RAW_SEARCH, @@ -185,6 +187,9 @@ enum index { ACTION_PHY_PORT, ACTION_PHY_PORT_ORIGINAL, ACTION_PHY_PORT_INDEX, + ACTION_PORT_ID, + ACTION_PORT_ID_ORIGINAL, + ACTION_PORT_ID_ID, ACTION_METER, ACTION_METER_ID, }; @@ -445,6 +450,7 @@ static const enum index next_item[] = { ITEM_PF, ITEM_VF, ITEM_PHY_PORT, + ITEM_PORT_ID, ITEM_RAW, ITEM_ETH, ITEM_VLAN, @@ -491,6 +497,12 @@ static const enum index item_phy_port[] = { ZERO, }; +static const enum index item_port_id[] = { + ITEM_PORT_ID_ID, + ITEM_NEXT, + ZERO, +}; + static const enum index item_raw[] = { ITEM_RAW_RELATIVE, ITEM_RAW_SEARCH, @@ -627,6 +639,7 @@ static const enum index next_action[] = { ACTION_PF, ACTION_VF, ACTION_PHY_PORT, + ACTION_PORT_ID, ACTION_METER, ZERO, }; @@ -668,6 +681,13 @@ static const enum index action_phy_port[] = { ZERO, }; +static const enum index action_port_id[] = { + ACTION_PORT_ID_ORIGINAL, + ACTION_PORT_ID_ID, + ACTION_NEXT, + ZERO, +}; + static const enum index action_meter[] = { ACTION_METER_ID, ACTION_NEXT, @@ -1084,6 +1104,20 @@ static const struct token token_list[] = { .next = NEXT(item_phy_port, NEXT_ENTRY(UNSIGNED), item_param), .args = ARGS(ARGS_ENTRY(struct rte_flow_item_phy_port, index)), }, + [ITEM_PORT_ID] = { + .name = "port_id", + .help = "match traffic from/to a given DPDK port ID", + .priv = PRIV_ITEM(PORT_ID, + sizeof(struct rte_flow_item_port_id)), + .next = NEXT(item_port_id), + .call = parse_vc, + }, + [ITEM_PORT_ID_ID] = { + .name = "id", + .help = "DPDK port ID", + .next = NEXT(item_port_id, NEXT_ENTRY(UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_port_id, id)), + }, [ITEM_RAW] = { .name = "raw", .help = "match an arbitrary byte string", @@ -1749,6 +1783,29 @@ static const struct token token_list[] = { index)), .call = parse_vc_conf, }, + [ACTION_PORT_ID] = { + .name = "port_id", + .help = "direct matching traffic to a given DPDK port ID", + .priv = PRIV_ACTION(PORT_ID, + sizeof(struct rte_flow_action_port_id)), + .next = NEXT(action_port_id), + .call = parse_vc, + }, + [ACTION_PORT_ID_ORIGINAL] = { + .name = "original", + .help = "use original DPDK port ID if possible", + .next = NEXT(action_port_id, NEXT_ENTRY(BOOLEAN)), + .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_port_id, + original, 1)), + .call = parse_vc_conf, + }, + [ACTION_PORT_ID_ID] = { + .name = "id", + .help = "DPDK port ID", + .next = NEXT(action_port_id, NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_port_id, id)), + .call = parse_vc_conf, + }, [ACTION_METER] = { .name = "meter", .help = "meter the directed packets at given id", diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index effb4ff81..4a273eff7 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -961,6 +961,7 @@ static const struct { MK_FLOW_ITEM(PF, 0), MK_FLOW_ITEM(VF, sizeof(struct rte_flow_item_vf)), MK_FLOW_ITEM(PHY_PORT, sizeof(struct rte_flow_item_phy_port)), + MK_FLOW_ITEM(PORT_ID, sizeof(struct rte_flow_item_port_id)), MK_FLOW_ITEM(RAW, sizeof(struct rte_flow_item_raw)), MK_FLOW_ITEM(ETH, sizeof(struct rte_flow_item_eth)), MK_FLOW_ITEM(VLAN, sizeof(struct rte_flow_item_vlan)), @@ -1059,6 +1060,7 @@ static const struct { MK_FLOW_ACTION(PF, 0), MK_FLOW_ACTION(VF, sizeof(struct rte_flow_action_vf)), MK_FLOW_ACTION(PHY_PORT, sizeof(struct rte_flow_action_phy_port)), + MK_FLOW_ACTION(PORT_ID, sizeof(struct rte_flow_action_port_id)), MK_FLOW_ACTION(METER, sizeof(struct rte_flow_action_meter)), }; diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index a39c1e1b0..2fb8e9c3f 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -617,6 +617,36 @@ associated with a port_id should be retrieved by other means. | ``mask`` | ``index`` | zeroed to match any port index | +----------+-----------+--------------------------------+ +Item: ``PORT_ID`` +^^^^^^^^^^^^^^^^^ + +Matches traffic originating from (ingress) or going to (egress) a given DPDK +port ID. + +Normally only supported if the port ID in question is known by the +underlying PMD and related to the device the flow rule is created against. + +This must not be confused with `Item: PHY_PORT`_ which refers to the +physical port of a device, whereas `Item: PORT_ID`_ refers to a ``struct +rte_eth_dev`` object on the application side (also known as "port +representor" depending on the kind of underlying device). + +- Default ``mask`` matches the specified DPDK port ID. + +.. _table_rte_flow_item_port_id: + +.. table:: PORT_ID + + +----------+----------+-----------------------------+ + | Field | Subfield | Value | + +==========+==========+=============================+ + | ``spec`` | ``id`` | DPDK port ID | + +----------+----------+-----------------------------+ + | ``last`` | ``id`` | upper range value | + +----------+----------+-----------------------------+ + | ``mask`` | ``id`` | zeroed to match any port ID | + +----------+----------+-----------------------------+ + Data matching item types ~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1453,6 +1483,24 @@ See `Item: PHY_PORT`_. | ``index`` | physical port index | +--------------+-------------------------------------+ +Action: ``PORT_ID`` +^^^^^^^^^^^^^^^^^^^ +Directs matching traffic to a given DPDK port ID. + +See `Item: PORT_ID`_. + +.. _table_rte_flow_action_port_id: + +.. table:: PORT_ID + + +--------------+---------------------------------------+ + | Field | Value | + +==============+=======================================+ + | ``original`` | use original DPDK port ID if possible | + +--------------+---------------------------------------+ + | ``id`` | DPDK port ID | + +--------------+---------------------------------------+ + Action: ``METER`` ^^^^^^^^^^^^^^^^^ diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index 64d8dfddb..bfb5ad027 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3212,6 +3212,10 @@ This section lists supported pattern items and their attributes, if any. - ``index {unsigned}``: physical port index. +- ``port_id``: match traffic from/to a given DPDK port ID. + + - ``id {unsigned}``: DPDK port ID. + - ``raw``: match an arbitrary byte string. - ``relative {boolean}``: look for pattern after the previous item. @@ -3428,6 +3432,11 @@ This section lists supported actions and their attributes, if any. - ``original {boolean}``: use original port index if possible. - ``index {unsigned}``: physical port index. +- ``port_id``: direct matching traffic to a given DPDK port ID. + + - ``original {boolean}``: use original DPDK port ID if possible. + - ``id {unsigned}``: DPDK port ID. + Destroying flow rules ~~~~~~~~~~~~~~~~~~~~~ diff --git a/lib/librte_ether/rte_flow.c b/lib/librte_ether/rte_flow.c index e0fd78dd5..3d8116ebd 100644 --- a/lib/librte_ether/rte_flow.c +++ b/lib/librte_ether/rte_flow.c @@ -39,6 +39,7 @@ static const struct rte_flow_desc_data rte_flow_desc_item[] = { MK_FLOW_ITEM(PF, 0), MK_FLOW_ITEM(VF, sizeof(struct rte_flow_item_vf)), MK_FLOW_ITEM(PHY_PORT, sizeof(struct rte_flow_item_phy_port)), + MK_FLOW_ITEM(PORT_ID, sizeof(struct rte_flow_item_port_id)), MK_FLOW_ITEM(RAW, sizeof(struct rte_flow_item_raw)), MK_FLOW_ITEM(ETH, sizeof(struct rte_flow_item_eth)), MK_FLOW_ITEM(VLAN, sizeof(struct rte_flow_item_vlan)), @@ -77,6 +78,7 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = { MK_FLOW_ACTION(PF, 0), MK_FLOW_ACTION(VF, sizeof(struct rte_flow_action_vf)), MK_FLOW_ACTION(PHY_PORT, sizeof(struct rte_flow_action_phy_port)), + MK_FLOW_ACTION(PORT_ID, sizeof(struct rte_flow_action_port_id)), }; static int diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index c3ae0c6a8..29a3b26e3 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -180,6 +180,16 @@ enum rte_flow_item_type { RTE_FLOW_ITEM_TYPE_PHY_PORT, /** + * [META] + * + * Matches traffic originating from (ingress) or going to (egress) a + * given DPDK port ID. + * + * See struct rte_flow_item_port_id. + */ + RTE_FLOW_ITEM_TYPE_PORT_ID, + + /** * Matches a byte string of a given length at a given offset. * * See struct rte_flow_item_raw. @@ -414,6 +424,32 @@ static const struct rte_flow_item_phy_port rte_flow_item_phy_port_mask = { #endif /** + * RTE_FLOW_ITEM_TYPE_PORT_ID + * + * Matches traffic originating from (ingress) or going to (egress) a given + * DPDK port ID. + * + * Normally only supported if the port ID in question is known by the + * underlying PMD and related to the device the flow rule is created + * against. + * + * This must not be confused with @p PHY_PORT which refers to the physical + * port of a device, whereas @p PORT_ID refers to a struct rte_eth_dev + * object on the application side (also known as "port representor" + * depending on the kind of underlying device). + */ +struct rte_flow_item_port_id { + uint32_t id; /**< DPDK port ID. */ +}; + +/** Default mask for RTE_FLOW_ITEM_TYPE_PORT_ID. */ +#ifndef __cplusplus +static const struct rte_flow_item_port_id rte_flow_item_port_id_mask = { + .id = 0xffffffff, +}; +#endif + +/** * RTE_FLOW_ITEM_TYPE_RAW * * Matches a byte string of a given length at a given offset. @@ -997,6 +1033,13 @@ enum rte_flow_action_type { RTE_FLOW_ACTION_TYPE_PHY_PORT, /** + * Directs matching traffic to a given DPDK port ID. + * + * See struct rte_flow_action_port_id. + */ + RTE_FLOW_ACTION_TYPE_PORT_ID, + + /** * Traffic metering and policing (MTR). * * See struct rte_flow_action_meter. @@ -1134,6 +1177,19 @@ struct rte_flow_action_phy_port { }; /** + * RTE_FLOW_ACTION_TYPE_PORT_ID + * + * Directs matching traffic to a given DPDK port ID. + * + * @see RTE_FLOW_ITEM_TYPE_PORT_ID + */ +struct rte_flow_action_port_id { + uint32_t original:1; /**< Use original DPDK port ID if possible. */ + uint32_t reserved:31; /**< Reserved, must be zero. */ + uint32_t id; /**< DPDK port ID. */ +}; + +/** * RTE_FLOW_ACTION_TYPE_METER * * Traffic metering and policing (MTR). -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [dpdk-dev] [PATCH v3 16/16] ethdev: add port ID item and action to flow API 2018-04-10 16:37 ` [dpdk-dev] [PATCH v3 16/16] ethdev: add port ID item and " Adrien Mazarguil @ 2018-04-11 13:02 ` Andrew Rybchenko 0 siblings, 0 replies; 157+ messages in thread From: Andrew Rybchenko @ 2018-04-11 13:02 UTC (permalink / raw) To: Adrien Mazarguil, Thomas Monjalon, Ferruh Yigit, dev Cc: Zhang, Qi Z, Declan Doherty On 04/10/2018 07:37 PM, Adrien Mazarguil wrote: > RTE_FLOW_ACTION_TYPE_PORT_ID brings the ability to inject matching traffic > into a different device, as identified by its DPDK port ID. > > This is normally only supported when the target port ID has some kind of > relationship with the port ID the flow rule is created against, such as > being exposed by a common physical device (e.g. a different port of an > Ethernet switch). > > The converse pattern item, RTE_FLOW_ITEM_TYPE_PORT_ID, makes the resulting > flow rule match traffic whose origin is the specified port ID. Note that > specifying a port ID that differs from the one the flow rule is created > against is normally meaningless (if even accepted), but can make sense if > combined with the transfer attribute. > > These must not be confused with their PHY_PORT counterparts, which refer to > physical ports using device-specific indices, but unlike PORT_ID are not > necessarily tied to DPDK port IDs. > > This breaks ABI compatibility for the following public functions: > > - rte_flow_copy() > - rte_flow_create() > - rte_flow_query() > - rte_flow_validate() > > Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> > Reviewed-by: Qi Zhang <qi.z.zhang@intel.com> > Cc: "Zhang, Qi Z" <qi.z.zhang@intel.com> > Cc: Declan Doherty <declan.doherty@intel.com> > > --- > > This patch provides the same functionality and supersedes Qi Zhang's > "ether: add flow action to redirect packet to a port" [1]. > > The main differences are: > > - Action is named PORT_ID instead of PORT. > - Addition of a PORT_ID pattern item. > - More extensive documentation. > - Testpmd support. > - rte_flow_copy() support. > > [1] http://dpdk.org/ml/archives/dev/2018-April/094648.html > --- > app/test-pmd/cmdline_flow.c | 57 ++++++++++++++++++++++++ > app/test-pmd/config.c | 2 + > doc/guides/prog_guide/rte_flow.rst | 48 ++++++++++++++++++++ > doc/guides/testpmd_app_ug/testpmd_funcs.rst | 9 ++++ > lib/librte_ether/rte_flow.c | 2 + > lib/librte_ether/rte_flow.h | 56 +++++++++++++++++++++++ > 6 files changed, 174 insertions(+) Acked-by: Andrew Rybchenko <arybchenko@solarflare.com> ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v4 00/16] Flow API overhaul for switch offloads 2018-04-10 16:36 ` [dpdk-dev] [PATCH v3 00/16] Flow API overhaul for switch offloads Adrien Mazarguil ` (15 preceding siblings ...) 2018-04-10 16:37 ` [dpdk-dev] [PATCH v3 16/16] ethdev: add port ID item and " Adrien Mazarguil @ 2018-04-16 16:22 ` Adrien Mazarguil 2018-04-16 16:22 ` [dpdk-dev] [PATCH v4 01/16] ethdev: add error types to flow API Adrien Mazarguil ` (16 more replies) 16 siblings, 17 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-16 16:22 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev As summarized in a prior RFC [1], the flow API (rte_flow) was chosen as a means to manage switch offloads supported by many devices (usually going by names such as E-Switch or vSwitch) through user-specified flow rules. Combined with the need to support encap/decap actions, this requires a change in the way flow actions are processed (in order and possibly repeated) which modifies the behavior of some of the existing actions, thus warranting a major ABI breakage. Given this ABI breakage is also required by other work submitted for the current release [2][3], this series addresses various longstanding issues with the flow API and makes minor improvements in preparation for upcoming features. Changes summary: - Additional error types. - Clearer documentation. - Improved C++ compatibility. - Exhaustive RSS action. - Consistent behavior of VLAN pattern item. - New "transfer" attribute bringing consistency to VF/PF pattern items. - Confusing "PORT" pattern item renamed "PHY_PORT", with new action counterpart. - New "PORT_ID" pattern item and action to be used with port representors. This series piggybacks on the major ABI update introduced by a prior commit [4] for DPDK 18.05 and depends on several fixes [5] which must be applied first. [1] "[RFC] Switch device offload with DPDK" http://dpdk.org/ml/archives/dev/2018-March/092513.html [2] commit 676b605182a5 ("doc: announce ethdev API change for RSS configuration") [3] "[PATCH v1 00/21] MLX5 tunnel Rx offloading" http://dpdk.org/ml/archives/dev/2018-March/092264.html [4] commit 653e038efc9b ("ethdev: remove versioning of filter control function") [5] "[PATCH v4 00/11] Bunch of flow API-related fixes" http://dpdk.org/ml/archives/dev/2018-April/096509.html v5 changes: - No change besides new acked-by lines, rebased series to address conflicts. v3 changes: - Rebased series, fixed latest conflicts. - Addressed Andrew's comments, see affected patches for details: - Empty RSS types in flow rule means PMD-specific RSS instead of no RSS. - RSS hash function now explicitly compared against RTE_ETH_HASH_FUNCTION_DEFAULT instead of 0 in all PMDs. - sfc PMD updated to also accept Toeplitz. - Implicit VLAN TPID matching now removed from all PMDs. - Default mask upate for VLAN TCI now split as separate patch #11. - Ingress/egress definition clarified in patch #12. v2 changes: - Squashed "ethdev: update ABI for flow API functions" in subsequent patches. - Emphasized ABI impact in relevant commit logs. - Modified documentation in "ethdev: alter behavior of flow API actions" to describe how terminating flow rules without any action of the fate kind result in undefined behavior instead of dropping traffic. - Fixed other minor documentation formatting issues. - Modified "ethdev: refine TPID handling in flow API" as follows: - Using standard macro definitions for VLAN, QinQ and E-Tag EtherTypes. - Fixed endian conversion in sfc. - Replaced a condition in VLAN pattern item processing with an assertion check for i40e. Adrien Mazarguil (16): ethdev: add error types to flow API ethdev: clarify flow API pattern items and actions doc: remove flow API migration section ethdev: remove DUP action from flow API ethdev: alter behavior of flow API actions ethdev: remove C99 flexible arrays from flow API ethdev: flatten RSS configuration in flow API ethdev: add hash function to RSS flow API action ethdev: add encap level to RSS flow API action ethdev: refine TPID handling in flow API ethdev: limit default VLAN TCI mask in flow API ethdev: add transfer attribute to flow API ethdev: update behavior of VF/PF in flow API ethdev: rename physical port item in flow API ethdev: add physical port action to flow API ethdev: add port ID item and action to flow API app/test-pmd/cmdline_flow.c | 394 +++++++++++---- app/test-pmd/config.c | 78 +-- doc/guides/nics/tap.rst | 2 +- doc/guides/prog_guide/rte_flow.rst | 618 ++++++++--------------- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 60 ++- drivers/net/bnxt/bnxt_filter.c | 49 +- drivers/net/e1000/e1000_ethdev.h | 13 +- drivers/net/e1000/igb_ethdev.c | 4 +- drivers/net/e1000/igb_flow.c | 83 ++- drivers/net/e1000/igb_rxtx.c | 55 +- drivers/net/enic/enic_flow.c | 50 +- drivers/net/i40e/i40e_ethdev.c | 57 ++- drivers/net/i40e/i40e_ethdev.h | 15 +- drivers/net/i40e/i40e_flow.c | 130 +++-- drivers/net/ixgbe/ixgbe_ethdev.c | 7 +- drivers/net/ixgbe/ixgbe_ethdev.h | 13 +- drivers/net/ixgbe/ixgbe_flow.c | 91 +++- drivers/net/ixgbe/ixgbe_rxtx.c | 55 +- drivers/net/mlx4/mlx4.c | 2 +- drivers/net/mlx4/mlx4_flow.c | 117 +++-- drivers/net/mlx4/mlx4_flow.h | 2 +- drivers/net/mlx4/mlx4_rxq.c | 2 +- drivers/net/mlx4/mlx4_rxtx.h | 2 +- drivers/net/mlx5/mlx5_flow.c | 316 ++++++------ drivers/net/mlx5/mlx5_rxq.c | 22 +- drivers/net/mlx5/mlx5_rxtx.h | 26 +- drivers/net/mvpp2/mrvl_flow.c | 32 +- drivers/net/sfc/sfc_flow.c | 78 ++- drivers/net/tap/tap_flow.c | 49 +- examples/ipsec-secgw/ipsec.c | 21 +- lib/librte_ether/rte_ethdev_version.map | 22 +- lib/librte_ether/rte_flow.c | 68 +-- lib/librte_ether/rte_flow.h | 339 ++++++++----- lib/librte_net/rte_ether.h | 1 + 34 files changed, 1750 insertions(+), 1123 deletions(-) -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v4 01/16] ethdev: add error types to flow API 2018-04-16 16:22 ` [dpdk-dev] [PATCH v4 00/16] Flow API overhaul for switch offloads Adrien Mazarguil @ 2018-04-16 16:22 ` Adrien Mazarguil 2018-04-17 19:37 ` Ferruh Yigit 2018-04-16 16:22 ` [dpdk-dev] [PATCH v4 02/16] ethdev: clarify flow API pattern items and actions Adrien Mazarguil ` (15 subsequent siblings) 16 siblings, 1 reply; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-16 16:22 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev These enable more precise reporting of objects responsible for errors. This breaks ABI compatibility for the following public functions: - rte_flow_create() - rte_flow_destroy() - rte_flow_error_set() - rte_flow_flush() - rte_flow_isolate() - rte_flow_query() - rte_flow_validate() Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Acked-by: Andrew Rybchenko <arybchenko@solarflare.com> --- app/test-pmd/config.c | 4 ++++ lib/librte_ether/rte_ethdev_version.map | 20 +++++++++++++------- lib/librte_ether/rte_flow.h | 4 ++++ 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 5daa93bb3..a7645adb8 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -1244,8 +1244,12 @@ port_flow_complain(struct rte_flow_error *error) [RTE_FLOW_ERROR_TYPE_ATTR_EGRESS] = "egress field", [RTE_FLOW_ERROR_TYPE_ATTR] = "attributes structure", [RTE_FLOW_ERROR_TYPE_ITEM_NUM] = "pattern length", + [RTE_FLOW_ERROR_TYPE_ITEM_SPEC] = "item specification", + [RTE_FLOW_ERROR_TYPE_ITEM_LAST] = "item specification range", + [RTE_FLOW_ERROR_TYPE_ITEM_MASK] = "item specification mask", [RTE_FLOW_ERROR_TYPE_ITEM] = "specific pattern item", [RTE_FLOW_ERROR_TYPE_ACTION_NUM] = "number of actions", + [RTE_FLOW_ERROR_TYPE_ACTION_CONF] = "action configuration", [RTE_FLOW_ERROR_TYPE_ACTION] = "specific action", }; const char *errstr; diff --git a/lib/librte_ether/rte_ethdev_version.map b/lib/librte_ether/rte_ethdev_version.map index 34df6c8b5..e915e7929 100644 --- a/lib/librte_ether/rte_ethdev_version.map +++ b/lib/librte_ether/rte_ethdev_version.map @@ -127,11 +127,6 @@ DPDK_17.02 { _rte_eth_dev_reset; rte_eth_dev_fw_version_get; - rte_flow_create; - rte_flow_destroy; - rte_flow_flush; - rte_flow_query; - rte_flow_validate; } DPDK_16.07; @@ -153,7 +148,6 @@ DPDK_17.08 { _rte_eth_dev_callback_process; rte_eth_dev_adjust_nb_rx_tx_desc; rte_flow_copy; - rte_flow_isolate; rte_tm_capabilities_get; rte_tm_hierarchy_commit; rte_tm_level_capabilities_get; @@ -192,7 +186,6 @@ DPDK_17.11 { rte_eth_dev_get_sec_ctx; rte_eth_dev_pool_ops_supported; rte_eth_dev_reset; - rte_flow_error_set; } DPDK_17.08; @@ -203,6 +196,19 @@ DPDK_18.02 { } DPDK_17.11; +DPDK_18.05 { + global: + + rte_flow_create; + rte_flow_destroy; + rte_flow_error_set; + rte_flow_flush; + rte_flow_isolate; + rte_flow_query; + rte_flow_validate; + +} DPDK_18.02; + EXPERIMENTAL { global: diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index 44ae19d3b..26b95c772 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -1186,8 +1186,12 @@ enum rte_flow_error_type { RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, /**< Egress field. */ RTE_FLOW_ERROR_TYPE_ATTR, /**< Attributes structure. */ RTE_FLOW_ERROR_TYPE_ITEM_NUM, /**< Pattern length. */ + RTE_FLOW_ERROR_TYPE_ITEM_SPEC, /**< Item specification. */ + RTE_FLOW_ERROR_TYPE_ITEM_LAST, /**< Item specification range. */ + RTE_FLOW_ERROR_TYPE_ITEM_MASK, /**< Item specification mask. */ RTE_FLOW_ERROR_TYPE_ITEM, /**< Specific pattern item. */ RTE_FLOW_ERROR_TYPE_ACTION_NUM, /**< Number of actions. */ + RTE_FLOW_ERROR_TYPE_ACTION_CONF, /**< Action configuration. */ RTE_FLOW_ERROR_TYPE_ACTION, /**< Specific action. */ }; -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [dpdk-dev] [PATCH v4 01/16] ethdev: add error types to flow API 2018-04-16 16:22 ` [dpdk-dev] [PATCH v4 01/16] ethdev: add error types to flow API Adrien Mazarguil @ 2018-04-17 19:37 ` Ferruh Yigit 2018-04-18 8:41 ` Adrien Mazarguil 0 siblings, 1 reply; 157+ messages in thread From: Ferruh Yigit @ 2018-04-17 19:37 UTC (permalink / raw) To: Adrien Mazarguil, Thomas Monjalon, dev On 4/16/2018 5:22 PM, Adrien Mazarguil wrote: > These enable more precise reporting of objects responsible for errors. > > This breaks ABI compatibility for the following public functions: > > - rte_flow_create() > - rte_flow_destroy() > - rte_flow_error_set() > - rte_flow_flush() > - rte_flow_isolate() > - rte_flow_query() > - rte_flow_validate() Is there a deprecation notice for this API break? > > Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> > Acked-by: Andrew Rybchenko <arybchenko@solarflare.com> <...> ^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [dpdk-dev] [PATCH v4 01/16] ethdev: add error types to flow API 2018-04-17 19:37 ` Ferruh Yigit @ 2018-04-18 8:41 ` Adrien Mazarguil 2018-04-18 9:24 ` Ferruh Yigit 0 siblings, 1 reply; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-18 8:41 UTC (permalink / raw) To: Ferruh Yigit; +Cc: Thomas Monjalon, dev On Tue, Apr 17, 2018 at 08:37:31PM +0100, Ferruh Yigit wrote: > On 4/16/2018 5:22 PM, Adrien Mazarguil wrote: > > These enable more precise reporting of objects responsible for errors. > > > > This breaks ABI compatibility for the following public functions: > > > > - rte_flow_create() > > - rte_flow_destroy() > > - rte_flow_error_set() > > - rte_flow_flush() > > - rte_flow_isolate() > > - rte_flow_query() > > - rte_flow_validate() > > Is there a deprecation notice for this API break? A notice covering the main changes in this series (most patches have an ABI impact) was sent but not included [1]. This particular patch rides on the announced ABI breakage in order to add a relatively minor feature while there. This ABI change was implicitly needed by upcoming work for 18.05 (Xueming's RSS stuff [2][3], Declan's TEP [4], the rest is summarized by a RFC [5]) due to the necessary changes of behavior in flow rules. Note that Xueming's deprecation notice [3] alone would have triggered such an ABI change because struct rte_flow_action_rss wouldn't have been binary compatible if struct rte_eth_rss_conf was updated. This change would have propagated back to rte_flow functions manipulating them. [1] "doc: announce API changes for flow rules" http://dpdk.org/ml/archives/dev/2018-February/090988.html [2] "MLX5 tunnel Rx offloading" http://dpdk.org/ml/archives/dev/2018-February/091461.html [3] "doc: annouce ABI change for RSS configuraiton structure" http://dpdk.org/ml/archives/dev/2018-February/090127.html [4] "tunnel endpoint hw acceleration enablement" http://dpdk.org/ml/archives/dev/2017-December/084676.html [5] "Switch device offload with DPDK" http://dpdk.org/ml/archives/dev/2018-March/092513.html > > Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> > > Acked-by: Andrew Rybchenko <arybchenko@solarflare.com> > > <...> > -- Adrien Mazarguil 6WIND ^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [dpdk-dev] [PATCH v4 01/16] ethdev: add error types to flow API 2018-04-18 8:41 ` Adrien Mazarguil @ 2018-04-18 9:24 ` Ferruh Yigit 2018-04-19 9:48 ` Adrien Mazarguil 0 siblings, 1 reply; 157+ messages in thread From: Ferruh Yigit @ 2018-04-18 9:24 UTC (permalink / raw) To: Adrien Mazarguil; +Cc: Thomas Monjalon, dev On 4/18/2018 9:41 AM, Adrien Mazarguil wrote: > On Tue, Apr 17, 2018 at 08:37:31PM +0100, Ferruh Yigit wrote: >> On 4/16/2018 5:22 PM, Adrien Mazarguil wrote: >>> These enable more precise reporting of objects responsible for errors. >>> >>> This breaks ABI compatibility for the following public functions: >>> >>> - rte_flow_create() >>> - rte_flow_destroy() >>> - rte_flow_error_set() >>> - rte_flow_flush() >>> - rte_flow_isolate() >>> - rte_flow_query() >>> - rte_flow_validate() >> >> Is there a deprecation notice for this API break? > > A notice covering the main changes in this series (most patches have an ABI > impact) was sent but not included [1]. This particular patch rides on the > announced ABI breakage in order to add a relatively minor feature while > there. My take from "announced ABI breakage" is the deprecation notice get three acks and merged into release, so it seems there is no deprecation notice and according process first deprecation notice should go in this release. Hi Thomas, Any comment on issue? > > This ABI change was implicitly needed by upcoming work for 18.05 (Xueming's > RSS stuff [2][3], Declan's TEP [4], the rest is summarized by a RFC [5]) due > to the necessary changes of behavior in flow rules. > > Note that Xueming's deprecation notice [3] alone would have triggered such > an ABI change because struct rte_flow_action_rss wouldn't have been binary > compatible if struct rte_eth_rss_conf was updated. This change would have > propagated back to rte_flow functions manipulating them. To be honest I lost track of Xueming's patches, because of split/merge of patchset, multiple set with multiple versions out. Is it possible to document the dependency graph including your set? > > [1] "doc: announce API changes for flow rules" > http://dpdk.org/ml/archives/dev/2018-February/090988.html > [2] "MLX5 tunnel Rx offloading" > http://dpdk.org/ml/archives/dev/2018-February/091461.html > [3] "doc: annouce ABI change for RSS configuraiton structure" > http://dpdk.org/ml/archives/dev/2018-February/090127.html > [4] "tunnel endpoint hw acceleration enablement" > http://dpdk.org/ml/archives/dev/2017-December/084676.html > [5] "Switch device offload with DPDK" > http://dpdk.org/ml/archives/dev/2018-March/092513.html > >>> Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> >>> Acked-by: Andrew Rybchenko <arybchenko@solarflare.com> >> >> <...> >> > ^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [dpdk-dev] [PATCH v4 01/16] ethdev: add error types to flow API 2018-04-18 9:24 ` Ferruh Yigit @ 2018-04-19 9:48 ` Adrien Mazarguil 0 siblings, 0 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-19 9:48 UTC (permalink / raw) To: Ferruh Yigit; +Cc: Thomas Monjalon, dev On Wed, Apr 18, 2018 at 10:24:10AM +0100, Ferruh Yigit wrote: > On 4/18/2018 9:41 AM, Adrien Mazarguil wrote: > > On Tue, Apr 17, 2018 at 08:37:31PM +0100, Ferruh Yigit wrote: > >> On 4/16/2018 5:22 PM, Adrien Mazarguil wrote: > >>> These enable more precise reporting of objects responsible for errors. > >>> > >>> This breaks ABI compatibility for the following public functions: > >>> > >>> - rte_flow_create() > >>> - rte_flow_destroy() > >>> - rte_flow_error_set() > >>> - rte_flow_flush() > >>> - rte_flow_isolate() > >>> - rte_flow_query() > >>> - rte_flow_validate() > >> > >> Is there a deprecation notice for this API break? > > > > A notice covering the main changes in this series (most patches have an ABI > > impact) was sent but not included [1]. This particular patch rides on the > > announced ABI breakage in order to add a relatively minor feature while > > there. > > My take from "announced ABI breakage" is the deprecation notice get three acks > and merged into release, so it seems there is no deprecation notice and > according process first deprecation notice should go in this release. True, so just describe how ABI impact is no worse than what was announced (and included) [3] and most of them are actually opportune changes to improve consistency and documentation since ABI would be broken for this release regardless. Regarding individual patches: - 01/16 "ethdev: add error types to flow API" => New error types are added in the middle of an existing enum. - 02/16 "ethdev: clarify flow API pattern items and actions" => No impact. - 03/16 "doc: remove flow API migration section" => No impact. - 04/16 "ethdev: remove DUP action from flow API" => An action that no PMD supports is removed from an existing enum. - 05/16 "ethdev: alter behavior of flow API actions" => A documentation change in how actions are processed logically breaks ABI in the case of repeated actions (currently a corner case). Most PMDs do not implement the original behavior correctly anyway (see commit log). - 06/16 "ethdev: remove C99 flexible arrays from flow API" => ABI impact is primarily triggered by the RSS action change (already covered [3]). The RAW pattern item is also modified for consistency. On the API side, except when allocating these structures, there is no difference in usage (i.e. array[index] => pointer[index]). - 07/16 "ethdev: flatten RSS configuration in flow API" => Already covered [3]. - 08/16 "ethdev: add hash function to RSS flow API action" => Already covered [3]. - 09/16 "ethdev: add encap level to RSS flow API action" => Already covered [3]. - 10/16 "ethdev: refine TPID handling in flow API" => No PMD supports the poorly defined TPID matching, applications couldn't possibly rely on it. - 11/16 "ethdev: limit default VLAN TCI mask in flow API" => No ABI breakage, but a different behavior for applications that rely on the default mask. It doesn't look like any PMD supports PCP/DEI matching so again applications could not rely on it (they still can do it by providing a specific mask). - 12/16 "ethdev: add transfer attribute to flow API" => Minor ABI impact (read: logical) due to the addition of a bit in an existing bit-field. No practical impact on applications. - 13/16 "ethdev: update behavior of VF/PF in flow API" => Documentation (API) change. The "transfer" bit must now be set in order to use these actions with PMDs that support them. - 14/16 "ethdev: rename physical port item in flow API" => API change for a pattern item supported by no PMD. - 15/16 "ethdev: add physical port action to flow API" => New action added in the middle of an existing enum. - 16/16 "ethdev: add port ID item and action to flow API" => New item/action added in the middle of existing enums. > Hi Thomas, > > Any comment on issue? > > > > > This ABI change was implicitly needed by upcoming work for 18.05 (Xueming's > > RSS stuff [2][3], Declan's TEP [4], the rest is summarized by a RFC [5]) due > > to the necessary changes of behavior in flow rules. > > > > Note that Xueming's deprecation notice [3] alone would have triggered such > > an ABI change because struct rte_flow_action_rss wouldn't have been binary > > compatible if struct rte_eth_rss_conf was updated. This change would have > > propagated back to rte_flow functions manipulating them. > > To be honest I lost track of Xueming's patches, because of split/merge of > patchset, multiple set with multiple versions out. > > Is it possible to document the dependency graph including your set? I hopefully didn't miss any: Bunch of flow API-related fixes (v5) [6] | `-- Flow API overhaul for switch offloads (v4) [7] | +-- additions to support tunnel encap/decap (v4) [8] | +-- introduce new tunnel types (v5) [9] | | | `-- mlx5 Rx tunnel offloading (v4) [10] | +-- rte_flow extension for vSwitch acceleration (v3.2) [11] | `-- net/sfc: RSS improvements [12] [6] http://dpdk.org/ml/archives/dev/2018-April/097411.html [7] http://dpdk.org/ml/archives/dev/2018-April/097423.html [8] http://dpdk.org/ml/archives/dev/2018-April/097956.html [9] http://dpdk.org/ml/archives/dev/2018-April/097669.html [10] http://dpdk.org/ml/archives/dev/2018-April/097673.html [11] http://dpdk.org/ml/archives/dev/2018-April/097266.html [12] http://dpdk.org/ml/archives/dev/2018-April/095872.html I gave the current version for these series but some of them are still under review and may change. I plan to send updates for [6] and [7] shortly. > > [1] "doc: announce API changes for flow rules" > > http://dpdk.org/ml/archives/dev/2018-February/090988.html > > [2] "MLX5 tunnel Rx offloading" > > http://dpdk.org/ml/archives/dev/2018-February/091461.html > > [3] "doc: annouce ABI change for RSS configuraiton structure" > > http://dpdk.org/ml/archives/dev/2018-February/090127.html > > [4] "tunnel endpoint hw acceleration enablement" > > http://dpdk.org/ml/archives/dev/2017-December/084676.html > > [5] "Switch device offload with DPDK" > > http://dpdk.org/ml/archives/dev/2018-March/092513.html > > > >>> Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> > >>> Acked-by: Andrew Rybchenko <arybchenko@solarflare.com> > >> > >> <...> > >> > > > -- Adrien Mazarguil 6WIND ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v4 02/16] ethdev: clarify flow API pattern items and actions 2018-04-16 16:22 ` [dpdk-dev] [PATCH v4 00/16] Flow API overhaul for switch offloads Adrien Mazarguil 2018-04-16 16:22 ` [dpdk-dev] [PATCH v4 01/16] ethdev: add error types to flow API Adrien Mazarguil @ 2018-04-16 16:22 ` Adrien Mazarguil 2018-04-16 16:22 ` [dpdk-dev] [PATCH v4 03/16] doc: remove flow API migration section Adrien Mazarguil ` (14 subsequent siblings) 16 siblings, 0 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-16 16:22 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev Although pattern items and actions examples end with "and so on", these lists include all existing definitions and as a result are updated almost every time new types are added. This is cumbersome and pointless. This patch also synchronizes Doxygen and external API documentation wording with a slight clarification regarding meta pattern items. No fundamental API change. Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Acked-by: Andrew Rybchenko <arybchenko@solarflare.com> --- doc/guides/prog_guide/rte_flow.rst | 23 +++++++++++------------ lib/librte_ether/rte_flow.h | 23 ++++++++++------------- 2 files changed, 21 insertions(+), 25 deletions(-) diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 961943dda..a11ebd617 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -186,12 +186,13 @@ Pattern item Pattern items fall in two categories: -- Matching protocol headers and packet data (ANY, RAW, ETH, VLAN, IPV4, - IPV6, ICMP, UDP, TCP, SCTP, VXLAN, MPLS, GRE, ESP and so on), usually - associated with a specification structure. +- Matching protocol headers and packet data, usually associated with a + specification structure. These must be stacked in the same order as the + protocol layers to match inside packets, starting from the lowest. -- Matching meta-data or affecting pattern processing (END, VOID, INVERT, PF, - VF, PORT and so on), often without a specification structure. +- Matching meta-data or affecting pattern processing, often without a + specification structure. Since they do not match packet contents, their + position in the list is usually not relevant. Item specification structures are used to match specific values among protocol fields (or item properties). Documentation describes for each item @@ -1001,15 +1002,13 @@ to a flow rule. That list is not ordered. They fall in three categories: -- Terminating actions (such as QUEUE, DROP, RSS, PF, VF) that prevent - processing matched packets by subsequent flow rules, unless overridden - with PASSTHRU. +- Terminating actions that prevent processing matched packets by subsequent + flow rules, unless overridden with PASSTHRU. -- Non-terminating actions (PASSTHRU, DUP) that leave matched packets up for - additional processing by subsequent flow rules. +- Non-terminating actions that leave matched packets up for additional + processing by subsequent flow rules. -- Other non-terminating meta actions that do not affect the fate of packets - (END, VOID, MARK, FLAG, COUNT, SECURITY). +- Other non-terminating meta actions that do not affect the fate of packets. When several actions are combined in a flow rule, they should all have different types (e.g. dropping a packet twice is not possible). diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index 26b95c772..d28a2a473 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -78,15 +78,13 @@ struct rte_flow_attr { * * Pattern items fall in two categories: * - * - Matching protocol headers and packet data (ANY, RAW, ETH, VLAN, IPV4, - * IPV6, ICMP, UDP, TCP, SCTP, VXLAN and so on), usually associated with a + * - Matching protocol headers and packet data, usually associated with a * specification structure. These must be stacked in the same order as the - * protocol layers to match, starting from the lowest. + * protocol layers to match inside packets, starting from the lowest. * - * - Matching meta-data or affecting pattern processing (END, VOID, INVERT, - * PF, VF, PORT and so on), often without a specification structure. Since - * they do not match packet contents, these can be specified anywhere - * within item lists without affecting others. + * - Matching meta-data or affecting pattern processing, often without a + * specification structure. Since they do not match packet contents, their + * position in the list is usually not relevant. * * See the description of individual types for more information. Those * marked with [META] fall into the second category. @@ -865,15 +863,14 @@ struct rte_flow_item { * * They fall in three categories: * - * - Terminating actions (such as QUEUE, DROP, RSS, PF, VF) that prevent - * processing matched packets by subsequent flow rules, unless overridden - * with PASSTHRU. + * - Terminating actions that prevent processing matched packets by + * subsequent flow rules, unless overridden with PASSTHRU. * - * - Non terminating actions (PASSTHRU, DUP) that leave matched packets up - * for additional processing by subsequent flow rules. + * - Non terminating actions that leave matched packets up for additional + * processing by subsequent flow rules. * * - Other non terminating meta actions that do not affect the fate of - * packets (END, VOID, MARK, FLAG, COUNT). + * packets. * * When several actions are combined in a flow rule, they should all have * different types (e.g. dropping a packet twice is not possible). -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v4 03/16] doc: remove flow API migration section 2018-04-16 16:22 ` [dpdk-dev] [PATCH v4 00/16] Flow API overhaul for switch offloads Adrien Mazarguil 2018-04-16 16:22 ` [dpdk-dev] [PATCH v4 01/16] ethdev: add error types to flow API Adrien Mazarguil 2018-04-16 16:22 ` [dpdk-dev] [PATCH v4 02/16] ethdev: clarify flow API pattern items and actions Adrien Mazarguil @ 2018-04-16 16:22 ` Adrien Mazarguil 2018-04-16 16:22 ` [dpdk-dev] [PATCH v4 04/16] ethdev: remove DUP action from flow API Adrien Mazarguil ` (13 subsequent siblings) 16 siblings, 0 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-16 16:22 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev This section has become less relevant since the flow API (rte_flow) is now a mature DPDK API with applications developed directly on top of it instead of an afterthought. This patch removes it for the following reasons: - It has never been updated to track the latest changes in the legacy filter types and never will. - Many provided examples are theoretical and misleading since PMDs do not implement them. Others are obvious. - Upcoming work on the flow API will alter the behavior of several pattern items, actions and in some cases, flow rules, which will in turn cause existing examples to be wrong. Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Acked-by: Andrew Rybchenko <arybchenko@solarflare.com> --- doc/guides/prog_guide/rte_flow.rst | 298 -------------------------------- 1 file changed, 298 deletions(-) diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index a11ebd617..51826d04c 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -55,9 +55,6 @@ encompasses and supersedes (including all functions and filter types) in order to expose a single interface with an unambiguous behavior that is common to all poll-mode drivers (PMDs). -Several methods to migrate existing applications are described in `API -migration`_. - Flow rule --------- @@ -2068,298 +2065,3 @@ Future evolutions - Optional software fallback when PMDs are unable to handle requested flow rules so applications do not have to implement their own. - -API migration -------------- - -Exhaustive list of deprecated filter types (normally prefixed with -*RTE_ETH_FILTER_*) found in ``rte_eth_ctrl.h`` and methods to convert them -to *rte_flow* rules. - -``MACVLAN`` to ``ETH`` → ``VF``, ``PF`` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -*MACVLAN* can be translated to a basic `Item: ETH`_ flow rule with a -terminating `Action: VF`_ or `Action: PF`_. - -.. _table_rte_flow_migration_macvlan: - -.. table:: MACVLAN conversion - - +--------------------------+---------+ - | Pattern | Actions | - +===+=====+==========+=====+=========+ - | 0 | ETH | ``spec`` | any | VF, | - | | +----------+-----+ PF | - | | | ``last`` | N/A | | - | | +----------+-----+ | - | | | ``mask`` | any | | - +---+-----+----------+-----+---------+ - | 1 | END | END | - +---+----------------------+---------+ - -``ETHERTYPE`` to ``ETH`` → ``QUEUE``, ``DROP`` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -*ETHERTYPE* is basically an `Item: ETH`_ flow rule with a terminating -`Action: QUEUE`_ or `Action: DROP`_. - -.. _table_rte_flow_migration_ethertype: - -.. table:: ETHERTYPE conversion - - +--------------------------+---------+ - | Pattern | Actions | - +===+=====+==========+=====+=========+ - | 0 | ETH | ``spec`` | any | QUEUE, | - | | +----------+-----+ DROP | - | | | ``last`` | N/A | | - | | +----------+-----+ | - | | | ``mask`` | any | | - +---+-----+----------+-----+---------+ - | 1 | END | END | - +---+----------------------+---------+ - -``FLEXIBLE`` to ``RAW`` → ``QUEUE`` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -*FLEXIBLE* can be translated to one `Item: RAW`_ pattern with a terminating -`Action: QUEUE`_ and a defined priority level. - -.. _table_rte_flow_migration_flexible: - -.. table:: FLEXIBLE conversion - - +--------------------------+---------+ - | Pattern | Actions | - +===+=====+==========+=====+=========+ - | 0 | RAW | ``spec`` | any | QUEUE | - | | +----------+-----+ | - | | | ``last`` | N/A | | - | | +----------+-----+ | - | | | ``mask`` | any | | - +---+-----+----------+-----+---------+ - | 1 | END | END | - +---+----------------------+---------+ - -``SYN`` to ``TCP`` → ``QUEUE`` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -*SYN* is a `Item: TCP`_ rule with only the ``syn`` bit enabled and masked, -and a terminating `Action: QUEUE`_. - -Priority level can be set to simulate the high priority bit. - -.. _table_rte_flow_migration_syn: - -.. table:: SYN conversion - - +-----------------------------------+---------+ - | Pattern | Actions | - +===+======+==========+=============+=========+ - | 0 | ETH | ``spec`` | unset | QUEUE | - | | +----------+-------------+ | - | | | ``last`` | unset | | - | | +----------+-------------+ | - | | | ``mask`` | unset | | - +---+------+----------+-------------+---------+ - | 1 | IPV4 | ``spec`` | unset | END | - | | +----------+-------------+ | - | | | ``mask`` | unset | | - | | +----------+-------------+ | - | | | ``mask`` | unset | | - +---+------+----------+---------+---+ | - | 2 | TCP | ``spec`` | ``syn`` | 1 | | - | | +----------+---------+---+ | - | | | ``mask`` | ``syn`` | 1 | | - +---+------+----------+---------+---+ | - | 3 | END | | - +---+-------------------------------+---------+ - -``NTUPLE`` to ``IPV4``, ``TCP``, ``UDP`` → ``QUEUE`` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -*NTUPLE* is similar to specifying an empty L2, `Item: IPV4`_ as L3 with -`Item: TCP`_ or `Item: UDP`_ as L4 and a terminating `Action: QUEUE`_. - -A priority level can be specified as well. - -.. _table_rte_flow_migration_ntuple: - -.. table:: NTUPLE conversion - - +-----------------------------+---------+ - | Pattern | Actions | - +===+======+==========+=======+=========+ - | 0 | ETH | ``spec`` | unset | QUEUE | - | | +----------+-------+ | - | | | ``last`` | unset | | - | | +----------+-------+ | - | | | ``mask`` | unset | | - +---+------+----------+-------+---------+ - | 1 | IPV4 | ``spec`` | any | END | - | | +----------+-------+ | - | | | ``last`` | unset | | - | | +----------+-------+ | - | | | ``mask`` | any | | - +---+------+----------+-------+ | - | 2 | TCP, | ``spec`` | any | | - | | UDP +----------+-------+ | - | | | ``last`` | unset | | - | | +----------+-------+ | - | | | ``mask`` | any | | - +---+------+----------+-------+ | - | 3 | END | | - +---+-------------------------+---------+ - -``TUNNEL`` to ``ETH``, ``IPV4``, ``IPV6``, ``VXLAN`` (or other) → ``QUEUE`` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -*TUNNEL* matches common IPv4 and IPv6 L3/L4-based tunnel types. - -In the following table, `Item: ANY`_ is used to cover the optional L4. - -.. _table_rte_flow_migration_tunnel: - -.. table:: TUNNEL conversion - - +-------------------------------------------------------+---------+ - | Pattern | Actions | - +===+==========================+==========+=============+=========+ - | 0 | ETH | ``spec`` | any | QUEUE | - | | +----------+-------------+ | - | | | ``last`` | unset | | - | | +----------+-------------+ | - | | | ``mask`` | any | | - +---+--------------------------+----------+-------------+---------+ - | 1 | IPV4, IPV6 | ``spec`` | any | END | - | | +----------+-------------+ | - | | | ``last`` | unset | | - | | +----------+-------------+ | - | | | ``mask`` | any | | - +---+--------------------------+----------+-------------+ | - | 2 | ANY | ``spec`` | any | | - | | +----------+-------------+ | - | | | ``last`` | unset | | - | | +----------+---------+---+ | - | | | ``mask`` | ``num`` | 0 | | - +---+--------------------------+----------+---------+---+ | - | 3 | VXLAN, GENEVE, TEREDO, | ``spec`` | any | | - | | NVGRE, GRE, ... +----------+-------------+ | - | | | ``last`` | unset | | - | | +----------+-------------+ | - | | | ``mask`` | any | | - +---+--------------------------+----------+-------------+ | - | 4 | END | | - +---+---------------------------------------------------+---------+ - -``FDIR`` to most item types → ``QUEUE``, ``DROP``, ``PASSTHRU`` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -*FDIR* is more complex than any other type, there are several methods to -emulate its functionality. It is summarized for the most part in the table -below. - -A few features are intentionally not supported: - -- The ability to configure the matching input set and masks for the entire - device, PMDs should take care of it automatically according to the - requested flow rules. - - For example if a device supports only one bit-mask per protocol type, - source/address IPv4 bit-masks can be made immutable by the first created - rule. Subsequent IPv4 or TCPv4 rules can only be created if they are - compatible. - - Note that only protocol bit-masks affected by existing flow rules are - immutable, others can be changed later. They become mutable again after - the related flow rules are destroyed. - -- Returning four or eight bytes of matched data when using flex bytes - filtering. Although a specific action could implement it, it conflicts - with the much more useful 32 bits tagging on devices that support it. - -- Side effects on RSS processing of the entire device. Flow rules that - conflict with the current device configuration should not be - allowed. Similarly, device configuration should not be allowed when it - affects existing flow rules. - -- Device modes of operation. "none" is unsupported since filtering cannot be - disabled as long as a flow rule is present. - -- "MAC VLAN" or "tunnel" perfect matching modes should be automatically set - according to the created flow rules. - -- Signature mode of operation is not defined but could be handled through - "FUZZY" item. - -.. _table_rte_flow_migration_fdir: - -.. table:: FDIR conversion - - +----------------------------------------+-----------------------+ - | Pattern | Actions | - +===+===================+==========+=====+=======================+ - | 0 | ETH, RAW | ``spec`` | any | QUEUE, DROP, PASSTHRU | - | | +----------+-----+ | - | | | ``last`` | N/A | | - | | +----------+-----+ | - | | | ``mask`` | any | | - +---+-------------------+----------+-----+-----------------------+ - | 1 | IPV4, IPv6 | ``spec`` | any | MARK | - | | +----------+-----+ | - | | | ``last`` | N/A | | - | | +----------+-----+ | - | | | ``mask`` | any | | - +---+-------------------+----------+-----+-----------------------+ - | 2 | TCP, UDP, SCTP | ``spec`` | any | END | - | | +----------+-----+ | - | | | ``last`` | N/A | | - | | +----------+-----+ | - | | | ``mask`` | any | | - +---+-------------------+----------+-----+ | - | 3 | VF, PF, FUZZY | ``spec`` | any | | - | | (optional) +----------+-----+ | - | | | ``last`` | N/A | | - | | +----------+-----+ | - | | | ``mask`` | any | | - +---+-------------------+----------+-----+ | - | 4 | END | | - +---+------------------------------------+-----------------------+ - -``HASH`` -~~~~~~~~ - -There is no counterpart to this filter type because it translates to a -global device setting instead of a pattern item. Device settings are -automatically set according to the created flow rules. - -``L2_TUNNEL`` to ``VOID`` → ``VXLAN`` (or others) -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -All packets are matched. This type alters incoming packets to encapsulate -them in a chosen tunnel type, optionally redirect them to a VF as well. - -The destination pool for tag based forwarding can be emulated with other -flow rules using `Action: DUP`_. - -.. _table_rte_flow_migration_l2tunnel: - -.. table:: L2_TUNNEL conversion - - +---------------------------+--------------------+ - | Pattern | Actions | - +===+======+==========+=====+====================+ - | 0 | VOID | ``spec`` | N/A | VXLAN, GENEVE, ... | - | | | | | | - | | | | | | - | | +----------+-----+ | - | | | ``last`` | N/A | | - | | +----------+-----+ | - | | | ``mask`` | N/A | | - | | | | | | - +---+------+----------+-----+--------------------+ - | 1 | END | VF (optional) | - +---+ +--------------------+ - | 2 | | END | - +---+-----------------------+--------------------+ -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v4 04/16] ethdev: remove DUP action from flow API 2018-04-16 16:22 ` [dpdk-dev] [PATCH v4 00/16] Flow API overhaul for switch offloads Adrien Mazarguil ` (2 preceding siblings ...) 2018-04-16 16:22 ` [dpdk-dev] [PATCH v4 03/16] doc: remove flow API migration section Adrien Mazarguil @ 2018-04-16 16:22 ` Adrien Mazarguil 2018-04-16 16:22 ` [dpdk-dev] [PATCH v4 05/16] ethdev: alter behavior of flow API actions Adrien Mazarguil ` (12 subsequent siblings) 16 siblings, 0 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-16 16:22 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev Upcoming changes in relation to the handling of actions list will make the DUP action redundant as specifying several QUEUE actions will achieve the same behavior. Besides, no PMD implements this action. By removing an entry from enum rte_flow_action_type, this patch breaks ABI compatibility for the following public functions: - rte_flow_copy() - rte_flow_create() - rte_flow_query() - rte_flow_validate() Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Acked-by: Andrew Rybchenko <arybchenko@solarflare.com> --- app/test-pmd/cmdline_flow.c | 23 ----------------------- app/test-pmd/config.c | 1 - doc/guides/prog_guide/rte_flow.rst | 23 ----------------------- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 8 -------- lib/librte_ether/rte_ethdev_version.map | 2 +- lib/librte_ether/rte_flow.c | 1 - lib/librte_ether/rte_flow.h | 24 ------------------------ 7 files changed, 1 insertion(+), 81 deletions(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index f0b4b7bc4..2ddb08feb 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -164,8 +164,6 @@ enum index { ACTION_QUEUE_INDEX, ACTION_DROP, ACTION_COUNT, - ACTION_DUP, - ACTION_DUP_INDEX, ACTION_RSS, ACTION_RSS_TYPES, ACTION_RSS_TYPE, @@ -625,7 +623,6 @@ static const enum index next_action[] = { ACTION_QUEUE, ACTION_DROP, ACTION_COUNT, - ACTION_DUP, ACTION_RSS, ACTION_PF, ACTION_VF, @@ -645,12 +642,6 @@ static const enum index action_queue[] = { ZERO, }; -static const enum index action_dup[] = { - ACTION_DUP_INDEX, - ACTION_NEXT, - ZERO, -}; - static const enum index action_rss[] = { ACTION_RSS_TYPES, ACTION_RSS_KEY, @@ -1597,20 +1588,6 @@ static const struct token token_list[] = { .next = NEXT(NEXT_ENTRY(ACTION_NEXT)), .call = parse_vc, }, - [ACTION_DUP] = { - .name = "dup", - .help = "duplicate packets to a given queue index", - .priv = PRIV_ACTION(DUP, sizeof(struct rte_flow_action_dup)), - .next = NEXT(action_dup), - .call = parse_vc, - }, - [ACTION_DUP_INDEX] = { - .name = "index", - .help = "queue index to duplicate packets to", - .next = NEXT(action_dup, NEXT_ENTRY(UNSIGNED)), - .args = ARGS(ARGS_ENTRY(struct rte_flow_action_dup, index)), - .call = parse_vc_conf, - }, [ACTION_RSS] = { .name = "rss", .help = "spread packets among several queues", diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index a7645adb8..d0d372797 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -1065,7 +1065,6 @@ static const struct { MK_FLOW_ACTION(QUEUE, sizeof(struct rte_flow_action_queue)), MK_FLOW_ACTION(DROP, 0), MK_FLOW_ACTION(COUNT, 0), - MK_FLOW_ACTION(DUP, sizeof(struct rte_flow_action_dup)), MK_FLOW_ACTION(RSS, sizeof(struct rte_flow_action_rss)), /* +queue[] */ MK_FLOW_ACTION(PF, 0), MK_FLOW_ACTION(VF, sizeof(struct rte_flow_action_vf)), diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 51826d04c..a237e4fd2 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -1299,26 +1299,6 @@ Query structure to retrieve and reset flow rule counters: | ``bytes`` | out | number of bytes through this rule | +---------------+-----+-----------------------------------+ -Action: ``DUP`` -^^^^^^^^^^^^^^^ - -Duplicates packets to a given queue index. - -This is normally combined with QUEUE, however when used alone, it is -actually similar to QUEUE + PASSTHRU. - -- Non-terminating by default. - -.. _table_rte_flow_action_dup: - -.. table:: DUP - - +-----------+------------------------------------+ - | Field | Value | - +===========+====================================+ - | ``index`` | queue index to duplicate packet to | - +-----------+------------------------------------+ - Action: ``RSS`` ^^^^^^^^^^^^^^^ @@ -2010,9 +1990,6 @@ Unsupported actions and tagging (`Action: MARK`_ or `Action: FLAG`_) may be implemented in software as long as the target queue is used by a single rule. -- A rule specifying both `Action: DUP`_ + `Action: QUEUE`_ may be translated - to two hidden rules combining `Action: QUEUE`_ and `Action: PASSTHRU`_. - - When a single target queue is provided, `Action: RSS`_ can also be implemented through `Action: QUEUE`_. diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index cb6f201e1..a015d02a4 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3363,10 +3363,6 @@ actions can sometimes be combined when the end result is unambiguous:: :: - drop / dup index 6 / end # same as above - -:: - queue index 6 / rss queues 6 7 8 / end # queue has no effect :: @@ -3400,10 +3396,6 @@ This section lists supported actions and their attributes, if any. - ``count``: enable counters for this rule. -- ``dup``: duplicate packets to a given queue index. - - - ``index {unsigned}``: queue index to duplicate packets to. - - ``rss``: spread packets among several queues. - ``types [{RSS hash type} [...]] end``: RSS hash types, allowed tokens diff --git a/lib/librte_ether/rte_ethdev_version.map b/lib/librte_ether/rte_ethdev_version.map index e915e7929..8f1ae5ed2 100644 --- a/lib/librte_ether/rte_ethdev_version.map +++ b/lib/librte_ether/rte_ethdev_version.map @@ -147,7 +147,6 @@ DPDK_17.08 { _rte_eth_dev_callback_process; rte_eth_dev_adjust_nb_rx_tx_desc; - rte_flow_copy; rte_tm_capabilities_get; rte_tm_hierarchy_commit; rte_tm_level_capabilities_get; @@ -199,6 +198,7 @@ DPDK_18.02 { DPDK_18.05 { global: + rte_flow_copy; rte_flow_create; rte_flow_destroy; rte_flow_error_set; diff --git a/lib/librte_ether/rte_flow.c b/lib/librte_ether/rte_flow.c index ada280810..80f9cb6cb 100644 --- a/lib/librte_ether/rte_flow.c +++ b/lib/librte_ether/rte_flow.c @@ -73,7 +73,6 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = { MK_FLOW_ACTION(QUEUE, sizeof(struct rte_flow_action_queue)), MK_FLOW_ACTION(DROP, 0), MK_FLOW_ACTION(COUNT, 0), - MK_FLOW_ACTION(DUP, sizeof(struct rte_flow_action_dup)), MK_FLOW_ACTION(RSS, sizeof(struct rte_flow_action_rss)), /* +queue[] */ MK_FLOW_ACTION(PF, 0), MK_FLOW_ACTION(VF, sizeof(struct rte_flow_action_vf)), diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index d28a2a473..6ace24ff4 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -961,16 +961,6 @@ enum rte_flow_action_type { RTE_FLOW_ACTION_TYPE_COUNT, /** - * Duplicates packets to a given queue index. - * - * This is normally combined with QUEUE, however when used alone, it - * is actually similar to QUEUE + PASSTHRU. - * - * See struct rte_flow_action_dup. - */ - RTE_FLOW_ACTION_TYPE_DUP, - - /** * Similar to QUEUE, except RSS is additionally performed on packets * to spread them among several queues according to the provided * parameters. @@ -1052,20 +1042,6 @@ struct rte_flow_query_count { }; /** - * RTE_FLOW_ACTION_TYPE_DUP - * - * Duplicates packets to a given queue index. - * - * This is normally combined with QUEUE, however when used alone, it is - * actually similar to QUEUE + PASSTHRU. - * - * Non-terminating by default. - */ -struct rte_flow_action_dup { - uint16_t index; /**< Queue index to duplicate packets to. */ -}; - -/** * RTE_FLOW_ACTION_TYPE_RSS * * Similar to QUEUE, except RSS is additionally performed on packets to -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v4 05/16] ethdev: alter behavior of flow API actions 2018-04-16 16:22 ` [dpdk-dev] [PATCH v4 00/16] Flow API overhaul for switch offloads Adrien Mazarguil ` (3 preceding siblings ...) 2018-04-16 16:22 ` [dpdk-dev] [PATCH v4 04/16] ethdev: remove DUP action from flow API Adrien Mazarguil @ 2018-04-16 16:22 ` Adrien Mazarguil 2018-04-18 12:26 ` Andrew Rybchenko 2018-04-16 16:22 ` [dpdk-dev] [PATCH v4 06/16] ethdev: remove C99 flexible arrays from flow API Adrien Mazarguil ` (11 subsequent siblings) 16 siblings, 1 reply; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-16 16:22 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev Cc: Ajit Khaparde, Wenzhuo Lu, John Daley, Gaetan Rivet, Beilei Xing, Konstantin Ananyev, Nelio Laranjeiro, Andrew Rybchenko, Pascal Mazon This patch makes the following changes to flow rule actions: - List order now matters, they are redefined as performed first to last instead of "all simultaneously". - Repeated actions are now supported (e.g. specifying QUEUE multiple times now duplicates traffic among them). Previously only the last action of any given kind was taken into account. - No more distinction between terminating/non-terminating/meta actions. Flow rules themselves are now defined as always terminating unless a PASSTHRU action is specified. These changes alter the behavior of flow rules in corner cases in order to prepare the flow API for actions that modify traffic contents or properties (e.g. encapsulation, compression) and for which order matter when combined. Previously one would have to do so through multiple flow rules by combining PASSTRHU with priority levels, however this proved overly complex to implement at the PMD level, hence this simpler approach. This breaks ABI compatibility for the following public functions: - rte_flow_create() - rte_flow_validate() PMDs with rte_flow support are modified accordingly: - bnxt: no change, implementation already forbids multiple actions and does not support PASSTHRU. - e1000: no change, same as bnxt. - enic: modified to forbid redundant actions, no support for default drop. - failsafe: no change needed. - i40e: no change, implementation already forbids multiple actions. - ixgbe: same as i40e. - mlx4: modified to forbid multiple fate-deciding actions and drop when unspecified. - mlx5: same as mlx4, with other redundant actions also forbidden. - sfc: same as mlx4. - tap: implementation already complies with the new behavior except for the default pass-through modified as a default drop. Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Reviewed-by: Andrew Rybchenko <arybchenko@oktetlabs.ru> Cc: Ajit Khaparde <ajit.khaparde@broadcom.com> Cc: Wenzhuo Lu <wenzhuo.lu@intel.com> Cc: John Daley <johndale@cisco.com> Cc: Gaetan Rivet <gaetan.rivet@6wind.com> Cc: Beilei Xing <beilei.xing@intel.com> Cc: Konstantin Ananyev <konstantin.ananyev@intel.com> Cc: Nelio Laranjeiro <nelio.laranjeiro@6wind.com> Cc: Andrew Rybchenko <arybchenko@solarflare.com> Cc: Pascal Mazon <pascal.mazon@6wind.com> --- doc/guides/prog_guide/rte_flow.rst | 67 +++++++++++++------------------- drivers/net/enic/enic_flow.c | 25 ++++++++++++ drivers/net/mlx4/mlx4_flow.c | 21 +++++++--- drivers/net/mlx5/mlx5_flow.c | 69 ++++++++++++++------------------- drivers/net/sfc/sfc_flow.c | 22 +++++++---- drivers/net/tap/tap_flow.c | 11 ++++++ lib/librte_ether/rte_flow.h | 54 +++++++------------------- 7 files changed, 138 insertions(+), 131 deletions(-) diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index a237e4fd2..80360d068 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -995,28 +995,27 @@ Actions Each possible action is represented by a type. Some have associated configuration structures. Several actions combined in a list can be assigned -to a flow rule. That list is not ordered. +to a flow rule and are performed in order. They fall in three categories: -- Terminating actions that prevent processing matched packets by subsequent - flow rules, unless overridden with PASSTHRU. +- Actions that modify the fate of matching traffic, for instance by dropping + or assigning it a specific destination. -- Non-terminating actions that leave matched packets up for additional - processing by subsequent flow rules. +- Actions that modify matching traffic contents or its properties. This + includes adding/removing encapsulation, encryption, compression and marks. -- Other non-terminating meta actions that do not affect the fate of packets. +- Actions related to the flow rule itself, such as updating counters or + making it non-terminating. -When several actions are combined in a flow rule, they should all have -different types (e.g. dropping a packet twice is not possible). +Flow rules being terminating by default, not specifying any action of the +fate kind results in undefined behavior. This applies to both ingress and +egress. -Only the last action of a given type is taken into account. PMDs still -perform error checking on the entire list. +PASSTHRU, when supported, makes a flow rule non-terminating. Like matching patterns, action lists are terminated by END items. -*Note that PASSTHRU is the only action able to override a terminating rule.* - Example of action that redirects packets to queue index 10: .. _table_rte_flow_action_example: @@ -1029,12 +1028,11 @@ Example of action that redirects packets to queue index 10: | ``index`` | 10 | +-----------+-------+ -Action lists examples, their order is not significant, applications must -consider all actions to be performed simultaneously: +Actions are performed in list order: -.. _table_rte_flow_count_and_drop: +.. _table_rte_flow_count_then_drop: -.. table:: Count and drop +.. table:: Count then drop +-------+--------+ | Index | Action | @@ -1050,7 +1048,7 @@ consider all actions to be performed simultaneously: .. _table_rte_flow_mark_count_redirect: -.. table:: Mark, count and redirect +.. table:: Mark, count then redirect +-------+--------+-----------+-------+ | Index | Action | Field | Value | @@ -1080,12 +1078,15 @@ consider all actions to be performed simultaneously: | 2 | END | +-------+----------------------------+ -In the above example, considering both actions are performed simultaneously, -the end result is that only QUEUE has any effect. +In the above example, while DROP and QUEUE must be performed in order, both +have to happen before reaching END. Only QUEUE has a visible effect. + +Note that such a list may be thought as ambiguous and rejected on that +basis. -.. _table_rte_flow_redirect_queue_3: +.. _table_rte_flow_redirect_queue_5_3: -.. table:: Redirect to queue 3 +.. table:: Redirect to queues 5 and 3 +-------+--------+-----------+-------+ | Index | Action | Field | Value | @@ -1099,9 +1100,9 @@ the end result is that only QUEUE has any effect. | 3 | END | +-------+----------------------------+ -As previously described, only the last action of a given type found in the -list is taken into account. The above example also shows that VOID is -ignored. +As previously described, all actions must be taken into account. This +effectively duplicates traffic to both queues. The above example also shows +that VOID is ignored. Action types ~~~~~~~~~~~~ @@ -1151,9 +1152,8 @@ PMDs. Action: ``PASSTHRU`` ^^^^^^^^^^^^^^^^^^^^ -Leaves packets up for additional processing by subsequent flow rules. This -is the default when a rule does not contain a terminating action, but can be -specified to force a rule to become non-terminating. +Leaves traffic up for additional processing by subsequent flow rules; makes +a flow rule non-terminating. - No configurable properties. @@ -1227,8 +1227,6 @@ Action: ``QUEUE`` Assigns packets to a given queue index. -- Terminating by default. - .. _table_rte_flow_action_queue: .. table:: QUEUE @@ -1245,8 +1243,6 @@ Action: ``DROP`` Drop packets. - No configurable properties. -- Terminating by default. -- PASSTHRU overrides this action if both are specified. .. _table_rte_flow_action_drop: @@ -1309,8 +1305,6 @@ Note: RSS hash result is stored in the ``hash.rss`` mbuf field which overlaps ``hash.fdir.lo``. Since `Action: MARK`_ sets the ``hash.fdir.hi`` field only, both can be requested simultaneously. -- Terminating by default. - .. _table_rte_flow_action_rss: .. table:: RSS @@ -1331,7 +1325,6 @@ Action: ``PF`` Redirects packets to the physical function (PF) of the current device. - No configurable properties. -- Terminating by default. .. _table_rte_flow_action_pf: @@ -1353,8 +1346,6 @@ ID instead of the specified one. This parameter may not be available and is not guaranteed to work properly if the VF part is matched by a prior flow rule or if packets are not addressed to a VF in the first place. -- Terminating by default. - .. _table_rte_flow_action_vf: .. table:: VF @@ -1378,8 +1369,6 @@ action parameter. More than one flow can use the same MTR object through the meter action. The MTR object can be further updated or queried using the rte_mtr* API. -- Non-terminating by default. - .. _table_rte_flow_action_meter: .. table:: METER @@ -1415,8 +1404,6 @@ direction. Multiple flows can be configured to use the same security session. -- Non-terminating by default. - .. _table_rte_flow_action_security: .. table:: SECURITY diff --git a/drivers/net/enic/enic_flow.c b/drivers/net/enic/enic_flow.c index b9f36587c..a5c6a1670 100644 --- a/drivers/net/enic/enic_flow.c +++ b/drivers/net/enic/enic_flow.c @@ -3,6 +3,7 @@ */ #include <errno.h> +#include <stdint.h> #include <rte_log.h> #include <rte_ethdev_driver.h> #include <rte_flow_driver.h> @@ -964,6 +965,9 @@ static int enic_copy_action_v1(const struct rte_flow_action actions[], struct filter_action_v2 *enic_action) { + enum { FATE = 1, }; + uint32_t overlap = 0; + FLOW_TRACE(); for (; actions->type != RTE_FLOW_ACTION_TYPE_END; actions++) { @@ -975,6 +979,10 @@ enic_copy_action_v1(const struct rte_flow_action actions[], const struct rte_flow_action_queue *queue = (const struct rte_flow_action_queue *) actions->conf; + + if (overlap & FATE) + return ENOTSUP; + overlap |= FATE; enic_action->rq_idx = enic_rte_rq_idx_to_sop_idx(queue->index); break; @@ -984,6 +992,8 @@ enic_copy_action_v1(const struct rte_flow_action actions[], break; } } + if (!overlap & FATE) + return ENOTSUP; enic_action->type = FILTER_ACTION_RQ_STEERING; return 0; } @@ -1001,6 +1011,9 @@ static int enic_copy_action_v2(const struct rte_flow_action actions[], struct filter_action_v2 *enic_action) { + enum { FATE = 1, MARK = 2, }; + uint32_t overlap = 0; + FLOW_TRACE(); for (; actions->type != RTE_FLOW_ACTION_TYPE_END; actions++) { @@ -1009,6 +1022,10 @@ enic_copy_action_v2(const struct rte_flow_action actions[], const struct rte_flow_action_queue *queue = (const struct rte_flow_action_queue *) actions->conf; + + if (overlap & FATE) + return ENOTSUP; + overlap |= FATE; enic_action->rq_idx = enic_rte_rq_idx_to_sop_idx(queue->index); enic_action->flags |= FILTER_ACTION_RQ_STEERING_FLAG; @@ -1019,6 +1036,9 @@ enic_copy_action_v2(const struct rte_flow_action actions[], (const struct rte_flow_action_mark *) actions->conf; + if (overlap & MARK) + return ENOTSUP; + overlap |= MARK; /* ENIC_MAGIC_FILTER_ID is reserved and is the highest * in the range of allows mark ids. */ @@ -1029,6 +1049,9 @@ enic_copy_action_v2(const struct rte_flow_action actions[], break; } case RTE_FLOW_ACTION_TYPE_FLAG: { + if (overlap & MARK) + return ENOTSUP; + overlap |= MARK; enic_action->filter_id = ENIC_MAGIC_FILTER_ID; enic_action->flags |= FILTER_ACTION_FILTER_ID_FLAG; break; @@ -1044,6 +1067,8 @@ enic_copy_action_v2(const struct rte_flow_action actions[], break; } } + if (!overlap & FATE) + return ENOTSUP; enic_action->type = FILTER_ACTION_V2; return 0; } diff --git a/drivers/net/mlx4/mlx4_flow.c b/drivers/net/mlx4/mlx4_flow.c index 67fd568bc..15cdf07b7 100644 --- a/drivers/net/mlx4/mlx4_flow.c +++ b/drivers/net/mlx4/mlx4_flow.c @@ -637,6 +637,7 @@ mlx4_flow_prepare(struct priv *priv, struct rte_flow temp = { .ibv_attr_size = sizeof(*temp.ibv_attr) }; struct rte_flow *flow = &temp; const char *msg = NULL; + int overlap; if (attr->group) return rte_flow_error_set @@ -656,6 +657,7 @@ mlx4_flow_prepare(struct priv *priv, (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, NULL, "only ingress is supported"); fill: + overlap = 0; proc = mlx4_flow_proc_item_list; /* Go over pattern. */ for (item = pattern; item->type; ++item) { @@ -702,6 +704,16 @@ mlx4_flow_prepare(struct priv *priv, } /* Go over actions list. */ for (action = actions; action->type; ++action) { + /* This one may appear anywhere multiple times. */ + if (action->type == RTE_FLOW_ACTION_TYPE_VOID) + continue; + /* Fate-deciding actions may appear exactly once. */ + if (overlap) { + msg = "cannot combine several fate-deciding actions," + " choose between DROP, QUEUE or RSS"; + goto exit_action_not_supported; + } + overlap = 1; switch (action->type) { const struct rte_flow_action_queue *queue; const struct rte_flow_action_rss *rss; @@ -709,8 +721,6 @@ mlx4_flow_prepare(struct priv *priv, uint64_t fields; unsigned int i; - case RTE_FLOW_ACTION_TYPE_VOID: - continue; case RTE_FLOW_ACTION_TYPE_DROP: flow->drop = 1; break; @@ -801,10 +811,9 @@ mlx4_flow_prepare(struct priv *priv, goto exit_action_not_supported; } } - if (!flow->rss && !flow->drop) - return rte_flow_error_set - (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, - NULL, "no valid action"); + /* When fate is unknown, drop traffic. */ + if (!overlap) + flow->drop = 1; /* Validation ends here. */ if (!addr) { if (flow->rss) diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 1ca413e32..9923bfa59 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -4,6 +4,7 @@ */ #include <sys/queue.h> +#include <stdint.h> #include <string.h> /* Verbs header. */ @@ -638,6 +639,8 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, struct rte_flow_error *error, struct mlx5_flow_parse *parser) { + enum { FATE = 1, MARK = 2, COUNT = 4, }; + uint32_t overlap = 0; struct priv *priv = dev->data->dev_private; int ret; @@ -654,39 +657,31 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, if (actions->type == RTE_FLOW_ACTION_TYPE_VOID) { continue; } else if (actions->type == RTE_FLOW_ACTION_TYPE_DROP) { + if (overlap & FATE) + goto exit_action_overlap; + overlap |= FATE; parser->drop = 1; } else if (actions->type == RTE_FLOW_ACTION_TYPE_QUEUE) { const struct rte_flow_action_queue *queue = (const struct rte_flow_action_queue *) actions->conf; - uint16_t n; - uint16_t found = 0; + if (overlap & FATE) + goto exit_action_overlap; + overlap |= FATE; if (!queue || (queue->index > (priv->rxqs_n - 1))) goto exit_action_not_supported; - for (n = 0; n < parser->queues_n; ++n) { - if (parser->queues[n] == queue->index) { - found = 1; - break; - } - } - if (parser->queues_n > 1 && !found) { - rte_flow_error_set(error, ENOTSUP, - RTE_FLOW_ERROR_TYPE_ACTION, - actions, - "queue action not in RSS queues"); - return -rte_errno; - } - if (!found) { - parser->queues_n = 1; - parser->queues[0] = queue->index; - } + parser->queues_n = 1; + parser->queues[0] = queue->index; } else if (actions->type == RTE_FLOW_ACTION_TYPE_RSS) { const struct rte_flow_action_rss *rss = (const struct rte_flow_action_rss *) actions->conf; uint16_t n; + if (overlap & FATE) + goto exit_action_overlap; + overlap |= FATE; if (!rss || !rss->num) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, @@ -694,26 +689,6 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, "no valid queues"); return -rte_errno; } - if (parser->queues_n == 1) { - uint16_t found = 0; - - assert(parser->queues_n); - for (n = 0; n < rss->num; ++n) { - if (parser->queues[0] == - rss->queue[n]) { - found = 1; - break; - } - } - if (!found) { - rte_flow_error_set(error, ENOTSUP, - RTE_FLOW_ERROR_TYPE_ACTION, - actions, - "queue action not in RSS" - " queues"); - return -rte_errno; - } - } if (rss->num > RTE_DIM(parser->queues)) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, @@ -747,6 +722,9 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, (const struct rte_flow_action_mark *) actions->conf; + if (overlap & MARK) + goto exit_action_overlap; + overlap |= MARK; if (!mark) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, @@ -764,14 +742,23 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, parser->mark = 1; parser->mark_id = mark->id; } else if (actions->type == RTE_FLOW_ACTION_TYPE_FLAG) { + if (overlap & MARK) + goto exit_action_overlap; + overlap |= MARK; parser->mark = 1; } else if (actions->type == RTE_FLOW_ACTION_TYPE_COUNT && priv->config.flow_counter_en) { + if (overlap & COUNT) + goto exit_action_overlap; + overlap |= COUNT; parser->count = 1; } else { goto exit_action_not_supported; } } + /* When fate is unknown, drop traffic. */ + if (!overlap & FATE) + parser->drop = 1; if (parser->drop && parser->mark) parser->mark = 0; if (!parser->queues_n && !parser->drop) { @@ -784,6 +771,10 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, actions, "action not supported"); return -rte_errno; +exit_action_overlap: + rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, + actions, "overlapping actions are not supported"); + return -rte_errno; } /** diff --git a/drivers/net/sfc/sfc_flow.c b/drivers/net/sfc/sfc_flow.c index fe4c0b0c5..056405515 100644 --- a/drivers/net/sfc/sfc_flow.c +++ b/drivers/net/sfc/sfc_flow.c @@ -1467,10 +1467,19 @@ sfc_flow_parse_actions(struct sfc_adapter *sa, } for (; actions->type != RTE_FLOW_ACTION_TYPE_END; actions++) { + /* This one may appear anywhere multiple times. */ + if (actions->type == RTE_FLOW_ACTION_TYPE_VOID) + continue; + /* Fate-deciding actions may appear exactly once. */ + if (is_specified) { + rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, + actions, + "Cannot combine several fate-deciding actions," + "choose between QUEUE, RSS or DROP"); + return -rte_errno; + } switch (actions->type) { - case RTE_FLOW_ACTION_TYPE_VOID: - break; - case RTE_FLOW_ACTION_TYPE_QUEUE: rc = sfc_flow_parse_queue(sa, actions->conf, flow); if (rc != 0) { @@ -1512,11 +1521,10 @@ sfc_flow_parse_actions(struct sfc_adapter *sa, } } + /* When fate is unknown, drop traffic. */ if (!is_specified) { - rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ACTION_NUM, actions, - "Action is unspecified"); - return -rte_errno; + flow->spec.template.efs_dmaq_id = + EFX_FILTER_SPEC_RX_DMAQ_ID_DROP; } return 0; diff --git a/drivers/net/tap/tap_flow.c b/drivers/net/tap/tap_flow.c index 3b7a960b0..fe2f94010 100644 --- a/drivers/net/tap/tap_flow.c +++ b/drivers/net/tap/tap_flow.c @@ -1140,6 +1140,7 @@ priv_flow_process(struct pmd_internals *pmd, else goto end; } +actions: for (; actions->type != RTE_FLOW_ACTION_TYPE_END; ++actions) { int err = 0; @@ -1222,6 +1223,16 @@ priv_flow_process(struct pmd_internals *pmd, if (err) goto exit_action_not_supported; } + /* When fate is unknown, drop traffic. */ + if (!action) { + static const struct rte_flow_action drop[] = { + { .type = RTE_FLOW_ACTION_TYPE_DROP, }, + { .type = RTE_FLOW_ACTION_TYPE_END, }, + }; + + actions = drop; + goto actions; + } end: if (flow) tap_nlattr_nested_finish(&flow->msg); /* nested TCA_OPTIONS */ diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index 6ace24ff4..96184f030 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -859,32 +859,28 @@ struct rte_flow_item { * * Each possible action is represented by a type. Some have associated * configuration structures. Several actions combined in a list can be - * affected to a flow rule. That list is not ordered. + * assigned to a flow rule and are performed in order. * * They fall in three categories: * - * - Terminating actions that prevent processing matched packets by - * subsequent flow rules, unless overridden with PASSTHRU. + * - Actions that modify the fate of matching traffic, for instance by + * dropping or assigning it a specific destination. * - * - Non terminating actions that leave matched packets up for additional - * processing by subsequent flow rules. + * - Actions that modify matching traffic contents or its properties. This + * includes adding/removing encapsulation, encryption, compression and + * marks. * - * - Other non terminating meta actions that do not affect the fate of - * packets. + * - Actions related to the flow rule itself, such as updating counters or + * making it non-terminating. * - * When several actions are combined in a flow rule, they should all have - * different types (e.g. dropping a packet twice is not possible). + * Flow rules being terminating by default, not specifying any action of the + * fate kind results in undefined behavior. This applies to both ingress and + * egress. * - * Only the last action of a given type is taken into account. PMDs still - * perform error checking on the entire list. - * - * Note that PASSTHRU is the only action able to override a terminating - * rule. + * PASSTHRU, when supported, makes a flow rule non-terminating. */ enum rte_flow_action_type { /** - * [META] - * * End marker for action lists. Prevents further processing of * actions, thereby ending the list. * @@ -893,8 +889,6 @@ enum rte_flow_action_type { RTE_FLOW_ACTION_TYPE_END, /** - * [META] - * * Used as a placeholder for convenience. It is ignored and simply * discarded by PMDs. * @@ -903,18 +897,14 @@ enum rte_flow_action_type { RTE_FLOW_ACTION_TYPE_VOID, /** - * Leaves packets up for additional processing by subsequent flow - * rules. This is the default when a rule does not contain a - * terminating action, but can be specified to force a rule to - * become non-terminating. + * Leaves traffic up for additional processing by subsequent flow + * rules; makes a flow rule non-terminating. * * No associated configuration structure. */ RTE_FLOW_ACTION_TYPE_PASSTHRU, /** - * [META] - * * Attaches an integer value to packets and sets PKT_RX_FDIR and * PKT_RX_FDIR_ID mbuf flags. * @@ -923,8 +913,6 @@ enum rte_flow_action_type { RTE_FLOW_ACTION_TYPE_MARK, /** - * [META] - * * Flags packets. Similar to MARK without a specific value; only * sets the PKT_RX_FDIR mbuf flag. * @@ -949,9 +937,7 @@ enum rte_flow_action_type { RTE_FLOW_ACTION_TYPE_DROP, /** - * [META] - * - * Enables counters for this rule. + * Enables counters for this flow rule. * * These counters can be retrieved and reset through rte_flow_query(), * see struct rte_flow_query_count. @@ -1020,8 +1006,6 @@ struct rte_flow_action_mark { * RTE_FLOW_ACTION_TYPE_QUEUE * * Assign packets to a given queue index. - * - * Terminating by default. */ struct rte_flow_action_queue { uint16_t index; /**< Queue index to use. */ @@ -1050,8 +1034,6 @@ struct rte_flow_query_count { * Note: RSS hash result is stored in the hash.rss mbuf field which overlaps * hash.fdir.lo. Since the MARK action sets the hash.fdir.hi field only, * both can be requested simultaneously. - * - * Terminating by default. */ struct rte_flow_action_rss { const struct rte_eth_rss_conf *rss_conf; /**< RSS parameters. */ @@ -1069,8 +1051,6 @@ struct rte_flow_action_rss { * and is not guaranteed to work properly if the VF part is matched by a * prior flow rule or if packets are not addressed to a VF in the first * place. - * - * Terminating by default. */ struct rte_flow_action_vf { uint32_t original:1; /**< Use original VF ID if possible. */ @@ -1085,8 +1065,6 @@ struct rte_flow_action_vf { * * Packets matched by items of this type can be either dropped or passed to the * next item with their color set by the MTR object. - * - * Non-terminating by default. */ struct rte_flow_action_meter { uint32_t mtr_id; /**< MTR object ID created with rte_mtr_create(). */ @@ -1116,8 +1094,6 @@ struct rte_flow_action_meter { * direction. * * Multiple flows can be configured to use the same security session. - * - * Non-terminating by default. */ struct rte_flow_action_security { void *security_session; /**< Pointer to security session structure. */ -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [dpdk-dev] [PATCH v4 05/16] ethdev: alter behavior of flow API actions 2018-04-16 16:22 ` [dpdk-dev] [PATCH v4 05/16] ethdev: alter behavior of flow API actions Adrien Mazarguil @ 2018-04-18 12:26 ` Andrew Rybchenko 2018-04-18 14:58 ` Adrien Mazarguil 0 siblings, 1 reply; 157+ messages in thread From: Andrew Rybchenko @ 2018-04-18 12:26 UTC (permalink / raw) To: Adrien Mazarguil, Thomas Monjalon, Ferruh Yigit, dev Cc: Ajit Khaparde, Wenzhuo Lu, John Daley, Gaetan Rivet, Beilei Xing, Konstantin Ananyev, Nelio Laranjeiro, Andrew Rybchenko, Pascal Mazon On 04/16/2018 07:22 PM, Adrien Mazarguil wrote: > This patch makes the following changes to flow rule actions: > > - List order now matters, they are redefined as performed first to last > instead of "all simultaneously". > > - Repeated actions are now supported (e.g. specifying QUEUE multiple times > now duplicates traffic among them). Previously only the last action of > any given kind was taken into account. > > - No more distinction between terminating/non-terminating/meta actions. > Flow rules themselves are now defined as always terminating unless a > PASSTHRU action is specified. > > These changes alter the behavior of flow rules in corner cases in order to > prepare the flow API for actions that modify traffic contents or properties > (e.g. encapsulation, compression) and for which order matter when combined. > > Previously one would have to do so through multiple flow rules by combining > PASSTRHU with priority levels, however this proved overly complex to > implement at the PMD level, hence this simpler approach. > > This breaks ABI compatibility for the following public functions: > > - rte_flow_create() > - rte_flow_validate() > > PMDs with rte_flow support are modified accordingly: > > - bnxt: no change, implementation already forbids multiple actions and does > not support PASSTHRU. > > - e1000: no change, same as bnxt. > > - enic: modified to forbid redundant actions, no support for default drop. > > - failsafe: no change needed. > > - i40e: no change, implementation already forbids multiple actions. > > - ixgbe: same as i40e. > > - mlx4: modified to forbid multiple fate-deciding actions and drop when > unspecified. > > - mlx5: same as mlx4, with other redundant actions also forbidden. > > - sfc: same as mlx4. > > - tap: implementation already complies with the new behavior except for > the default pass-through modified as a default drop. > > Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> > Reviewed-by: Andrew Rybchenko <arybchenko@oktetlabs.ru> > Cc: Ajit Khaparde <ajit.khaparde@broadcom.com> > Cc: Wenzhuo Lu <wenzhuo.lu@intel.com> > Cc: John Daley <johndale@cisco.com> > Cc: Gaetan Rivet <gaetan.rivet@6wind.com> > Cc: Beilei Xing <beilei.xing@intel.com> > Cc: Konstantin Ananyev <konstantin.ananyev@intel.com> > Cc: Nelio Laranjeiro <nelio.laranjeiro@6wind.com> > Cc: Andrew Rybchenko <arybchenko@solarflare.com> > Cc: Pascal Mazon <pascal.mazon@6wind.com> > --- > doc/guides/prog_guide/rte_flow.rst | 67 +++++++++++++------------------- > drivers/net/enic/enic_flow.c | 25 ++++++++++++ > drivers/net/mlx4/mlx4_flow.c | 21 +++++++--- > drivers/net/mlx5/mlx5_flow.c | 69 ++++++++++++++------------------- > drivers/net/sfc/sfc_flow.c | 22 +++++++---- > drivers/net/tap/tap_flow.c | 11 ++++++ > lib/librte_ether/rte_flow.h | 54 +++++++------------------- > 7 files changed, 138 insertions(+), 131 deletions(-) [...] > diff --git a/drivers/net/enic/enic_flow.c b/drivers/net/enic/enic_flow.c > index b9f36587c..a5c6a1670 100644 > --- a/drivers/net/enic/enic_flow.c > +++ b/drivers/net/enic/enic_flow.c > @@ -975,6 +979,10 @@ enic_copy_action_v1(const struct rte_flow_action actions[], > const struct rte_flow_action_queue *queue = > (const struct rte_flow_action_queue *) > actions->conf; > + > + if (overlap & FATE) > + return ENOTSUP; > + overlap |= FATE; > enic_action->rq_idx = > enic_rte_rq_idx_to_sop_idx(queue->index); > break; > @@ -984,6 +992,8 @@ enic_copy_action_v1(const struct rte_flow_action actions[], > break; > } > } > + if (!overlap & FATE) Build using clang on Ubuntu 17.10 fails: /var/tmp/dpdk-next-net/drivers/net/enic/enic_flow.c:1000:6: fatal error: logical not is only applied to the left hand side of this bitwise operator [-Wlogical-not-parentheses] if (!overlap & FATE) ^ ~ /var/tmp/dpdk-next-net/drivers/net/enic/enic_flow.c:1000:6: note: add parentheses after the '!' to evaluate the bitwise operator first if (!overlap & FATE) ^ ( ) /var/tmp/dpdk-next-net/drivers/net/enic/enic_flow.c:1000:6: note: add parentheses around left hand side expression to silence this warning if (!overlap & FATE) ^ ( ) 1 error generated. /var/tmp/dpdk-next-net/mk/internal/rte.compile-pre.mk:114: recipe for target 'enic_flow.o' failed make[4]: *** [enic_flow.o] Error 1 /var/tmp/dpdk-next-net/mk/rte.subdir.mk:35: recipe for target 'enic' failed make[3]: *** [enic] Error 2 CC nfp_cpp_pcie_ops.o make[3]: *** Waiting for unfinished jobs.... $ clang --version clang version 4.0.1-6 (tags/RELEASE_401/final) Target: x86_64-pc-linux-gnu Thread model: posix InstalledDir: /usr/bin > + return ENOTSUP; > enic_action->type = FILTER_ACTION_RQ_STEERING; > return 0; > } > @@ -1001,6 +1011,9 @@ static int > enic_copy_action_v2(const struct rte_flow_action actions[], > struct filter_action_v2 *enic_action) > { > + enum { FATE = 1, MARK = 2, }; > + uint32_t overlap = 0; > + > FLOW_TRACE(); > > for (; actions->type != RTE_FLOW_ACTION_TYPE_END; actions++) { > @@ -1009,6 +1022,10 @@ enic_copy_action_v2(const struct rte_flow_action actions[], > const struct rte_flow_action_queue *queue = > (const struct rte_flow_action_queue *) > actions->conf; > + > + if (overlap & FATE) > + return ENOTSUP; > + overlap |= FATE; > enic_action->rq_idx = > enic_rte_rq_idx_to_sop_idx(queue->index); > enic_action->flags |= FILTER_ACTION_RQ_STEERING_FLAG; > @@ -1019,6 +1036,9 @@ enic_copy_action_v2(const struct rte_flow_action actions[], > (const struct rte_flow_action_mark *) > actions->conf; > > + if (overlap & MARK) Same > + return ENOTSUP; > + overlap |= MARK; > /* ENIC_MAGIC_FILTER_ID is reserved and is the highest > * in the range of allows mark ids. > */ > @@ -1029,6 +1049,9 @@ enic_copy_action_v2(const struct rte_flow_action actions[], > break; > } > case RTE_FLOW_ACTION_TYPE_FLAG: { > + if (overlap & MARK) > + return ENOTSUP; > + overlap |= MARK; > enic_action->filter_id = ENIC_MAGIC_FILTER_ID; > enic_action->flags |= FILTER_ACTION_FILTER_ID_FLAG; > break; > @@ -1044,6 +1067,8 @@ enic_copy_action_v2(const struct rte_flow_action actions[], > break; > } > } > + if (!overlap & FATE) Same > + return ENOTSUP; > enic_action->type = FILTER_ACTION_V2; > return 0; > } [...] ^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [dpdk-dev] [PATCH v4 05/16] ethdev: alter behavior of flow API actions 2018-04-18 12:26 ` Andrew Rybchenko @ 2018-04-18 14:58 ` Adrien Mazarguil 0 siblings, 0 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-18 14:58 UTC (permalink / raw) To: Andrew Rybchenko Cc: Thomas Monjalon, Ferruh Yigit, dev, Ajit Khaparde, Wenzhuo Lu, John Daley, Gaetan Rivet, Beilei Xing, Konstantin Ananyev, Nelio Laranjeiro, Pascal Mazon On Wed, Apr 18, 2018 at 03:26:00PM +0300, Andrew Rybchenko wrote: > On 04/16/2018 07:22 PM, Adrien Mazarguil wrote: > > This patch makes the following changes to flow rule actions: > > > > - List order now matters, they are redefined as performed first to last > > instead of "all simultaneously". > > > > - Repeated actions are now supported (e.g. specifying QUEUE multiple times > > now duplicates traffic among them). Previously only the last action of > > any given kind was taken into account. > > > > - No more distinction between terminating/non-terminating/meta actions. > > Flow rules themselves are now defined as always terminating unless a > > PASSTHRU action is specified. > > > > These changes alter the behavior of flow rules in corner cases in order to > > prepare the flow API for actions that modify traffic contents or properties > > (e.g. encapsulation, compression) and for which order matter when combined. > > > > Previously one would have to do so through multiple flow rules by combining > > PASSTRHU with priority levels, however this proved overly complex to > > implement at the PMD level, hence this simpler approach. > > > > This breaks ABI compatibility for the following public functions: > > > > - rte_flow_create() > > - rte_flow_validate() > > > > PMDs with rte_flow support are modified accordingly: > > > > - bnxt: no change, implementation already forbids multiple actions and does > > not support PASSTHRU. > > > > - e1000: no change, same as bnxt. > > > > - enic: modified to forbid redundant actions, no support for default drop. > > > > - failsafe: no change needed. > > > > - i40e: no change, implementation already forbids multiple actions. > > > > - ixgbe: same as i40e. > > > > - mlx4: modified to forbid multiple fate-deciding actions and drop when > > unspecified. > > > > - mlx5: same as mlx4, with other redundant actions also forbidden. > > > > - sfc: same as mlx4. > > > > - tap: implementation already complies with the new behavior except for > > the default pass-through modified as a default drop. > > > > Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> > > Reviewed-by: Andrew Rybchenko <arybchenko@oktetlabs.ru> > > Cc: Ajit Khaparde <ajit.khaparde@broadcom.com> > > Cc: Wenzhuo Lu <wenzhuo.lu@intel.com> > > Cc: John Daley <johndale@cisco.com> > > Cc: Gaetan Rivet <gaetan.rivet@6wind.com> > > Cc: Beilei Xing <beilei.xing@intel.com> > > Cc: Konstantin Ananyev <konstantin.ananyev@intel.com> > > Cc: Nelio Laranjeiro <nelio.laranjeiro@6wind.com> > > Cc: Andrew Rybchenko <arybchenko@solarflare.com> > > Cc: Pascal Mazon <pascal.mazon@6wind.com> > > --- > > doc/guides/prog_guide/rte_flow.rst | 67 +++++++++++++------------------- > > drivers/net/enic/enic_flow.c | 25 ++++++++++++ > > drivers/net/mlx4/mlx4_flow.c | 21 +++++++--- > > drivers/net/mlx5/mlx5_flow.c | 69 ++++++++++++++------------------- > > drivers/net/sfc/sfc_flow.c | 22 +++++++---- > > drivers/net/tap/tap_flow.c | 11 ++++++ > > lib/librte_ether/rte_flow.h | 54 +++++++------------------- > > 7 files changed, 138 insertions(+), 131 deletions(-) > > [...] > > > diff --git a/drivers/net/enic/enic_flow.c b/drivers/net/enic/enic_flow.c > > index b9f36587c..a5c6a1670 100644 > > --- a/drivers/net/enic/enic_flow.c > > +++ b/drivers/net/enic/enic_flow.c > > @@ -975,6 +979,10 @@ enic_copy_action_v1(const struct rte_flow_action actions[], > > const struct rte_flow_action_queue *queue = > > (const struct rte_flow_action_queue *) > > actions->conf; > > + > > + if (overlap & FATE) > > + return ENOTSUP; > > + overlap |= FATE; > > enic_action->rq_idx = > > enic_rte_rq_idx_to_sop_idx(queue->index); > > break; > > @@ -984,6 +992,8 @@ enic_copy_action_v1(const struct rte_flow_action actions[], > > break; > > } > > } > > + if (!overlap & FATE) > > Build using clang on Ubuntu 17.10 fails: > > /var/tmp/dpdk-next-net/drivers/net/enic/enic_flow.c:1000:6: fatal error: > logical not is only applied to > the left hand side of this bitwise operator > [-Wlogical-not-parentheses] > if (!overlap & FATE) > ^ ~ > /var/tmp/dpdk-next-net/drivers/net/enic/enic_flow.c:1000:6: note: add > parentheses after the '!' to > evaluate the bitwise operator first > if (!overlap & FATE) > ^ > ( ) > /var/tmp/dpdk-next-net/drivers/net/enic/enic_flow.c:1000:6: note: add > parentheses around left hand side > expression to silence this warning > if (!overlap & FATE) > ^ > ( ) > 1 error generated. > /var/tmp/dpdk-next-net/mk/internal/rte.compile-pre.mk:114: recipe for target > 'enic_flow.o' failed > make[4]: *** [enic_flow.o] Error 1 > /var/tmp/dpdk-next-net/mk/rte.subdir.mk:35: recipe for target 'enic' failed > make[3]: *** [enic] Error 2 > CC nfp_cpp_pcie_ops.o > make[3]: *** Waiting for unfinished jobs.... > > $ clang --version > clang version 4.0.1-6 (tags/RELEASE_401/final) > Target: x86_64-pc-linux-gnu > Thread model: posix > InstalledDir: /usr/bin > > > > + return ENOTSUP; > > enic_action->type = FILTER_ACTION_RQ_STEERING; > > return 0; > > } > > @@ -1001,6 +1011,9 @@ static int > > enic_copy_action_v2(const struct rte_flow_action actions[], > > struct filter_action_v2 *enic_action) > > { > > + enum { FATE = 1, MARK = 2, }; > > + uint32_t overlap = 0; > > + > > FLOW_TRACE(); > > for (; actions->type != RTE_FLOW_ACTION_TYPE_END; actions++) { > > @@ -1009,6 +1022,10 @@ enic_copy_action_v2(const struct rte_flow_action actions[], > > const struct rte_flow_action_queue *queue = > > (const struct rte_flow_action_queue *) > > actions->conf; > > + > > + if (overlap & FATE) > > + return ENOTSUP; > > + overlap |= FATE; > > enic_action->rq_idx = > > enic_rte_rq_idx_to_sop_idx(queue->index); > > enic_action->flags |= FILTER_ACTION_RQ_STEERING_FLAG; > > @@ -1019,6 +1036,9 @@ enic_copy_action_v2(const struct rte_flow_action actions[], > > (const struct rte_flow_action_mark *) > > actions->conf; > > + if (overlap & MARK) > > Same > > > + return ENOTSUP; > > + overlap |= MARK; > > /* ENIC_MAGIC_FILTER_ID is reserved and is the highest > > * in the range of allows mark ids. > > */ > > @@ -1029,6 +1049,9 @@ enic_copy_action_v2(const struct rte_flow_action actions[], > > break; > > } > > case RTE_FLOW_ACTION_TYPE_FLAG: { > > + if (overlap & MARK) > > + return ENOTSUP; > > + overlap |= MARK; > > enic_action->filter_id = ENIC_MAGIC_FILTER_ID; > > enic_action->flags |= FILTER_ACTION_FILTER_ID_FLAG; > > break; > > @@ -1044,6 +1067,8 @@ enic_copy_action_v2(const struct rte_flow_action actions[], > > break; > > } > > } > > + if (!overlap & FATE) > > Same > > > + return ENOTSUP; > > enic_action->type = FILTER_ACTION_V2; > > return 0; > > } > > [...] Thanks for reporting. These "!overlap" checks are indeed messy, oddly my own compilation tests with GCC and clang did not report them. I'll submit an updated version. -- Adrien Mazarguil 6WIND ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v4 06/16] ethdev: remove C99 flexible arrays from flow API 2018-04-16 16:22 ` [dpdk-dev] [PATCH v4 00/16] Flow API overhaul for switch offloads Adrien Mazarguil ` (4 preceding siblings ...) 2018-04-16 16:22 ` [dpdk-dev] [PATCH v4 05/16] ethdev: alter behavior of flow API actions Adrien Mazarguil @ 2018-04-16 16:22 ` Adrien Mazarguil 2018-04-17 20:18 ` Thomas Monjalon 2018-04-16 16:22 ` [dpdk-dev] [PATCH v4 07/16] ethdev: flatten RSS configuration in " Adrien Mazarguil ` (10 subsequent siblings) 16 siblings, 1 reply; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-16 16:22 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev This patch replaces C99-style flexible arrays in struct rte_flow_action_rss and struct rte_flow_item_raw with standard pointers to the same data. They proved difficult to use in the field (e.g. no possibility of static initialization) and unsuitable for C++ applications. Affected PMDs and examples are updated accordingly. This breaks ABI compatibility for the following public functions: - rte_flow_copy() - rte_flow_create() - rte_flow_query() - rte_flow_validate() Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> --- app/test-pmd/cmdline_flow.c | 117 +++++++++++++++++--------------- app/test-pmd/config.c | 25 ++++--- doc/guides/prog_guide/rte_flow.rst | 18 ++--- drivers/net/mlx4/mlx4_flow.c | 22 +++--- drivers/net/mlx5/mlx5_flow.c | 20 +++--- examples/ipsec-secgw/ipsec.c | 17 ++--- lib/librte_ether/rte_flow.c | 25 ++++--- lib/librte_ether/rte_flow.h | 8 ++- 8 files changed, 135 insertions(+), 117 deletions(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 2ddb08feb..798b7948d 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -179,25 +179,22 @@ enum index { ACTION_METER_ID, }; -/** Size of pattern[] field in struct rte_flow_item_raw. */ -#define ITEM_RAW_PATTERN_SIZE 36 +/** Maximum size for pattern in struct rte_flow_item_raw. */ +#define ITEM_RAW_PATTERN_SIZE 40 /** Storage size for struct rte_flow_item_raw including pattern. */ #define ITEM_RAW_SIZE \ - (offsetof(struct rte_flow_item_raw, pattern) + ITEM_RAW_PATTERN_SIZE) + (sizeof(struct rte_flow_item_raw) + ITEM_RAW_PATTERN_SIZE) /** Maximum number of queue indices in struct rte_flow_action_rss. */ #define ACTION_RSS_QUEUE_NUM 32 /** Storage for struct rte_flow_action_rss including external data. */ -union action_rss_data { +struct action_rss_data { struct rte_flow_action_rss conf; - struct { - uint8_t conf_data[offsetof(struct rte_flow_action_rss, queue)]; - uint16_t queue[ACTION_RSS_QUEUE_NUM]; - struct rte_eth_rss_conf rss_conf; - uint8_t rss_key[RSS_HASH_KEY_LENGTH]; - } s; + uint16_t queue[ACTION_RSS_QUEUE_NUM]; + struct rte_eth_rss_conf rss_conf; + uint8_t rss_key[RSS_HASH_KEY_LENGTH]; }; /** Maximum number of subsequent tokens and arguments on the stack. */ @@ -320,13 +317,6 @@ struct token { .size = sizeof(*((s *)0)->f), \ }) -/** Static initializer for ARGS() with arbitrary size. */ -#define ARGS_ENTRY_USZ(s, f, sz) \ - (&(const struct arg){ \ - .offset = offsetof(s, f), \ - .size = (sz), \ - }) - /** Static initializer for ARGS() with arbitrary offset and size. */ #define ARGS_ENTRY_ARB(o, s) \ (&(const struct arg){ \ @@ -1105,9 +1095,9 @@ static const struct token token_list[] = { NEXT_ENTRY(ITEM_PARAM_IS, ITEM_PARAM_SPEC, ITEM_PARAM_MASK)), - .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, length), - ARGS_ENTRY_USZ(struct rte_flow_item_raw, - pattern, + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, pattern), + ARGS_ENTRY(struct rte_flow_item_raw, length), + ARGS_ENTRY_ARB(sizeof(struct rte_flow_item_raw), ITEM_RAW_PATTERN_SIZE)), }, [ITEM_ETH] = { @@ -1591,7 +1581,7 @@ static const struct token token_list[] = { [ACTION_RSS] = { .name = "rss", .help = "spread packets among several queues", - .priv = PRIV_ACTION(RSS, sizeof(union action_rss_data)), + .priv = PRIV_ACTION(RSS, sizeof(struct action_rss_data)), .next = NEXT(action_rss), .call = parse_vc_action_rss, }, @@ -1610,23 +1600,21 @@ static const struct token token_list[] = { .name = "key", .help = "RSS hash key", .next = NEXT(action_rss, NEXT_ENTRY(STRING)), - .args = ARGS(ARGS_ENTRY_ARB - (((uintptr_t)&((union action_rss_data *)0)-> - s.rss_conf.rss_key_len), + .args = ARGS(ARGS_ENTRY_ARB(0, 0), + ARGS_ENTRY_ARB + (offsetof(struct action_rss_data, rss_conf) + + offsetof(struct rte_eth_rss_conf, rss_key_len), sizeof(((struct rte_eth_rss_conf *)0)-> rss_key_len)), - ARGS_ENTRY_ARB - (((uintptr_t)((union action_rss_data *)0)-> - s.rss_key), - RSS_HASH_KEY_LENGTH)), + ARGS_ENTRY(struct action_rss_data, rss_key)), }, [ACTION_RSS_KEY_LEN] = { .name = "key_len", .help = "RSS hash key length in bytes", .next = NEXT(action_rss, NEXT_ENTRY(UNSIGNED)), .args = ARGS(ARGS_ENTRY_ARB_BOUNDED - (((uintptr_t)&((union action_rss_data *)0)-> - s.rss_conf.rss_key_len), + (offsetof(struct action_rss_data, rss_conf) + + offsetof(struct rte_eth_rss_conf, rss_key_len), sizeof(((struct rte_eth_rss_conf *)0)-> rss_key_len), 0, @@ -2067,7 +2055,7 @@ parse_vc_action_rss(struct context *ctx, const struct token *token, { struct buffer *out = buf; struct rte_flow_action *action; - union action_rss_data *action_rss_data; + struct action_rss_data *action_rss_data; unsigned int i; int ret; @@ -2085,29 +2073,29 @@ parse_vc_action_rss(struct context *ctx, const struct token *token, ctx->objmask = NULL; /* Set up default configuration. */ action_rss_data = ctx->object; - *action_rss_data = (union action_rss_data){ + *action_rss_data = (struct action_rss_data){ .conf = (struct rte_flow_action_rss){ - .rss_conf = &action_rss_data->s.rss_conf, + .rss_conf = &action_rss_data->rss_conf, .num = RTE_MIN(nb_rxq, ACTION_RSS_QUEUE_NUM), + .queue = action_rss_data->queue, }, + .queue = { 0 }, + .rss_conf = (struct rte_eth_rss_conf){ + .rss_key = action_rss_data->rss_key, + .rss_key_len = sizeof(action_rss_data->rss_key), + .rss_hf = rss_hf, + }, + .rss_key = "testpmd's default RSS hash key", }; - action_rss_data->s.rss_conf = (struct rte_eth_rss_conf){ - .rss_key = action_rss_data->s.rss_key, - .rss_key_len = sizeof(action_rss_data->s.rss_key), - .rss_hf = rss_hf, - }; - strncpy((void *)action_rss_data->s.rss_key, - "testpmd's default RSS hash key", - sizeof(action_rss_data->s.rss_key)); for (i = 0; i < action_rss_data->conf.num; ++i) - action_rss_data->conf.queue[i] = i; + action_rss_data->queue[i] = i; if (!port_id_is_invalid(ctx->port, DISABLED_WARN) && ctx->port != (portid_t)RTE_PORT_ALL) { struct rte_eth_dev_info info; rte_eth_dev_info_get(ctx->port, &info); - action_rss_data->s.rss_conf.rss_key_len = - RTE_MIN(sizeof(action_rss_data->s.rss_key), + action_rss_data->rss_conf.rss_key_len = + RTE_MIN(sizeof(action_rss_data->rss_key), info.hash_key_size); } action->conf = &action_rss_data->conf; @@ -2125,7 +2113,7 @@ parse_vc_action_rss_type(struct context *ctx, const struct token *token, void *buf, unsigned int size) { static const enum index next[] = NEXT_ENTRY(ACTION_RSS_TYPE); - union action_rss_data *action_rss_data; + struct action_rss_data *action_rss_data; unsigned int i; (void)token; @@ -2135,7 +2123,7 @@ parse_vc_action_rss_type(struct context *ctx, const struct token *token, return -1; if (!(ctx->objdata >> 16) && ctx->object) { action_rss_data = ctx->object; - action_rss_data->s.rss_conf.rss_hf = 0; + action_rss_data->rss_conf.rss_hf = 0; } if (!strcmp_partial("end", str, len)) { ctx->objdata &= 0xffff; @@ -2154,7 +2142,7 @@ parse_vc_action_rss_type(struct context *ctx, const struct token *token, if (!ctx->object) return len; action_rss_data = ctx->object; - action_rss_data->s.rss_conf.rss_hf |= rss_type_table[i].rss_type; + action_rss_data->rss_conf.rss_hf |= rss_type_table[i].rss_type; return len; } @@ -2169,7 +2157,7 @@ parse_vc_action_rss_queue(struct context *ctx, const struct token *token, void *buf, unsigned int size) { static const enum index next[] = NEXT_ENTRY(ACTION_RSS_QUEUE); - union action_rss_data *action_rss_data; + struct action_rss_data *action_rss_data; int ret; int i; @@ -2186,10 +2174,9 @@ parse_vc_action_rss_queue(struct context *ctx, const struct token *token, if (i >= ACTION_RSS_QUEUE_NUM) return -1; if (push_args(ctx, - ARGS_ENTRY_ARB(offsetof(struct rte_flow_action_rss, - queue) + - i * sizeof(action_rss_data->s.queue[i]), - sizeof(action_rss_data->s.queue[i])))) + ARGS_ENTRY_ARB(offsetof(struct action_rss_data, queue) + + i * sizeof(action_rss_data->queue[i]), + sizeof(action_rss_data->queue[i])))) return -1; ret = parse_int(ctx, token, str, len, NULL, 0); if (ret < 0) { @@ -2206,6 +2193,7 @@ parse_vc_action_rss_queue(struct context *ctx, const struct token *token, return len; action_rss_data = ctx->object; action_rss_data->conf.num = i; + action_rss_data->conf.queue = i ? action_rss_data->queue : NULL; return len; } @@ -2483,8 +2471,8 @@ parse_int(struct context *ctx, const struct token *token, /** * Parse a string. * - * Two arguments (ctx->args) are retrieved from the stack to store data and - * its length (in that order). + * Three arguments (ctx->args) are retrieved from the stack to store data, + * its actual length and address (in that order). */ static int parse_string(struct context *ctx, const struct token *token, @@ -2493,6 +2481,7 @@ parse_string(struct context *ctx, const struct token *token, { const struct arg *arg_data = pop_args(ctx); const struct arg *arg_len = pop_args(ctx); + const struct arg *arg_addr = pop_args(ctx); char tmp[16]; /* Ought to be enough. */ int ret; @@ -2503,6 +2492,11 @@ parse_string(struct context *ctx, const struct token *token, push_args(ctx, arg_data); return -1; } + if (!arg_addr) { + push_args(ctx, arg_len); + push_args(ctx, arg_data); + return -1; + } size = arg_data->size; /* Bit-mask fill is not supported. */ if (arg_data->mask || size < len) @@ -2525,8 +2519,23 @@ parse_string(struct context *ctx, const struct token *token, memset((uint8_t *)buf + len, 0x00, size - len); if (ctx->objmask) memset((uint8_t *)ctx->objmask + arg_data->offset, 0xff, len); + /* Save address if requested. */ + if (arg_addr->size) { + memcpy((uint8_t *)ctx->object + arg_addr->offset, + (void *[]){ + (uint8_t *)ctx->object + arg_data->offset + }, + arg_addr->size); + if (ctx->objmask) + memcpy((uint8_t *)ctx->objmask + arg_addr->offset, + (void *[]){ + (uint8_t *)ctx->objmask + arg_data->offset + }, + arg_addr->size); + } return len; error: + push_args(ctx, arg_addr); push_args(ctx, arg_len); push_args(ctx, arg_data); return -1; diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index d0d372797..95618e4eb 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -977,7 +977,7 @@ static const struct { MK_FLOW_ITEM(PF, 0), MK_FLOW_ITEM(VF, sizeof(struct rte_flow_item_vf)), MK_FLOW_ITEM(PORT, sizeof(struct rte_flow_item_port)), - MK_FLOW_ITEM(RAW, sizeof(struct rte_flow_item_raw)), /* +pattern[] */ + MK_FLOW_ITEM(RAW, sizeof(struct rte_flow_item_raw)), MK_FLOW_ITEM(ETH, sizeof(struct rte_flow_item_eth)), MK_FLOW_ITEM(VLAN, sizeof(struct rte_flow_item_vlan)), MK_FLOW_ITEM(IPV4, sizeof(struct rte_flow_item_ipv4)), @@ -1026,14 +1026,20 @@ flow_item_spec_copy(void *buf, const struct rte_flow_item *item, union { struct rte_flow_item_raw *raw; } dst; + size_t off; case RTE_FLOW_ITEM_TYPE_RAW: src.raw = item_spec; dst.raw = buf; - size = offsetof(struct rte_flow_item_raw, pattern) + - src.raw->length * sizeof(*src.raw->pattern); - if (dst.raw) - memcpy(dst.raw, src.raw, size); + off = RTE_ALIGN_CEIL(sizeof(struct rte_flow_item_raw), + sizeof(*src.raw->pattern)); + size = off + src.raw->length * sizeof(*src.raw->pattern); + if (dst.raw) { + memcpy(dst.raw, src.raw, sizeof(*src.raw)); + dst.raw->pattern = memcpy((uint8_t *)dst.raw + off, + src.raw->pattern, + size - off); + } break; default: size = flow_item[item->type].size; @@ -1065,7 +1071,7 @@ static const struct { MK_FLOW_ACTION(QUEUE, sizeof(struct rte_flow_action_queue)), MK_FLOW_ACTION(DROP, 0), MK_FLOW_ACTION(COUNT, 0), - MK_FLOW_ACTION(RSS, sizeof(struct rte_flow_action_rss)), /* +queue[] */ + MK_FLOW_ACTION(RSS, sizeof(struct rte_flow_action_rss)), MK_FLOW_ACTION(PF, 0), MK_FLOW_ACTION(VF, sizeof(struct rte_flow_action_vf)), MK_FLOW_ACTION(METER, sizeof(struct rte_flow_action_meter)), @@ -1096,11 +1102,14 @@ flow_action_conf_copy(void *buf, const struct rte_flow_action *action) *dst.rss = (struct rte_flow_action_rss){ .num = src.rss->num, }; - off += offsetof(struct rte_flow_action_rss, queue); + off += sizeof(*src.rss); if (src.rss->num) { + off = RTE_ALIGN_CEIL(off, sizeof(double)); size = sizeof(*src.rss->queue) * src.rss->num; if (dst.rss) - memcpy(dst.rss->queue, src.rss->queue, size); + dst.rss->queue = memcpy + ((void *)((uintptr_t)dst.rss + off), + src.rss->queue, size); off += size; } off = RTE_ALIGN_CEIL(off, sizeof(double)); diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 80360d068..acbeaacbd 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -1309,15 +1309,15 @@ field only, both can be requested simultaneously. .. table:: RSS - +--------------+------------------------------+ - | Field | Value | - +==============+==============================+ - | ``rss_conf`` | RSS parameters | - +--------------+------------------------------+ - | ``num`` | number of entries in queue[] | - +--------------+------------------------------+ - | ``queue[]`` | queue indices to use | - +--------------+------------------------------+ + +--------------+--------------------------------+ + | Field | Value | + +==============+================================+ + | ``rss_conf`` | RSS parameters | + +--------------+--------------------------------+ + | ``num`` | number of entries in ``queue`` | + +--------------+--------------------------------+ + | ``queue`` | queue indices to use | + +--------------+--------------------------------+ Action: ``PF`` ^^^^^^^^^^^^^^ diff --git a/drivers/net/mlx4/mlx4_flow.c b/drivers/net/mlx4/mlx4_flow.c index 15cdf07b7..8feb6ae31 100644 --- a/drivers/net/mlx4/mlx4_flow.c +++ b/drivers/net/mlx4/mlx4_flow.c @@ -1282,14 +1282,16 @@ mlx4_flow_internal(struct priv *priv, struct rte_flow_error *error) */ uint32_t queues = rte_align32pow2(priv->dev->data->nb_rx_queues + 1) >> 1; - alignas(struct rte_flow_action_rss) uint8_t rss_conf_data - [offsetof(struct rte_flow_action_rss, queue) + - sizeof(((struct rte_flow_action_rss *)0)->queue[0]) * queues]; - struct rte_flow_action_rss *rss_conf = (void *)rss_conf_data; + uint16_t queue[queues]; + struct rte_flow_action_rss action_rss = { + .rss_conf = NULL, /* Rely on default fallback settings. */ + .num = queues, + .queue = queue, + }; struct rte_flow_action actions[] = { { .type = RTE_FLOW_ACTION_TYPE_RSS, - .conf = rss_conf, + .conf = &action_rss, }, { .type = RTE_FLOW_ACTION_TYPE_END, @@ -1311,12 +1313,8 @@ mlx4_flow_internal(struct priv *priv, struct rte_flow_error *error) if (!queues) goto error; /* Prepare default RSS configuration. */ - *rss_conf = (struct rte_flow_action_rss){ - .rss_conf = NULL, /* Rely on default fallback settings. */ - .num = queues, - }; for (i = 0; i != queues; ++i) - rss_conf->queue[i] = i; + queue[i] = i; /* * Set up VLAN item if filtering is enabled and at least one VLAN * filter is configured. @@ -1375,7 +1373,7 @@ mlx4_flow_internal(struct priv *priv, struct rte_flow_error *error) if (j != sizeof(mac->addr_bytes)) continue; if (flow->rss->queues != queues || - memcmp(flow->rss->queue_id, rss_conf->queue, + memcmp(flow->rss->queue_id, action_rss.queue, queues * sizeof(flow->rss->queue_id[0]))) continue; break; @@ -1415,7 +1413,7 @@ mlx4_flow_internal(struct priv *priv, struct rte_flow_error *error) if (flow && flow->internal) { assert(flow->rss); if (flow->rss->queues != queues || - memcmp(flow->rss->queue_id, rss_conf->queue, + memcmp(flow->rss->queue_id, action_rss.queue, queues * sizeof(flow->rss->queue_id[0]))) flow = NULL; } diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 9923bfa59..75ea0cbcb 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -2446,9 +2446,16 @@ mlx5_ctrl_flow_vlan(struct rte_eth_dev *dev, .type = RTE_FLOW_ITEM_TYPE_END, }, }; + uint16_t queue[priv->reta_idx_n]; + struct rte_flow_action_rss action_rss = { + .rss_conf = &priv->rss_conf, + .num = priv->reta_idx_n, + .queue = queue, + }; struct rte_flow_action actions[] = { { .type = RTE_FLOW_ACTION_TYPE_RSS, + .conf = &action_rss, }, { .type = RTE_FLOW_ACTION_TYPE_END, @@ -2457,24 +2464,13 @@ mlx5_ctrl_flow_vlan(struct rte_eth_dev *dev, struct rte_flow *flow; struct rte_flow_error error; unsigned int i; - union { - struct rte_flow_action_rss rss; - struct { - const struct rte_eth_rss_conf *rss_conf; - uint16_t num; - uint16_t queue[RTE_MAX_QUEUES_PER_PORT]; - } local; - } action_rss; if (!priv->reta_idx_n) { rte_errno = EINVAL; return -rte_errno; } for (i = 0; i != priv->reta_idx_n; ++i) - action_rss.local.queue[i] = (*priv->reta_idx)[i]; - action_rss.local.rss_conf = &priv->rss_conf; - action_rss.local.num = priv->reta_idx_n; - actions[0].conf = (const void *)&action_rss.rss; + queue[i] = (*priv->reta_idx)[i]; flow = mlx5_flow_list_create(dev, &priv->ctrl_flows, &attr, items, actions, &error); if (!flow) diff --git a/examples/ipsec-secgw/ipsec.c b/examples/ipsec-secgw/ipsec.c index 5fb5bc16e..8b2047adb 100644 --- a/examples/ipsec-secgw/ipsec.c +++ b/examples/ipsec-secgw/ipsec.c @@ -186,14 +186,8 @@ create_session(struct ipsec_ctx *ipsec_ctx, struct ipsec_sa *sa) .rss_key_len = 40, }; struct rte_eth_dev *eth_dev; - union { - struct rte_flow_action_rss rss; - struct { - const struct rte_eth_rss_conf *rss_conf; - uint16_t num; - uint16_t queue[RTE_MAX_QUEUES_PER_PORT]; - } local; - } action_rss; + uint16_t queue[RTE_MAX_QUEUES_PER_PORT]; + struct rte_flow_action_rss action_rss; unsigned int i; unsigned int j; @@ -207,9 +201,10 @@ create_session(struct ipsec_ctx *ipsec_ctx, struct ipsec_sa *sa) for (i = 0, j = 0; i < eth_dev->data->nb_rx_queues; ++i) if (eth_dev->data->rx_queues[i]) - action_rss.local.queue[j++] = i; - action_rss.local.num = j; - action_rss.local.rss_conf = &rss_conf; + queue[j++] = i; + action_rss.rss_conf = &rss_conf; + action_rss.num = j; + action_rss.queue = queue; ret = rte_flow_validate(sa->portid, &sa->attr, sa->pattern, sa->action, &err); diff --git a/lib/librte_ether/rte_flow.c b/lib/librte_ether/rte_flow.c index 80f9cb6cb..bb19e28c6 100644 --- a/lib/librte_ether/rte_flow.c +++ b/lib/librte_ether/rte_flow.c @@ -39,7 +39,7 @@ static const struct rte_flow_desc_data rte_flow_desc_item[] = { MK_FLOW_ITEM(PF, 0), MK_FLOW_ITEM(VF, sizeof(struct rte_flow_item_vf)), MK_FLOW_ITEM(PORT, sizeof(struct rte_flow_item_port)), - MK_FLOW_ITEM(RAW, sizeof(struct rte_flow_item_raw)), /* +pattern[] */ + MK_FLOW_ITEM(RAW, sizeof(struct rte_flow_item_raw)), MK_FLOW_ITEM(ETH, sizeof(struct rte_flow_item_eth)), MK_FLOW_ITEM(VLAN, sizeof(struct rte_flow_item_vlan)), MK_FLOW_ITEM(IPV4, sizeof(struct rte_flow_item_ipv4)), @@ -73,7 +73,7 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = { MK_FLOW_ACTION(QUEUE, sizeof(struct rte_flow_action_queue)), MK_FLOW_ACTION(DROP, 0), MK_FLOW_ACTION(COUNT, 0), - MK_FLOW_ACTION(RSS, sizeof(struct rte_flow_action_rss)), /* +queue[] */ + MK_FLOW_ACTION(RSS, sizeof(struct rte_flow_action_rss)), MK_FLOW_ACTION(PF, 0), MK_FLOW_ACTION(VF, sizeof(struct rte_flow_action_vf)), }; @@ -282,14 +282,20 @@ flow_item_spec_copy(void *buf, const struct rte_flow_item *item, union { struct rte_flow_item_raw *raw; } dst; + size_t off; case RTE_FLOW_ITEM_TYPE_RAW: src.raw = item_spec; dst.raw = buf; - size = offsetof(struct rte_flow_item_raw, pattern) + - src.raw->length * sizeof(*src.raw->pattern); - if (dst.raw) - memcpy(dst.raw, src.raw, size); + off = RTE_ALIGN_CEIL(sizeof(struct rte_flow_item_raw), + sizeof(*src.raw->pattern)); + size = off + src.raw->length * sizeof(*src.raw->pattern); + if (dst.raw) { + memcpy(dst.raw, src.raw, sizeof(*src.raw)); + dst.raw->pattern = memcpy((uint8_t *)dst.raw + off, + src.raw->pattern, + size - off); + } break; default: size = rte_flow_desc_item[item->type].size; @@ -326,11 +332,14 @@ flow_action_conf_copy(void *buf, const struct rte_flow_action *action) *dst.rss = (struct rte_flow_action_rss){ .num = src.rss->num, }; - off += offsetof(struct rte_flow_action_rss, queue); + off += sizeof(*src.rss); if (src.rss->num) { + off = RTE_ALIGN_CEIL(off, sizeof(double)); size = sizeof(*src.rss->queue) * src.rss->num; if (dst.rss) - memcpy(dst.rss->queue, src.rss->queue, size); + dst.rss->queue = memcpy + ((void *)((uintptr_t)dst.rss + off), + src.rss->queue, size); off += size; } off = RTE_ALIGN_CEIL(off, sizeof(double)); diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index 96184f030..ad2e55b8e 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -14,6 +14,7 @@ * associated actions in hardware through flow rules. */ +#include <stddef.h> #include <stdint.h> #include <rte_arp.h> @@ -432,7 +433,7 @@ struct rte_flow_item_raw { int32_t offset; /**< Absolute or relative offset for pattern. */ uint16_t limit; /**< Search area limit for start of pattern. */ uint16_t length; /**< Pattern length. */ - uint8_t pattern[]; /**< Byte string to look for. */ + const uint8_t *pattern; /**< Byte string to look for. */ }; /** Default mask for RTE_FLOW_ITEM_TYPE_RAW. */ @@ -444,6 +445,7 @@ static const struct rte_flow_item_raw rte_flow_item_raw_mask = { .offset = 0xffffffff, .limit = 0xffff, .length = 0xffff, + .pattern = NULL, }; #endif @@ -1037,8 +1039,8 @@ struct rte_flow_query_count { */ struct rte_flow_action_rss { const struct rte_eth_rss_conf *rss_conf; /**< RSS parameters. */ - uint16_t num; /**< Number of entries in queue[]. */ - uint16_t queue[]; /**< Queues indices to use. */ + uint16_t num; /**< Number of entries in @p queue. */ + const uint16_t *queue; /**< Queue indices to use. */ }; /** -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [dpdk-dev] [PATCH v4 06/16] ethdev: remove C99 flexible arrays from flow API 2018-04-16 16:22 ` [dpdk-dev] [PATCH v4 06/16] ethdev: remove C99 flexible arrays from flow API Adrien Mazarguil @ 2018-04-17 20:18 ` Thomas Monjalon 2018-04-18 6:45 ` Nélio Laranjeiro 0 siblings, 1 reply; 157+ messages in thread From: Thomas Monjalon @ 2018-04-17 20:18 UTC (permalink / raw) To: Adrien Mazarguil; +Cc: dev, Ferruh Yigit 16/04/2018 18:22, Adrien Mazarguil: > This patch replaces C99-style flexible arrays in struct rte_flow_action_rss > and struct rte_flow_item_raw with standard pointers to the same data. > > They proved difficult to use in the field (e.g. no possibility of static > initialization) and unsuitable for C++ applications. > > Affected PMDs and examples are updated accordingly. > > This breaks ABI compatibility for the following public functions: > > - rte_flow_copy() > - rte_flow_create() > - rte_flow_query() > - rte_flow_validate() > > Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> > --- > app/test-pmd/cmdline_flow.c | 117 +++++++++++++++++--------------- > app/test-pmd/config.c | 25 ++++--- > doc/guides/prog_guide/rte_flow.rst | 18 ++--- > drivers/net/mlx4/mlx4_flow.c | 22 +++--- > drivers/net/mlx5/mlx5_flow.c | 20 +++--- > examples/ipsec-secgw/ipsec.c | 17 ++--- > lib/librte_ether/rte_flow.c | 25 ++++--- > lib/librte_ether/rte_flow.h | 8 ++- > 8 files changed, 135 insertions(+), 117 deletions(-) There are almost as much insertions as deletions. So it's probably not a bad move. Acked-by: Thomas Monjalon <thomas@monjalon.net> ^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [dpdk-dev] [PATCH v4 06/16] ethdev: remove C99 flexible arrays from flow API 2018-04-17 20:18 ` Thomas Monjalon @ 2018-04-18 6:45 ` Nélio Laranjeiro 0 siblings, 0 replies; 157+ messages in thread From: Nélio Laranjeiro @ 2018-04-18 6:45 UTC (permalink / raw) To: Thomas Monjalon; +Cc: Adrien Mazarguil, dev, Ferruh Yigit On Tue, Apr 17, 2018 at 10:18:22PM +0200, Thomas Monjalon wrote: > 16/04/2018 18:22, Adrien Mazarguil: > > This patch replaces C99-style flexible arrays in struct rte_flow_action_rss > > and struct rte_flow_item_raw with standard pointers to the same data. > > > > They proved difficult to use in the field (e.g. no possibility of static > > initialization) and unsuitable for C++ applications. > > > > Affected PMDs and examples are updated accordingly. > > > > This breaks ABI compatibility for the following public functions: > > > > - rte_flow_copy() > > - rte_flow_create() > > - rte_flow_query() > > - rte_flow_validate() > > > > Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> > > --- > > app/test-pmd/cmdline_flow.c | 117 +++++++++++++++++--------------- > > app/test-pmd/config.c | 25 ++++--- > > doc/guides/prog_guide/rte_flow.rst | 18 ++--- > > drivers/net/mlx4/mlx4_flow.c | 22 +++--- > > drivers/net/mlx5/mlx5_flow.c | 20 +++--- > > examples/ipsec-secgw/ipsec.c | 17 ++--- > > lib/librte_ether/rte_flow.c | 25 ++++--- > > lib/librte_ether/rte_flow.h | 8 ++- > > 8 files changed, 135 insertions(+), 117 deletions(-) > > There are almost as much insertions as deletions. > So it's probably not a bad move. > > Acked-by: Thomas Monjalon <thomas@monjalon.net> For mlx5: Acked-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com> -- Nélio Laranjeiro 6WIND ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v4 07/16] ethdev: flatten RSS configuration in flow API 2018-04-16 16:22 ` [dpdk-dev] [PATCH v4 00/16] Flow API overhaul for switch offloads Adrien Mazarguil ` (5 preceding siblings ...) 2018-04-16 16:22 ` [dpdk-dev] [PATCH v4 06/16] ethdev: remove C99 flexible arrays from flow API Adrien Mazarguil @ 2018-04-16 16:22 ` Adrien Mazarguil 2018-04-16 16:22 ` [dpdk-dev] [PATCH v4 08/16] ethdev: add hash function to RSS flow API action Adrien Mazarguil ` (9 subsequent siblings) 16 siblings, 0 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-16 16:22 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev Cc: Xueming Li, Wenzhuo Lu, Jingjing Wu, Beilei Xing, Qi Zhang, Konstantin Ananyev, Nelio Laranjeiro, Yongseok Koh, Andrew Rybchenko, Pascal Mazon, Radu Nicolau, Akhil Goyal Since its inception, the rte_flow RSS action has been relying in part on external struct rte_eth_rss_conf for compatibility with the legacy RSS API. This structure lacks parameters such as the hash algorithm to use, and more recently, a method to tell which layer RSS should be performed on [1]. Given struct rte_eth_rss_conf will never be flexible enough to represent a complete RSS configuration (e.g. RETA table), this patch supersedes it by extending the rte_flow RSS action directly. A subsequent patch will add a field to use a non-default RSS hash algorithm. To that end, a field named "types" replaces the field formerly known as "rss_hf" and standing for "RSS hash functions" as it was confusing. Actual RSS hash function types are defined by enum rte_eth_hash_function. This patch updates all PMDs and example applications accordingly. It breaks ABI compatibility for the following public functions: - rte_flow_copy() - rte_flow_create() - rte_flow_query() - rte_flow_validate() [1] commit 676b605182a5 ("doc: announce ethdev API change for RSS configuration") Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Acked-by: Andrew Rybchenko <arybchenko@solarflare.com> Cc: Xueming Li <xuemingl@mellanox.com> Cc: Ferruh Yigit <ferruh.yigit@intel.com> Cc: Thomas Monjalon <thomas@monjalon.net> Cc: Wenzhuo Lu <wenzhuo.lu@intel.com> Cc: Jingjing Wu <jingjing.wu@intel.com> Cc: Beilei Xing <beilei.xing@intel.com> Cc: Qi Zhang <qi.z.zhang@intel.com> Cc: Konstantin Ananyev <konstantin.ananyev@intel.com> Cc: Nelio Laranjeiro <nelio.laranjeiro@6wind.com> Cc: Yongseok Koh <yskoh@mellanox.com> Cc: Andrew Rybchenko <arybchenko@solarflare.com> Cc: Pascal Mazon <pascal.mazon@6wind.com> Cc: Radu Nicolau <radu.nicolau@intel.com> Cc: Akhil Goyal <akhil.goyal@nxp.com> --- v3 changes: Documentation update regarding the meaning of a 0 value for RSS types in flow rules. It used to implicitly mean "no RSS" but is redefined as requesting a kind of "best-effort" mode from PMDs, i.e. anything ranging from empty to all-inclusive RSS; what matters is it provides safe defaults that will work regardless of PMD capabilities. --- app/test-pmd/cmdline_flow.c | 48 +++--- app/test-pmd/config.c | 39 ++--- doc/guides/prog_guide/rte_flow.rst | 28 ++-- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 6 +- drivers/net/e1000/e1000_ethdev.h | 13 +- drivers/net/e1000/igb_ethdev.c | 4 +- drivers/net/e1000/igb_flow.c | 31 ++-- drivers/net/e1000/igb_rxtx.c | 51 +++++- drivers/net/i40e/i40e_ethdev.c | 53 +++++-- drivers/net/i40e/i40e_ethdev.h | 15 +- drivers/net/i40e/i40e_flow.c | 47 +++--- drivers/net/ixgbe/ixgbe_ethdev.c | 4 +- drivers/net/ixgbe/ixgbe_ethdev.h | 13 +- drivers/net/ixgbe/ixgbe_flow.c | 30 ++-- drivers/net/ixgbe/ixgbe_rxtx.c | 51 +++++- drivers/net/mlx4/mlx4.c | 2 +- drivers/net/mlx4/mlx4_flow.c | 61 +++---- drivers/net/mlx4/mlx4_flow.h | 2 +- drivers/net/mlx4/mlx4_rxq.c | 2 +- drivers/net/mlx4/mlx4_rxtx.h | 2 +- drivers/net/mlx5/mlx5_flow.c | 193 +++++++++++------------ drivers/net/mlx5/mlx5_rxq.c | 22 +-- drivers/net/mlx5/mlx5_rxtx.h | 26 +-- drivers/net/sfc/sfc_flow.c | 21 ++- drivers/net/tap/tap_flow.c | 8 +- examples/ipsec-secgw/ipsec.c | 10 +- lib/librte_ether/rte_flow.c | 39 ++--- lib/librte_ether/rte_flow.h | 12 +- 28 files changed, 478 insertions(+), 355 deletions(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 798b7948d..c9c2c3ad9 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -192,9 +192,8 @@ enum index { /** Storage for struct rte_flow_action_rss including external data. */ struct action_rss_data { struct rte_flow_action_rss conf; + uint8_t key[RSS_HASH_KEY_LENGTH]; uint16_t queue[ACTION_RSS_QUEUE_NUM]; - struct rte_eth_rss_conf rss_conf; - uint8_t rss_key[RSS_HASH_KEY_LENGTH]; }; /** Maximum number of subsequent tokens and arguments on the stack. */ @@ -1587,7 +1586,7 @@ static const struct token token_list[] = { }, [ACTION_RSS_TYPES] = { .name = "types", - .help = "RSS hash types", + .help = "specific RSS hash types", .next = NEXT(action_rss, NEXT_ENTRY(ACTION_RSS_TYPE)), }, [ACTION_RSS_TYPE] = { @@ -1602,21 +1601,21 @@ static const struct token token_list[] = { .next = NEXT(action_rss, NEXT_ENTRY(STRING)), .args = ARGS(ARGS_ENTRY_ARB(0, 0), ARGS_ENTRY_ARB - (offsetof(struct action_rss_data, rss_conf) + - offsetof(struct rte_eth_rss_conf, rss_key_len), - sizeof(((struct rte_eth_rss_conf *)0)-> - rss_key_len)), - ARGS_ENTRY(struct action_rss_data, rss_key)), + (offsetof(struct action_rss_data, conf) + + offsetof(struct rte_flow_action_rss, key_len), + sizeof(((struct rte_flow_action_rss *)0)-> + key_len)), + ARGS_ENTRY(struct action_rss_data, key)), }, [ACTION_RSS_KEY_LEN] = { .name = "key_len", .help = "RSS hash key length in bytes", .next = NEXT(action_rss, NEXT_ENTRY(UNSIGNED)), .args = ARGS(ARGS_ENTRY_ARB_BOUNDED - (offsetof(struct action_rss_data, rss_conf) + - offsetof(struct rte_eth_rss_conf, rss_key_len), - sizeof(((struct rte_eth_rss_conf *)0)-> - rss_key_len), + (offsetof(struct action_rss_data, conf) + + offsetof(struct rte_flow_action_rss, key_len), + sizeof(((struct rte_flow_action_rss *)0)-> + key_len), 0, RSS_HASH_KEY_LENGTH)), }, @@ -2075,27 +2074,24 @@ parse_vc_action_rss(struct context *ctx, const struct token *token, action_rss_data = ctx->object; *action_rss_data = (struct action_rss_data){ .conf = (struct rte_flow_action_rss){ - .rss_conf = &action_rss_data->rss_conf, - .num = RTE_MIN(nb_rxq, ACTION_RSS_QUEUE_NUM), + .types = rss_hf, + .key_len = sizeof(action_rss_data->key), + .queue_num = RTE_MIN(nb_rxq, ACTION_RSS_QUEUE_NUM), + .key = action_rss_data->key, .queue = action_rss_data->queue, }, + .key = "testpmd's default RSS hash key", .queue = { 0 }, - .rss_conf = (struct rte_eth_rss_conf){ - .rss_key = action_rss_data->rss_key, - .rss_key_len = sizeof(action_rss_data->rss_key), - .rss_hf = rss_hf, - }, - .rss_key = "testpmd's default RSS hash key", }; - for (i = 0; i < action_rss_data->conf.num; ++i) + for (i = 0; i < action_rss_data->conf.queue_num; ++i) action_rss_data->queue[i] = i; if (!port_id_is_invalid(ctx->port, DISABLED_WARN) && ctx->port != (portid_t)RTE_PORT_ALL) { struct rte_eth_dev_info info; rte_eth_dev_info_get(ctx->port, &info); - action_rss_data->rss_conf.rss_key_len = - RTE_MIN(sizeof(action_rss_data->rss_key), + action_rss_data->conf.key_len = + RTE_MIN(sizeof(action_rss_data->key), info.hash_key_size); } action->conf = &action_rss_data->conf; @@ -2123,7 +2119,7 @@ parse_vc_action_rss_type(struct context *ctx, const struct token *token, return -1; if (!(ctx->objdata >> 16) && ctx->object) { action_rss_data = ctx->object; - action_rss_data->rss_conf.rss_hf = 0; + action_rss_data->conf.types = 0; } if (!strcmp_partial("end", str, len)) { ctx->objdata &= 0xffff; @@ -2142,7 +2138,7 @@ parse_vc_action_rss_type(struct context *ctx, const struct token *token, if (!ctx->object) return len; action_rss_data = ctx->object; - action_rss_data->rss_conf.rss_hf |= rss_type_table[i].rss_type; + action_rss_data->conf.types |= rss_type_table[i].rss_type; return len; } @@ -2192,7 +2188,7 @@ parse_vc_action_rss_queue(struct context *ctx, const struct token *token, if (!ctx->object) return len; action_rss_data = ctx->object; - action_rss_data->conf.num = i; + action_rss_data->conf.queue_num = i; action_rss_data->conf.queue = i ? action_rss_data->queue : NULL; return len; } diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 95618e4eb..3da09536a 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -1100,40 +1100,27 @@ flow_action_conf_copy(void *buf, const struct rte_flow_action *action) off = 0; if (dst.rss) *dst.rss = (struct rte_flow_action_rss){ - .num = src.rss->num, + .types = src.rss->types, + .key_len = src.rss->key_len, + .queue_num = src.rss->queue_num, }; off += sizeof(*src.rss); - if (src.rss->num) { + if (src.rss->key_len) { off = RTE_ALIGN_CEIL(off, sizeof(double)); - size = sizeof(*src.rss->queue) * src.rss->num; + size = sizeof(*src.rss->key) * src.rss->key_len; if (dst.rss) - dst.rss->queue = memcpy + dst.rss->key = memcpy ((void *)((uintptr_t)dst.rss + off), - src.rss->queue, size); + src.rss->key, size); off += size; } - off = RTE_ALIGN_CEIL(off, sizeof(double)); - if (dst.rss) { - dst.rss->rss_conf = (void *)((uintptr_t)dst.rss + off); - *(struct rte_eth_rss_conf *)(uintptr_t) - dst.rss->rss_conf = (struct rte_eth_rss_conf){ - .rss_key_len = src.rss->rss_conf->rss_key_len, - .rss_hf = src.rss->rss_conf->rss_hf, - }; - } - off += sizeof(*src.rss->rss_conf); - if (src.rss->rss_conf->rss_key_len) { + if (src.rss->queue_num) { off = RTE_ALIGN_CEIL(off, sizeof(double)); - size = sizeof(*src.rss->rss_conf->rss_key) * - src.rss->rss_conf->rss_key_len; - if (dst.rss) { - ((struct rte_eth_rss_conf *)(uintptr_t) - dst.rss->rss_conf)->rss_key = - (void *)((uintptr_t)dst.rss + off); - memcpy(dst.rss->rss_conf->rss_key, - src.rss->rss_conf->rss_key, - size); - } + size = sizeof(*src.rss->queue) * src.rss->queue_num; + if (dst.rss) + dst.rss->queue = memcpy + ((void *)((uintptr_t)dst.rss + off), + src.rss->queue, size); off += size; } size = off; diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index acbeaacbd..cf252eeba 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -1301,6 +1301,12 @@ Action: ``RSS`` Similar to QUEUE, except RSS is additionally performed on packets to spread them among several queues according to the provided parameters. +Unlike global RSS settings used by other DPDK APIs, unsetting the ``types`` +field does not disable RSS in a flow rule. Doing so instead requests safe +unspecified "best-effort" settings from the underlying PMD, which depending +on the flow rule, may result in anything ranging from empty (single queue) +to all-inclusive RSS. + Note: RSS hash result is stored in the ``hash.rss`` mbuf field which overlaps ``hash.fdir.lo``. Since `Action: MARK`_ sets the ``hash.fdir.hi`` field only, both can be requested simultaneously. @@ -1309,15 +1315,19 @@ field only, both can be requested simultaneously. .. table:: RSS - +--------------+--------------------------------+ - | Field | Value | - +==============+================================+ - | ``rss_conf`` | RSS parameters | - +--------------+--------------------------------+ - | ``num`` | number of entries in ``queue`` | - +--------------+--------------------------------+ - | ``queue`` | queue indices to use | - +--------------+--------------------------------+ + +---------------+---------------------------------------------+ + | Field | Value | + +===============+=============================================+ + | ``types`` | specific RSS hash types (see ``ETH_RSS_*``) | + +---------------+---------------------------------------------+ + | ``key_len`` | hash key length in bytes | + +---------------+---------------------------------------------+ + | ``queue_num`` | number of entries in ``queue`` | + +---------------+---------------------------------------------+ + | ``key`` | hash key | + +---------------+---------------------------------------------+ + | ``queue`` | queue indices to use | + +---------------+---------------------------------------------+ Action: ``PF`` ^^^^^^^^^^^^^^ diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index a015d02a4..17336d163 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3398,8 +3398,10 @@ This section lists supported actions and their attributes, if any. - ``rss``: spread packets among several queues. - - ``types [{RSS hash type} [...]] end``: RSS hash types, allowed tokens - are the same as `set_hash_input_set`_, an empty list means none (0). + - ``types [{RSS hash type} [...]] end``: specific RSS hash types, allowed + tokens are the same as `set_hash_input_set`_, except that an empty list + does not disable RSS but instead requests unspecified "best-effort" + settings. - ``key {string}``: RSS hash key, overrides ``key_len``. diff --git a/drivers/net/e1000/e1000_ethdev.h b/drivers/net/e1000/e1000_ethdev.h index 6354b894a..902001f36 100644 --- a/drivers/net/e1000/e1000_ethdev.h +++ b/drivers/net/e1000/e1000_ethdev.h @@ -4,6 +4,10 @@ #ifndef _E1000_ETHDEV_H_ #define _E1000_ETHDEV_H_ + +#include <stdint.h> + +#include <rte_flow.h> #include <rte_time.h> #include <rte_pci.h> @@ -27,6 +31,7 @@ #define E1000_CTRL_EXT_EXTEND_VLAN (1<<26) /* EXTENDED VLAN */ #define IGB_VFTA_SIZE 128 +#define IGB_HKEY_MAX_INDEX 10 #define IGB_MAX_RX_QUEUE_NUM 8 #define IGB_MAX_RX_QUEUE_NUM_82576 16 @@ -229,8 +234,8 @@ struct igb_ethertype_filter { }; struct igb_rte_flow_rss_conf { - struct rte_eth_rss_conf rss_conf; /**< RSS parameters. */ - uint16_t num; /**< Number of entries in queue[]. */ + struct rte_flow_action_rss conf; /**< RSS parameters. */ + uint8_t key[IGB_HKEY_MAX_INDEX * sizeof(uint32_t)]; /* Hash key. */ uint16_t queue[IGB_MAX_RX_QUEUE_NUM]; /**< Queues indices to use. */ }; @@ -501,6 +506,10 @@ int eth_igb_syn_filter_set(struct rte_eth_dev *dev, int eth_igb_add_del_flex_filter(struct rte_eth_dev *dev, struct rte_eth_flex_filter *filter, bool add); +int igb_rss_conf_init(struct igb_rte_flow_rss_conf *out, + const struct rte_flow_action_rss *in); +int igb_action_rss_same(const struct rte_flow_action_rss *comp, + const struct rte_flow_action_rss *with); int igb_config_rss_filter(struct rte_eth_dev *dev, struct igb_rte_flow_rss_conf *conf, bool add); diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c index 9b808a982..7e9935b7e 100644 --- a/drivers/net/e1000/igb_ethdev.c +++ b/drivers/net/e1000/igb_ethdev.c @@ -41,8 +41,6 @@ #define IGB_DEFAULT_TX_HTHRESH 1 #define IGB_DEFAULT_TX_WTHRESH ((hw->mac.type == e1000_82576) ? 1 : 16) -#define IGB_HKEY_MAX_INDEX 10 - /* Bit shift and mask */ #define IGB_4_BIT_WIDTH (CHAR_BIT / 2) #define IGB_4_BIT_MASK RTE_LEN2MASK(IGB_4_BIT_WIDTH, uint8_t) @@ -5576,7 +5574,7 @@ igb_rss_filter_restore(struct rte_eth_dev *dev) struct e1000_filter_info *filter_info = E1000_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private); - if (filter_info->rss_info.num) + if (filter_info->rss_info.conf.queue_num) igb_config_rss_filter(dev, &filter_info->rss_info, TRUE); } diff --git a/drivers/net/e1000/igb_flow.c b/drivers/net/e1000/igb_flow.c index c0f5b5190..8dc5f75f2 100644 --- a/drivers/net/e1000/igb_flow.c +++ b/drivers/net/e1000/igb_flow.c @@ -1292,7 +1292,7 @@ igb_parse_rss_filter(struct rte_eth_dev *dev, rss = (const struct rte_flow_action_rss *)act->conf; - if (!rss || !rss->num) { + if (!rss || !rss->queue_num) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, act, @@ -1300,7 +1300,7 @@ igb_parse_rss_filter(struct rte_eth_dev *dev, return -rte_errno; } - for (n = 0; n < rss->num; n++) { + for (n = 0; n < rss->queue_num; n++) { if (rss->queue[n] >= dev->data->nb_rx_queues) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, @@ -1310,14 +1310,18 @@ igb_parse_rss_filter(struct rte_eth_dev *dev, } } - if (rss->rss_conf) - rss_conf->rss_conf = *rss->rss_conf; - else - rss_conf->rss_conf.rss_hf = IGB_RSS_OFFLOAD_ALL; - - for (n = 0; n < rss->num; ++n) - rss_conf->queue[n] = rss->queue[n]; - rss_conf->num = rss->num; + if (rss->key_len && rss->key_len != RTE_DIM(rss_conf->key)) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, + "RSS hash key must be exactly 40 bytes"); + if (rss->queue_num > RTE_DIM(rss_conf->queue)) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, + "too many queues for RSS context"); + if (igb_rss_conf_init(rss_conf, rss)) + return rte_flow_error_set + (error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, act, + "RSS context initialization failure"); /* check if the next not void item is END */ index++; @@ -1518,9 +1522,8 @@ igb_flow_create(struct rte_eth_dev *dev, PMD_DRV_LOG(ERR, "failed to allocate memory"); goto out; } - rte_memcpy(&rss_filter_ptr->filter_info, - &rss_conf, - sizeof(struct igb_rte_flow_rss_conf)); + igb_rss_conf_init(&rss_filter_ptr->filter_info, + &rss_conf.conf); TAILQ_INSERT_TAIL(&igb_filter_rss_list, rss_filter_ptr, entries); flow->rule = rss_filter_ptr; @@ -1757,7 +1760,7 @@ igb_clear_rss_filter(struct rte_eth_dev *dev) struct e1000_filter_info *filter = E1000_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private); - if (filter->rss_info.num) + if (filter->rss_info.conf.queue_num) igb_config_rss_filter(dev, &filter->rss_info, FALSE); } diff --git a/drivers/net/e1000/igb_rxtx.c b/drivers/net/e1000/igb_rxtx.c index 323913f0d..45bb3455c 100644 --- a/drivers/net/e1000/igb_rxtx.c +++ b/drivers/net/e1000/igb_rxtx.c @@ -2898,12 +2898,47 @@ igb_txq_info_get(struct rte_eth_dev *dev, uint16_t queue_id, } int +igb_rss_conf_init(struct igb_rte_flow_rss_conf *out, + const struct rte_flow_action_rss *in) +{ + if (in->key_len > RTE_DIM(out->key) || + in->queue_num > RTE_DIM(out->queue)) + return -EINVAL; + out->conf = (struct rte_flow_action_rss){ + .types = in->types, + .key_len = in->key_len, + .queue_num = in->queue_num, + .key = memcpy(out->key, in->key, in->key_len), + .queue = memcpy(out->queue, in->queue, + sizeof(*in->queue) * in->queue_num), + }; + return 0; +} + +int +igb_action_rss_same(const struct rte_flow_action_rss *comp, + const struct rte_flow_action_rss *with) +{ + return (comp->types == with->types && + comp->key_len == with->key_len && + comp->queue_num == with->queue_num && + !memcmp(comp->key, with->key, with->key_len) && + !memcmp(comp->queue, with->queue, + sizeof(*with->queue) * with->queue_num)); +} + +int igb_config_rss_filter(struct rte_eth_dev *dev, struct igb_rte_flow_rss_conf *conf, bool add) { uint32_t shift; uint16_t i, j; - struct rte_eth_rss_conf rss_conf = conf->rss_conf; + struct rte_eth_rss_conf rss_conf = { + .rss_key = conf->conf.key_len ? + (void *)(uintptr_t)conf->conf.key : NULL, + .rss_key_len = conf->conf.key_len, + .rss_hf = conf->conf.types, + }; struct e1000_filter_info *filter_info = E1000_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private); struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private); @@ -2911,8 +2946,8 @@ igb_config_rss_filter(struct rte_eth_dev *dev, hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private); if (!add) { - if (memcmp(conf, &filter_info->rss_info, - sizeof(struct igb_rte_flow_rss_conf)) == 0) { + if (igb_action_rss_same(&filter_info->rss_info.conf, + &conf->conf)) { igb_rss_disable(dev); memset(&filter_info->rss_info, 0, sizeof(struct igb_rte_flow_rss_conf)); @@ -2921,7 +2956,7 @@ igb_config_rss_filter(struct rte_eth_dev *dev, return -EINVAL; } - if (filter_info->rss_info.num) + if (filter_info->rss_info.conf.queue_num) return -EINVAL; /* Fill in redirection table. */ @@ -2933,9 +2968,9 @@ igb_config_rss_filter(struct rte_eth_dev *dev, } reta; uint8_t q_idx; - if (j == conf->num) + if (j == conf->conf.queue_num) j = 0; - q_idx = conf->queue[j]; + q_idx = conf->conf.queue[j]; reta.bytes[i & 3] = (uint8_t)(q_idx << shift); if ((i & 3) == 3) E1000_WRITE_REG(hw, E1000_RETA(i >> 2), reta.dword); @@ -2952,8 +2987,8 @@ igb_config_rss_filter(struct rte_eth_dev *dev, rss_conf.rss_key = rss_intel_key; /* Default hash key */ igb_hw_rss_hash_set(hw, &rss_conf); - rte_memcpy(&filter_info->rss_info, - conf, sizeof(struct igb_rte_flow_rss_conf)); + if (igb_rss_conf_init(&filter_info->rss_info, &conf->conf)) + return -EINVAL; return 0; } diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index 180ac7449..e65235fc3 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c @@ -11,6 +11,7 @@ #include <inttypes.h> #include <assert.h> +#include <rte_common.h> #include <rte_eal.h> #include <rte_string_fns.h> #include <rte_pci.h> @@ -11499,7 +11500,7 @@ i40e_rss_filter_restore(struct i40e_pf *pf) { struct i40e_rte_flow_rss_conf *conf = &pf->rss_info; - if (conf->num) + if (conf->conf.queue_num) i40e_config_rss_filter(pf, conf, TRUE); } @@ -12031,18 +12032,52 @@ i40e_cloud_filter_qinq_create(struct i40e_pf *pf) } int +i40e_rss_conf_init(struct i40e_rte_flow_rss_conf *out, + const struct rte_flow_action_rss *in) +{ + if (in->key_len > RTE_DIM(out->key) || + in->queue_num > RTE_DIM(out->queue)) + return -EINVAL; + out->conf = (struct rte_flow_action_rss){ + .types = in->types, + .key_len = in->key_len, + .queue_num = in->queue_num, + .key = memcpy(out->key, in->key, in->key_len), + .queue = memcpy(out->queue, in->queue, + sizeof(*in->queue) * in->queue_num), + }; + return 0; +} + +int +i40e_action_rss_same(const struct rte_flow_action_rss *comp, + const struct rte_flow_action_rss *with) +{ + return (comp->types == with->types && + comp->key_len == with->key_len && + comp->queue_num == with->queue_num && + !memcmp(comp->key, with->key, with->key_len) && + !memcmp(comp->queue, with->queue, + sizeof(*with->queue) * with->queue_num)); +} + +int i40e_config_rss_filter(struct i40e_pf *pf, struct i40e_rte_flow_rss_conf *conf, bool add) { struct i40e_hw *hw = I40E_PF_TO_HW(pf); uint32_t i, lut = 0; uint16_t j, num; - struct rte_eth_rss_conf rss_conf = conf->rss_conf; + struct rte_eth_rss_conf rss_conf = { + .rss_key = conf->conf.key_len ? + (void *)(uintptr_t)conf->conf.key : NULL, + .rss_key_len = conf->conf.key_len, + .rss_hf = conf->conf.types, + }; struct i40e_rte_flow_rss_conf *rss_info = &pf->rss_info; if (!add) { - if (memcmp(conf, rss_info, - sizeof(struct i40e_rte_flow_rss_conf)) == 0) { + if (i40e_action_rss_same(&rss_info->conf, &conf->conf)) { i40e_pf_disable_rss(pf); memset(rss_info, 0, sizeof(struct i40e_rte_flow_rss_conf)); @@ -12051,7 +12086,7 @@ i40e_config_rss_filter(struct i40e_pf *pf, return -EINVAL; } - if (rss_info->num) + if (rss_info->conf.queue_num) return -EINVAL; /* If both VMDQ and RSS enabled, not all of PF queues are configured. @@ -12062,7 +12097,7 @@ i40e_config_rss_filter(struct i40e_pf *pf, else num = pf->dev_data->nb_rx_queues; - num = RTE_MIN(num, conf->num); + num = RTE_MIN(num, conf->conf.queue_num); PMD_DRV_LOG(INFO, "Max of contiguous %u PF queues are configured", num); @@ -12075,7 +12110,7 @@ i40e_config_rss_filter(struct i40e_pf *pf, for (i = 0, j = 0; i < hw->func_caps.rss_table_size; i++, j++) { if (j == num) j = 0; - lut = (lut << 8) | (conf->queue[j] & ((0x1 << + lut = (lut << 8) | (conf->conf.queue[j] & ((0x1 << hw->func_caps.rss_table_entry_width) - 1)); if ((i & 3) == 3) I40E_WRITE_REG(hw, I40E_PFQF_HLUT(i >> 2), lut); @@ -12100,8 +12135,8 @@ i40e_config_rss_filter(struct i40e_pf *pf, i40e_hw_rss_hash_set(pf, &rss_conf); - rte_memcpy(rss_info, - conf, sizeof(struct i40e_rte_flow_rss_conf)); + if (i40e_rss_conf_init(rss_info, &conf->conf)) + return -EINVAL; return 0; } diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h index d33b255e7..a0569d4ae 100644 --- a/drivers/net/i40e/i40e_ethdev.h +++ b/drivers/net/i40e/i40e_ethdev.h @@ -5,14 +5,19 @@ #ifndef _I40E_ETHDEV_H_ #define _I40E_ETHDEV_H_ +#include <stdint.h> + #include <rte_eth_ctrl.h> #include <rte_time.h> #include <rte_kvargs.h> #include <rte_hash.h> +#include <rte_flow.h> #include <rte_flow_driver.h> #include <rte_tm_driver.h> #include "rte_pmd_i40e.h" +#include "base/i40e_register.h" + #define I40E_VLAN_TAG_SIZE 4 #define I40E_AQ_LEN 32 @@ -878,9 +883,11 @@ struct i40e_customized_pctype { }; struct i40e_rte_flow_rss_conf { - struct rte_eth_rss_conf rss_conf; /**< RSS parameters. */ + struct rte_flow_action_rss conf; /**< RSS parameters. */ uint16_t queue_region_conf; /**< Queue region config flag */ - uint16_t num; /**< Number of entries in queue[]. */ + uint8_t key[(I40E_VFQF_HKEY_MAX_INDEX > I40E_PFQF_HKEY_MAX_INDEX ? + I40E_VFQF_HKEY_MAX_INDEX : I40E_PFQF_HKEY_MAX_INDEX) + 1 * + sizeof(uint32_t)]; /* Hash key. */ uint16_t queue[I40E_MAX_Q_PER_TC]; /**< Queues indices to use. */ }; @@ -1219,6 +1226,10 @@ void i40e_init_queue_region_conf(struct rte_eth_dev *dev); void i40e_flex_payload_reg_set_default(struct i40e_hw *hw); int i40e_set_rss_key(struct i40e_vsi *vsi, uint8_t *key, uint8_t key_len); int i40e_set_rss_lut(struct i40e_vsi *vsi, uint8_t *lut, uint16_t lut_size); +int i40e_rss_conf_init(struct i40e_rte_flow_rss_conf *out, + const struct rte_flow_action_rss *in); +int i40e_action_rss_same(const struct rte_flow_action_rss *comp, + const struct rte_flow_action_rss *with); int i40e_config_rss_filter(struct i40e_pf *pf, struct i40e_rte_flow_rss_conf *conf, bool add); diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c index d6f5e9923..ec6231003 100644 --- a/drivers/net/i40e/i40e_flow.c +++ b/drivers/net/i40e/i40e_flow.c @@ -4220,7 +4220,7 @@ i40e_flow_parse_rss_action(struct rte_eth_dev *dev, if (action_flag) { for (n = 0; n < 64; n++) { - if (rss->rss_conf->rss_hf & (hf_bit << n)) { + if (rss->types & (hf_bit << n)) { conf_info->region[0].hw_flowtype[0] = n; conf_info->region[0].flowtype_num = 1; conf_info->queue_region_number = 1; @@ -4236,12 +4236,12 @@ i40e_flow_parse_rss_action(struct rte_eth_dev *dev, * queue index for this port. */ if (conf_info->queue_region_number) { - for (i = 0; i < rss->num; i++) { - for (j = 0; j < rss_info->num; j++) { - if (rss->queue[i] == rss_info->queue[j]) + for (i = 0; i < rss->queue_num; i++) { + for (j = 0; j < rss_info->conf.queue_num; j++) { + if (rss->queue[i] == rss_info->conf.queue[j]) break; } - if (j == rss_info->num) { + if (j == rss_info->conf.queue_num) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, act, @@ -4250,7 +4250,7 @@ i40e_flow_parse_rss_action(struct rte_eth_dev *dev, } } - for (i = 0; i < rss->num - 1; i++) { + for (i = 0; i < rss->queue_num - 1; i++) { if (rss->queue[i + 1] != rss->queue[i] + 1) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, @@ -4265,8 +4265,8 @@ i40e_flow_parse_rss_action(struct rte_eth_dev *dev, for (n = 0; n < conf_info->queue_region_number; n++) { if (conf_info->region[n].user_priority_num || conf_info->region[n].flowtype_num) { - if (!((rte_is_power_of_2(rss->num)) && - rss->num <= 64)) { + if (!((rte_is_power_of_2(rss->queue_num)) && + rss->queue_num <= 64)) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, act, @@ -4294,7 +4294,8 @@ i40e_flow_parse_rss_action(struct rte_eth_dev *dev, } for (i = 0; i < info->queue_region_number; i++) { - if (info->region[i].queue_num == rss->num && + if (info->region[i].queue_num == + rss->queue_num && info->region[i].queue_start_index == rss->queue[0]) break; @@ -4310,7 +4311,7 @@ i40e_flow_parse_rss_action(struct rte_eth_dev *dev, } info->region[i].queue_num = - rss->num; + rss->queue_num; info->region[i].queue_start_index = rss->queue[0]; info->region[i].region_id = @@ -4356,7 +4357,7 @@ i40e_flow_parse_rss_action(struct rte_eth_dev *dev, if (rss_config->queue_region_conf) return 0; - if (!rss || !rss->num) { + if (!rss || !rss->queue_num) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, act, @@ -4364,7 +4365,7 @@ i40e_flow_parse_rss_action(struct rte_eth_dev *dev, return -rte_errno; } - for (n = 0; n < rss->num; n++) { + for (n = 0; n < rss->queue_num; n++) { if (rss->queue[n] >= dev->data->nb_rx_queues) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, @@ -4375,15 +4376,19 @@ i40e_flow_parse_rss_action(struct rte_eth_dev *dev, } /* Parse RSS related parameters from configuration */ - if (rss->rss_conf) - rss_config->rss_conf = *rss->rss_conf; - else - rss_config->rss_conf.rss_hf = - pf->adapter->flow_types_mask; + if (rss->key_len && rss->key_len > RTE_DIM(rss_config->key)) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, + "RSS hash key too large"); + if (rss->queue_num > RTE_DIM(rss_config->queue)) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, + "too many queues for RSS context"); + if (i40e_rss_conf_init(rss_config, rss)) + return rte_flow_error_set + (error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, act, + "RSS context initialization failure"); - for (n = 0; n < rss->num; ++n) - rss_config->queue[n] = rss->queue[n]; - rss_config->num = rss->num; index++; /* check if the next not void action is END */ @@ -4903,7 +4908,7 @@ i40e_flow_flush_rss_filter(struct rte_eth_dev *dev) ret = i40e_flush_queue_region_all_conf(dev, hw, pf, 0); - if (rss_info->num) + if (rss_info->conf.queue_num) ret = i40e_config_rss_filter(pf, rss_info, FALSE); return ret; } diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c index a5e2fc0ca..25a8d041d 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.c +++ b/drivers/net/ixgbe/ixgbe_ethdev.c @@ -100,8 +100,6 @@ #define IXGBE_QUEUE_STAT_COUNTERS (sizeof(hw_stats->qprc) / sizeof(hw_stats->qprc[0])) -#define IXGBE_HKEY_MAX_INDEX 10 - /* Additional timesync values. */ #define NSEC_PER_SEC 1000000000L #define IXGBE_INCVAL_10GB 0x66666666 @@ -8294,7 +8292,7 @@ ixgbe_rss_filter_restore(struct rte_eth_dev *dev) struct ixgbe_filter_info *filter_info = IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private); - if (filter_info->rss_info.num) + if (filter_info->rss_info.conf.queue_num) ixgbe_config_rss_filter(dev, &filter_info->rss_info, TRUE); } diff --git a/drivers/net/ixgbe/ixgbe_ethdev.h b/drivers/net/ixgbe/ixgbe_ethdev.h index 655077700..9491b03f4 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.h +++ b/drivers/net/ixgbe/ixgbe_ethdev.h @@ -4,6 +4,9 @@ #ifndef _IXGBE_ETHDEV_H_ #define _IXGBE_ETHDEV_H_ + +#include <stdint.h> + #include "base/ixgbe_type.h" #include "base/ixgbe_dcb.h" #include "base/ixgbe_dcb_82599.h" @@ -12,6 +15,7 @@ #ifdef RTE_LIBRTE_SECURITY #include "ixgbe_ipsec.h" #endif +#include <rte_flow.h> #include <rte_time.h> #include <rte_hash.h> #include <rte_pci.h> @@ -39,6 +43,7 @@ #define IXGBE_EXTENDED_VLAN (uint32_t)(1 << 26) /* EXTENDED VLAN ENABLE */ #define IXGBE_VFTA_SIZE 128 #define IXGBE_VLAN_TAG_SIZE 4 +#define IXGBE_HKEY_MAX_INDEX 10 #define IXGBE_MAX_RX_QUEUE_NUM 128 #define IXGBE_MAX_INTR_QUEUE_NUM 15 #define IXGBE_VMDQ_DCB_NB_QUEUES IXGBE_MAX_RX_QUEUE_NUM @@ -196,8 +201,8 @@ struct ixgbe_hw_fdir_info { }; struct ixgbe_rte_flow_rss_conf { - struct rte_eth_rss_conf rss_conf; /**< RSS parameters. */ - uint16_t num; /**< Number of entries in queue[]. */ + struct rte_flow_action_rss conf; /**< RSS parameters. */ + uint8_t key[IXGBE_HKEY_MAX_INDEX * sizeof(uint32_t)]; /* Hash key. */ uint16_t queue[IXGBE_MAX_RX_QUEUE_NUM]; /**< Queues indices to use. */ }; @@ -696,6 +701,10 @@ void ixgbe_tm_conf_init(struct rte_eth_dev *dev); void ixgbe_tm_conf_uninit(struct rte_eth_dev *dev); int ixgbe_set_queue_rate_limit(struct rte_eth_dev *dev, uint16_t queue_idx, uint16_t tx_rate); +int ixgbe_rss_conf_init(struct ixgbe_rte_flow_rss_conf *out, + const struct rte_flow_action_rss *in); +int ixgbe_action_rss_same(const struct rte_flow_action_rss *comp, + const struct rte_flow_action_rss *with); int ixgbe_config_rss_filter(struct rte_eth_dev *dev, struct ixgbe_rte_flow_rss_conf *conf, bool add); diff --git a/drivers/net/ixgbe/ixgbe_flow.c b/drivers/net/ixgbe/ixgbe_flow.c index abdeac28b..4e31c7c56 100644 --- a/drivers/net/ixgbe/ixgbe_flow.c +++ b/drivers/net/ixgbe/ixgbe_flow.c @@ -2761,7 +2761,7 @@ ixgbe_parse_rss_filter(struct rte_eth_dev *dev, rss = (const struct rte_flow_action_rss *)act->conf; - if (!rss || !rss->num) { + if (!rss || !rss->queue_num) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, act, @@ -2769,7 +2769,7 @@ ixgbe_parse_rss_filter(struct rte_eth_dev *dev, return -rte_errno; } - for (n = 0; n < rss->num; n++) { + for (n = 0; n < rss->queue_num; n++) { if (rss->queue[n] >= dev->data->nb_rx_queues) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, @@ -2778,14 +2778,19 @@ ixgbe_parse_rss_filter(struct rte_eth_dev *dev, return -rte_errno; } } - if (rss->rss_conf) - rss_conf->rss_conf = *rss->rss_conf; - else - rss_conf->rss_conf.rss_hf = IXGBE_RSS_OFFLOAD_ALL; - for (n = 0; n < rss->num; ++n) - rss_conf->queue[n] = rss->queue[n]; - rss_conf->num = rss->num; + if (rss->key_len && rss->key_len != RTE_DIM(rss_conf->key)) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, + "RSS hash key must be exactly 40 bytes"); + if (rss->queue_num > RTE_DIM(rss_conf->queue)) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, + "too many queues for RSS context"); + if (ixgbe_rss_conf_init(rss_conf, rss)) + return rte_flow_error_set + (error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, act, + "RSS context initialization failure"); /* check if the next not void item is END */ act = next_no_void_action(actions, act); @@ -2834,7 +2839,7 @@ ixgbe_clear_rss_filter(struct rte_eth_dev *dev) struct ixgbe_filter_info *filter_info = IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private); - if (filter_info->rss_info.num) + if (filter_info->rss_info.conf.queue_num) ixgbe_config_rss_filter(dev, &filter_info->rss_info, FALSE); } @@ -3153,9 +3158,8 @@ ixgbe_flow_create(struct rte_eth_dev *dev, PMD_DRV_LOG(ERR, "failed to allocate memory"); goto out; } - rte_memcpy(&rss_filter_ptr->filter_info, - &rss_conf, - sizeof(struct ixgbe_rte_flow_rss_conf)); + ixgbe_rss_conf_init(&rss_filter_ptr->filter_info, + &rss_conf.conf); TAILQ_INSERT_TAIL(&filter_rss_list, rss_filter_ptr, entries); flow->rule = rss_filter_ptr; diff --git a/drivers/net/ixgbe/ixgbe_rxtx.c b/drivers/net/ixgbe/ixgbe_rxtx.c index 7511e183f..94ea7444d 100644 --- a/drivers/net/ixgbe/ixgbe_rxtx.c +++ b/drivers/net/ixgbe/ixgbe_rxtx.c @@ -5675,6 +5675,36 @@ ixgbevf_dev_rxtx_start(struct rte_eth_dev *dev) } int +ixgbe_rss_conf_init(struct ixgbe_rte_flow_rss_conf *out, + const struct rte_flow_action_rss *in) +{ + if (in->key_len > RTE_DIM(out->key) || + in->queue_num > RTE_DIM(out->queue)) + return -EINVAL; + out->conf = (struct rte_flow_action_rss){ + .types = in->types, + .key_len = in->key_len, + .queue_num = in->queue_num, + .key = memcpy(out->key, in->key, in->key_len), + .queue = memcpy(out->queue, in->queue, + sizeof(*in->queue) * in->queue_num), + }; + return 0; +} + +int +ixgbe_action_rss_same(const struct rte_flow_action_rss *comp, + const struct rte_flow_action_rss *with) +{ + return (comp->types == with->types && + comp->key_len == with->key_len && + comp->queue_num == with->queue_num && + !memcmp(comp->key, with->key, with->key_len) && + !memcmp(comp->queue, with->queue, + sizeof(*with->queue) * with->queue_num)); +} + +int ixgbe_config_rss_filter(struct rte_eth_dev *dev, struct ixgbe_rte_flow_rss_conf *conf, bool add) { @@ -5684,7 +5714,12 @@ ixgbe_config_rss_filter(struct rte_eth_dev *dev, uint16_t j; uint16_t sp_reta_size; uint32_t reta_reg; - struct rte_eth_rss_conf rss_conf = conf->rss_conf; + struct rte_eth_rss_conf rss_conf = { + .rss_key = conf->conf.key_len ? + (void *)(uintptr_t)conf->conf.key : NULL, + .rss_key_len = conf->conf.key_len, + .rss_hf = conf->conf.types, + }; struct ixgbe_filter_info *filter_info = IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private); @@ -5694,8 +5729,8 @@ ixgbe_config_rss_filter(struct rte_eth_dev *dev, sp_reta_size = ixgbe_reta_size_get(hw->mac.type); if (!add) { - if (memcmp(conf, &filter_info->rss_info, - sizeof(struct ixgbe_rte_flow_rss_conf)) == 0) { + if (ixgbe_action_rss_same(&filter_info->rss_info.conf, + &conf->conf)) { ixgbe_rss_disable(dev); memset(&filter_info->rss_info, 0, sizeof(struct ixgbe_rte_flow_rss_conf)); @@ -5704,7 +5739,7 @@ ixgbe_config_rss_filter(struct rte_eth_dev *dev, return -EINVAL; } - if (filter_info->rss_info.num) + if (filter_info->rss_info.conf.queue_num) return -EINVAL; /* Fill in redirection table * The byte-swap is needed because NIC registers are in @@ -5714,9 +5749,9 @@ ixgbe_config_rss_filter(struct rte_eth_dev *dev, for (i = 0, j = 0; i < sp_reta_size; i++, j++) { reta_reg = ixgbe_reta_reg_get(hw->mac.type, i); - if (j == conf->num) + if (j == conf->conf.queue_num) j = 0; - reta = (reta << 8) | conf->queue[j]; + reta = (reta << 8) | conf->conf.queue[j]; if ((i & 3) == 3) IXGBE_WRITE_REG(hw, reta_reg, rte_bswap32(reta)); @@ -5733,8 +5768,8 @@ ixgbe_config_rss_filter(struct rte_eth_dev *dev, rss_conf.rss_key = rss_intel_key; /* Default hash key */ ixgbe_hw_rss_hash_set(hw, &rss_conf); - rte_memcpy(&filter_info->rss_info, - conf, sizeof(struct ixgbe_rte_flow_rss_conf)); + if (ixgbe_rss_conf_init(&filter_info->rss_info, &conf->conf)) + return -EINVAL; return 0; } diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c index 06f17703b..970d20dd1 100644 --- a/drivers/net/mlx4/mlx4.c +++ b/drivers/net/mlx4/mlx4.c @@ -569,7 +569,7 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev) " for UDP RSS and inner VXLAN RSS"); /* Fake support for all possible RSS hash fields. */ priv->hw_rss_sup = ~UINT64_C(0); - priv->hw_rss_sup = mlx4_conv_rss_hf(priv, -1); + priv->hw_rss_sup = mlx4_conv_rss_types(priv, -1); /* Filter out known unsupported fields. */ priv->hw_rss_sup &= ~(uint64_t)(IBV_RX_HASH_SRC_PORT_UDP | diff --git a/drivers/net/mlx4/mlx4_flow.c b/drivers/net/mlx4/mlx4_flow.c index 8feb6ae31..dd86e4ce7 100644 --- a/drivers/net/mlx4/mlx4_flow.c +++ b/drivers/net/mlx4/mlx4_flow.c @@ -76,22 +76,22 @@ struct mlx4_drop { }; /** - * Convert DPDK RSS hash fields to their Verbs equivalent. + * Convert DPDK RSS hash types to their Verbs equivalent. * - * This function returns the supported (default) set when @p rss_hf has + * This function returns the supported (default) set when @p types has * special value (uint64_t)-1. * * @param priv * Pointer to private structure. - * @param rss_hf - * Hash fields in DPDK format (see struct rte_eth_rss_conf). + * @param types + * Hash types in DPDK format (see struct rte_eth_rss_conf). * * @return * A valid Verbs RSS hash fields mask for mlx4 on success, (uint64_t)-1 * otherwise and rte_errno is set. */ uint64_t -mlx4_conv_rss_hf(struct priv *priv, uint64_t rss_hf) +mlx4_conv_rss_types(struct priv *priv, uint64_t types) { enum { IPV4, IPV6, TCP, UDP, }; const uint64_t in[] = { @@ -126,17 +126,17 @@ mlx4_conv_rss_hf(struct priv *priv, uint64_t rss_hf) unsigned int i; for (i = 0; i != RTE_DIM(in); ++i) - if (rss_hf & in[i]) { - seen |= rss_hf & in[i]; + if (types & in[i]) { + seen |= types & in[i]; conv |= out[i]; } if ((conv & priv->hw_rss_sup) == conv) { - if (rss_hf == (uint64_t)-1) { + if (types == (uint64_t)-1) { /* Include inner RSS by default if supported. */ conv |= priv->hw_rss_sup & IBV_RX_HASH_INNER; return conv; } - if (!(rss_hf & ~seen)) + if (!(types & ~seen)) return conv; } rte_errno = ENOTSUP; @@ -717,7 +717,8 @@ mlx4_flow_prepare(struct priv *priv, switch (action->type) { const struct rte_flow_action_queue *queue; const struct rte_flow_action_rss *rss; - const struct rte_eth_rss_conf *rss_conf; + const uint8_t *rss_key; + uint32_t rss_key_len; uint64_t fields; unsigned int i; @@ -747,58 +748,56 @@ mlx4_flow_prepare(struct priv *priv, break; rss = action->conf; /* Default RSS configuration if none is provided. */ - rss_conf = - rss->rss_conf ? - rss->rss_conf : - &(struct rte_eth_rss_conf){ - .rss_key = mlx4_rss_hash_key_default, - .rss_key_len = MLX4_RSS_HASH_KEY_SIZE, - .rss_hf = -1, - }; + if (rss->key_len) { + rss_key = rss->key; + rss_key_len = rss->key_len; + } else { + rss_key = mlx4_rss_hash_key_default; + rss_key_len = MLX4_RSS_HASH_KEY_SIZE; + } /* Sanity checks. */ - for (i = 0; i < rss->num; ++i) + for (i = 0; i < rss->queue_num; ++i) if (rss->queue[i] >= priv->dev->data->nb_rx_queues) break; - if (i != rss->num) { + if (i != rss->queue_num) { msg = "queue index target beyond number of" " configured Rx queues"; goto exit_action_not_supported; } - if (!rte_is_power_of_2(rss->num)) { + if (!rte_is_power_of_2(rss->queue_num)) { msg = "for RSS, mlx4 requires the number of" " queues to be a power of two"; goto exit_action_not_supported; } - if (rss_conf->rss_key_len != - sizeof(flow->rss->key)) { + if (rss_key_len != sizeof(flow->rss->key)) { msg = "mlx4 supports exactly one RSS hash key" " length: " MLX4_STR_EXPAND(MLX4_RSS_HASH_KEY_SIZE); goto exit_action_not_supported; } - for (i = 1; i < rss->num; ++i) + for (i = 1; i < rss->queue_num; ++i) if (rss->queue[i] - rss->queue[i - 1] != 1) break; - if (i != rss->num) { + if (i != rss->queue_num) { msg = "mlx4 requires RSS contexts to use" " consecutive queue indices only"; goto exit_action_not_supported; } - if (rss->queue[0] % rss->num) { + if (rss->queue[0] % rss->queue_num) { msg = "mlx4 requires the first queue of a RSS" " context to be aligned on a multiple" " of the context size"; goto exit_action_not_supported; } rte_errno = 0; - fields = mlx4_conv_rss_hf(priv, rss_conf->rss_hf); + fields = mlx4_conv_rss_types(priv, rss->types); if (fields == (uint64_t)-1 && rte_errno) { msg = "unsupported RSS hash type requested"; goto exit_action_not_supported; } flow->rss = mlx4_rss_get - (priv, fields, rss_conf->rss_key, rss->num, + (priv, fields, rss_key, rss->queue_num, rss->queue); if (!flow->rss) { msg = "either invalid parameters or not enough" @@ -1284,8 +1283,10 @@ mlx4_flow_internal(struct priv *priv, struct rte_flow_error *error) rte_align32pow2(priv->dev->data->nb_rx_queues + 1) >> 1; uint16_t queue[queues]; struct rte_flow_action_rss action_rss = { - .rss_conf = NULL, /* Rely on default fallback settings. */ - .num = queues, + .types = -1, + .key_len = MLX4_RSS_HASH_KEY_SIZE, + .queue_num = queues, + .key = mlx4_rss_hash_key_default, .queue = queue, }; struct rte_flow_action actions[] = { diff --git a/drivers/net/mlx4/mlx4_flow.h b/drivers/net/mlx4/mlx4_flow.h index 4e3889e67..7b83d74b0 100644 --- a/drivers/net/mlx4/mlx4_flow.h +++ b/drivers/net/mlx4/mlx4_flow.h @@ -47,7 +47,7 @@ struct rte_flow { /* mlx4_flow.c */ -uint64_t mlx4_conv_rss_hf(struct priv *priv, uint64_t rss_hf); +uint64_t mlx4_conv_rss_types(struct priv *priv, uint64_t rss_hf); int mlx4_flow_sync(struct priv *priv, struct rte_flow_error *error); void mlx4_flow_clean(struct priv *priv); int mlx4_filter_ctrl(struct rte_eth_dev *dev, diff --git a/drivers/net/mlx4/mlx4_rxq.c b/drivers/net/mlx4/mlx4_rxq.c index 6be6a0b9a..b430678c7 100644 --- a/drivers/net/mlx4/mlx4_rxq.c +++ b/drivers/net/mlx4/mlx4_rxq.c @@ -88,7 +88,7 @@ mlx4_rss_hash_key_default[MLX4_RSS_HASH_KEY_SIZE] = { */ struct mlx4_rss * mlx4_rss_get(struct priv *priv, uint64_t fields, - uint8_t key[MLX4_RSS_HASH_KEY_SIZE], + const uint8_t key[MLX4_RSS_HASH_KEY_SIZE], uint16_t queues, const uint16_t queue_id[]) { struct mlx4_rss *rss; diff --git a/drivers/net/mlx4/mlx4_rxtx.h b/drivers/net/mlx4/mlx4_rxtx.h index b1af86110..2dfee957f 100644 --- a/drivers/net/mlx4/mlx4_rxtx.h +++ b/drivers/net/mlx4/mlx4_rxtx.h @@ -127,7 +127,7 @@ uint8_t mlx4_rss_hash_key_default[MLX4_RSS_HASH_KEY_SIZE]; int mlx4_rss_init(struct priv *priv); void mlx4_rss_deinit(struct priv *priv); struct mlx4_rss *mlx4_rss_get(struct priv *priv, uint64_t fields, - uint8_t key[MLX4_RSS_HASH_KEY_SIZE], + const uint8_t key[MLX4_RSS_HASH_KEY_SIZE], uint16_t queues, const uint16_t queue_id[]); void mlx4_rss_put(struct mlx4_rss *rss); int mlx4_rss_attach(struct mlx4_rss *rss); diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 75ea0cbcb..86870b0cb 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -214,9 +214,8 @@ struct rte_flow { TAILQ_ENTRY(rte_flow) next; /**< Pointer to the next flow structure. */ uint32_t mark:1; /**< Set if the flow is marked. */ uint32_t drop:1; /**< Drop queue. */ - uint16_t queues_n; /**< Number of entries in queue[]. */ + struct rte_flow_action_rss rss_conf; /**< RSS configuration */ uint16_t (*queues)[]; /**< Queues indexes to use. */ - struct rte_eth_rss_conf rss_conf; /**< RSS configuration */ uint8_t rss_key[40]; /**< copy of the RSS key. */ struct ibv_counter_set *cs; /**< Holds the counters for the rule. */ struct mlx5_flow_counter_stats counter_stats;/**<The counter stats. */ @@ -406,9 +405,8 @@ struct mlx5_flow_parse { uint32_t mark:1; /**< Mark is present in the flow. */ uint32_t count:1; /**< Count is present in the flow. */ uint32_t mark_id; /**< Mark identifier. */ + struct rte_flow_action_rss rss_conf; /**< RSS configuration */ uint16_t queues[RTE_MAX_QUEUES_PER_PORT]; /**< Queues indexes to use. */ - uint16_t queues_n; /**< Number of entries in queue[]. */ - struct rte_eth_rss_conf rss_conf; /**< RSS configuration */ uint8_t rss_key[40]; /**< copy of the RSS key. */ enum hash_rxq_type layer; /**< Last pattern layer detected. */ struct ibv_counter_set *cs; /**< Holds the counter set for the rule */ @@ -532,47 +530,6 @@ mlx5_flow_item_validate(const struct rte_flow_item *item, } /** - * Copy the RSS configuration from the user ones, of the rss_conf is null, - * uses the driver one. - * - * @param parser - * Internal parser structure. - * @param rss_conf - * User RSS configuration to save. - * - * @return - * 0 on success, a negative errno value otherwise and rte_errno is set. - */ -static int -mlx5_flow_convert_rss_conf(struct mlx5_flow_parse *parser, - const struct rte_eth_rss_conf *rss_conf) -{ - /* - * This function is also called at the beginning of - * mlx5_flow_convert_actions() to initialize the parser with the - * device default RSS configuration. - */ - if (rss_conf) { - if (rss_conf->rss_hf & MLX5_RSS_HF_MASK) { - rte_errno = EINVAL; - return -rte_errno; - } - if (rss_conf->rss_key_len != 40) { - rte_errno = EINVAL; - return -rte_errno; - } - if (rss_conf->rss_key_len && rss_conf->rss_key) { - parser->rss_conf.rss_key_len = rss_conf->rss_key_len; - memcpy(parser->rss_key, rss_conf->rss_key, - rss_conf->rss_key_len); - parser->rss_conf.rss_key = parser->rss_key; - } - parser->rss_conf.rss_hf = rss_conf->rss_hf; - } - return 0; -} - -/** * Extract attribute to the parser. * * @param[in] attr @@ -642,17 +599,7 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, enum { FATE = 1, MARK = 2, COUNT = 4, }; uint32_t overlap = 0; struct priv *priv = dev->data->dev_private; - int ret; - /* - * Add default RSS configuration necessary for Verbs to create QP even - * if no RSS is necessary. - */ - ret = mlx5_flow_convert_rss_conf(parser, - (const struct rte_eth_rss_conf *) - &priv->rss_conf); - if (ret) - return ret; for (; actions->type != RTE_FLOW_ACTION_TYPE_END; ++actions) { if (actions->type == RTE_FLOW_ACTION_TYPE_VOID) { continue; @@ -671,25 +618,53 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, overlap |= FATE; if (!queue || (queue->index > (priv->rxqs_n - 1))) goto exit_action_not_supported; - parser->queues_n = 1; parser->queues[0] = queue->index; + parser->rss_conf = (struct rte_flow_action_rss){ + .queue_num = 1, + .queue = parser->queues, + }; } else if (actions->type == RTE_FLOW_ACTION_TYPE_RSS) { const struct rte_flow_action_rss *rss = (const struct rte_flow_action_rss *) actions->conf; + const uint8_t *rss_key; + uint32_t rss_key_len; uint16_t n; if (overlap & FATE) goto exit_action_overlap; overlap |= FATE; - if (!rss || !rss->num) { + if (rss->types & MLX5_RSS_HF_MASK) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION, + actions, + "unsupported RSS type" + " requested"); + return -rte_errno; + } + if (rss->key_len) { + rss_key_len = rss->key_len; + rss_key = rss->key; + } else { + rss_key_len = rss_hash_default_key_len; + rss_key = rss_hash_default_key; + } + if (rss_key_len != RTE_DIM(parser->rss_key)) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION, + actions, + "RSS hash key must be" + " exactly 40 bytes long"); + return -rte_errno; + } + if (!rss->queue_num) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, actions, "no valid queues"); return -rte_errno; } - if (rss->num > RTE_DIM(parser->queues)) { + if (rss->queue_num > RTE_DIM(parser->queues)) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, actions, @@ -697,7 +672,7 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, " context"); return -rte_errno; } - for (n = 0; n < rss->num; ++n) { + for (n = 0; n < rss->queue_num; ++n) { if (rss->queue[n] >= priv->rxqs_n) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, @@ -707,16 +682,16 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, return -rte_errno; } } - for (n = 0; n < rss->num; ++n) - parser->queues[n] = rss->queue[n]; - parser->queues_n = rss->num; - if (mlx5_flow_convert_rss_conf(parser, rss->rss_conf)) { - rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ACTION, - actions, - "wrong RSS configuration"); - return -rte_errno; - } + parser->rss_conf = (struct rte_flow_action_rss){ + .types = rss->types, + .key_len = rss_key_len, + .queue_num = rss->queue_num, + .key = memcpy(parser->rss_key, rss_key, + sizeof(*rss_key) * rss_key_len), + .queue = memcpy(parser->queues, rss->queue, + sizeof(*rss->queue) * + rss->queue_num), + }; } else if (actions->type == RTE_FLOW_ACTION_TYPE_MARK) { const struct rte_flow_action_mark *mark = (const struct rte_flow_action_mark *) @@ -761,7 +736,7 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, parser->drop = 1; if (parser->drop && parser->mark) parser->mark = 0; - if (!parser->queues_n && !parser->drop) { + if (!parser->rss_conf.queue_num && !parser->drop) { rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_HANDLE, NULL, "no valid action"); return -rte_errno; @@ -941,7 +916,7 @@ mlx5_flow_convert_finalise(struct mlx5_flow_parse *parser) unsigned int i; /* Remove any other flow not matching the pattern. */ - if (parser->queues_n == 1 && !parser->rss_conf.rss_hf) { + if (parser->rss_conf.queue_num == 1 && !parser->rss_conf.types) { for (i = 0; i != hash_rxq_init_n; ++i) { if (i == HASH_RXQ_ETH) continue; @@ -969,7 +944,7 @@ mlx5_flow_convert_finalise(struct mlx5_flow_parse *parser) } /* Remove impossible flow according to the RSS configuration. */ if (hash_rxq_init[parser->layer].dpdk_rss_hf & - parser->rss_conf.rss_hf) { + parser->rss_conf.types) { /* Remove any other flow. */ for (i = hmin; i != (hmax + 1); ++i) { if ((i == parser->layer) || @@ -980,7 +955,7 @@ mlx5_flow_convert_finalise(struct mlx5_flow_parse *parser) } } else if (!parser->queue[ip].ibv_attr) { /* no RSS possible with the current configuration. */ - parser->queues_n = 1; + parser->rss_conf.queue_num = 1; return; } fill: @@ -1109,7 +1084,7 @@ mlx5_flow_convert(struct rte_eth_dev *dev, for (i = 0; i != hash_rxq_init_n; ++i) { unsigned int offset; - if (!(parser->rss_conf.rss_hf & + if (!(parser->rss_conf.types & hash_rxq_init[i].dpdk_rss_hf) && (i != HASH_RXQ_ETH)) continue; @@ -1777,20 +1752,20 @@ mlx5_flow_create_action_queue_rss(struct rte_eth_dev *dev, continue; flow->frxq[i].hrxq = mlx5_hrxq_get(dev, - parser->rss_conf.rss_key, - parser->rss_conf.rss_key_len, + parser->rss_conf.key, + parser->rss_conf.key_len, hash_fields, - parser->queues, - parser->queues_n); + parser->rss_conf.queue, + parser->rss_conf.queue_num); if (flow->frxq[i].hrxq) continue; flow->frxq[i].hrxq = mlx5_hrxq_new(dev, - parser->rss_conf.rss_key, - parser->rss_conf.rss_key_len, + parser->rss_conf.key, + parser->rss_conf.key_len, hash_fields, - parser->queues, - parser->queues_n); + parser->rss_conf.queue, + parser->rss_conf.queue_num); if (!flow->frxq[i].hrxq) { return rte_flow_error_set(error, ENOMEM, RTE_FLOW_ERROR_TYPE_HANDLE, @@ -1861,9 +1836,9 @@ mlx5_flow_create_action_queue(struct rte_eth_dev *dev, NULL, "internal error in flow creation"); goto error; } - for (i = 0; i != parser->queues_n; ++i) { + for (i = 0; i != parser->rss_conf.queue_num; ++i) { struct mlx5_rxq_data *q = - (*priv->rxqs)[parser->queues[i]]; + (*priv->rxqs)[parser->rss_conf.queue[i]]; q->mark |= parser->mark; } @@ -1927,7 +1902,8 @@ mlx5_flow_list_create(struct rte_eth_dev *dev, if (ret) goto exit; flow = rte_calloc(__func__, 1, - sizeof(*flow) + parser.queues_n * sizeof(uint16_t), + sizeof(*flow) + + parser.rss_conf.queue_num * sizeof(uint16_t), 0); if (!flow) { rte_flow_error_set(error, ENOMEM, @@ -1936,15 +1912,20 @@ mlx5_flow_list_create(struct rte_eth_dev *dev, "cannot allocate flow memory"); return NULL; } - /* Copy queues configuration. */ + /* Copy configuration. */ flow->queues = (uint16_t (*)[])(flow + 1); - memcpy(flow->queues, parser.queues, parser.queues_n * sizeof(uint16_t)); - flow->queues_n = parser.queues_n; + flow->rss_conf = (struct rte_flow_action_rss){ + .types = parser.rss_conf.types, + .key_len = parser.rss_conf.key_len, + .queue_num = parser.rss_conf.queue_num, + .key = memcpy(flow->rss_key, parser.rss_conf.key, + sizeof(*parser.rss_conf.key) * + parser.rss_conf.key_len), + .queue = memcpy(flow->queues, parser.rss_conf.queue, + sizeof(*parser.rss_conf.queue) * + parser.rss_conf.queue_num), + }; flow->mark = parser.mark; - /* Copy RSS configuration. */ - flow->rss_conf = parser.rss_conf; - flow->rss_conf.rss_key = flow->rss_key; - memcpy(flow->rss_key, parser.rss_key, parser.rss_conf.rss_key_len); /* finalise the flow. */ if (parser.drop) ret = mlx5_flow_create_action_queue_drop(dev, &parser, flow, @@ -2024,7 +2005,7 @@ mlx5_flow_list_destroy(struct rte_eth_dev *dev, struct mlx5_flows *list, if (flow->drop || !flow->mark) goto free; - for (i = 0; i != flow->queues_n; ++i) { + for (i = 0; i != flow->rss_conf.queue_num; ++i) { struct rte_flow *tmp; int mark = 0; @@ -2334,19 +2315,19 @@ mlx5_flow_start(struct rte_eth_dev *dev, struct mlx5_flows *list) if (!flow->frxq[i].ibv_attr) continue; flow->frxq[i].hrxq = - mlx5_hrxq_get(dev, flow->rss_conf.rss_key, - flow->rss_conf.rss_key_len, + mlx5_hrxq_get(dev, flow->rss_conf.key, + flow->rss_conf.key_len, hash_rxq_init[i].hash_fields, - (*flow->queues), - flow->queues_n); + flow->rss_conf.queue, + flow->rss_conf.queue_num); if (flow->frxq[i].hrxq) goto flow_create; flow->frxq[i].hrxq = - mlx5_hrxq_new(dev, flow->rss_conf.rss_key, - flow->rss_conf.rss_key_len, + mlx5_hrxq_new(dev, flow->rss_conf.key, + flow->rss_conf.key_len, hash_rxq_init[i].hash_fields, - (*flow->queues), - flow->queues_n); + flow->rss_conf.queue, + flow->rss_conf.queue_num); if (!flow->frxq[i].hrxq) { DRV_LOG(DEBUG, "port %u flow %p cannot be applied", @@ -2370,8 +2351,8 @@ mlx5_flow_start(struct rte_eth_dev *dev, struct mlx5_flows *list) } if (!flow->mark) continue; - for (i = 0; i != flow->queues_n; ++i) - (*priv->rxqs)[(*flow->queues)[i]]->mark = 1; + for (i = 0; i != flow->rss_conf.queue_num; ++i) + (*priv->rxqs)[flow->rss_conf.queue[i]]->mark = 1; } return 0; } @@ -2448,8 +2429,10 @@ mlx5_ctrl_flow_vlan(struct rte_eth_dev *dev, }; uint16_t queue[priv->reta_idx_n]; struct rte_flow_action_rss action_rss = { - .rss_conf = &priv->rss_conf, - .num = priv->reta_idx_n, + .types = priv->rss_conf.rss_hf, + .key_len = priv->rss_conf.rss_key_len, + .queue_num = priv->reta_idx_n, + .key = priv->rss_conf.rss_key, .queue = queue, }; struct rte_flow_action actions[] = { diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c index eda3ba3d5..18ad40813 100644 --- a/drivers/net/mlx5/mlx5_rxq.c +++ b/drivers/net/mlx5/mlx5_rxq.c @@ -1218,8 +1218,8 @@ mlx5_rxq_verify(struct rte_eth_dev *dev) * The Verbs object initialised, NULL otherwise and rte_errno is set. */ struct mlx5_ind_table_ibv * -mlx5_ind_table_ibv_new(struct rte_eth_dev *dev, uint16_t queues[], - uint16_t queues_n) +mlx5_ind_table_ibv_new(struct rte_eth_dev *dev, const uint16_t *queues, + uint32_t queues_n) { struct priv *priv = dev->data->dev_private; struct mlx5_ind_table_ibv *ind_tbl; @@ -1286,8 +1286,8 @@ mlx5_ind_table_ibv_new(struct rte_eth_dev *dev, uint16_t queues[], * An indirection table if found. */ struct mlx5_ind_table_ibv * -mlx5_ind_table_ibv_get(struct rte_eth_dev *dev, uint16_t queues[], - uint16_t queues_n) +mlx5_ind_table_ibv_get(struct rte_eth_dev *dev, const uint16_t *queues, + uint32_t queues_n) { struct priv *priv = dev->data->dev_private; struct mlx5_ind_table_ibv *ind_tbl; @@ -1391,8 +1391,10 @@ mlx5_ind_table_ibv_verify(struct rte_eth_dev *dev) * The Verbs object initialised, NULL otherwise and rte_errno is set. */ struct mlx5_hrxq * -mlx5_hrxq_new(struct rte_eth_dev *dev, uint8_t *rss_key, uint8_t rss_key_len, - uint64_t hash_fields, uint16_t queues[], uint16_t queues_n) +mlx5_hrxq_new(struct rte_eth_dev *dev, + const uint8_t *rss_key, uint32_t rss_key_len, + uint64_t hash_fields, + const uint16_t *queues, uint32_t queues_n) { struct priv *priv = dev->data->dev_private; struct mlx5_hrxq *hrxq; @@ -1419,7 +1421,7 @@ mlx5_hrxq_new(struct rte_eth_dev *dev, uint8_t *rss_key, uint8_t rss_key_len, .rx_hash_conf = (struct ibv_rx_hash_conf){ .rx_hash_function = IBV_RX_HASH_FUNC_TOEPLITZ, .rx_hash_key_len = rss_key_len, - .rx_hash_key = rss_key, + .rx_hash_key = (void *)(uintptr_t)rss_key, .rx_hash_fields_mask = hash_fields, }, .rwq_ind_tbl = ind_tbl->ind_table, @@ -1469,8 +1471,10 @@ mlx5_hrxq_new(struct rte_eth_dev *dev, uint8_t *rss_key, uint8_t rss_key_len, * An hash Rx queue on success. */ struct mlx5_hrxq * -mlx5_hrxq_get(struct rte_eth_dev *dev, uint8_t *rss_key, uint8_t rss_key_len, - uint64_t hash_fields, uint16_t queues[], uint16_t queues_n) +mlx5_hrxq_get(struct rte_eth_dev *dev, + const uint8_t *rss_key, uint32_t rss_key_len, + uint64_t hash_fields, + const uint16_t *queues, uint32_t queues_n) { struct priv *priv = dev->data->dev_private; struct mlx5_hrxq *hrxq; diff --git a/drivers/net/mlx5/mlx5_rxtx.h b/drivers/net/mlx5/mlx5_rxtx.h index 2309aa4f3..ee534c340 100644 --- a/drivers/net/mlx5/mlx5_rxtx.h +++ b/drivers/net/mlx5/mlx5_rxtx.h @@ -134,7 +134,7 @@ struct mlx5_ind_table_ibv { LIST_ENTRY(mlx5_ind_table_ibv) next; /* Pointer to the next element. */ rte_atomic32_t refcnt; /* Reference counter. */ struct ibv_rwq_ind_table *ind_table; /**< Indirection table. */ - uint16_t queues_n; /**< Number of queues in the list. */ + uint32_t queues_n; /**< Number of queues in the list. */ uint16_t queues[]; /**< Queue list. */ }; @@ -145,7 +145,7 @@ struct mlx5_hrxq { struct mlx5_ind_table_ibv *ind_table; /* Indirection table. */ struct ibv_qp *qp; /* Verbs queue pair. */ uint64_t hash_fields; /* Verbs Hash fields. */ - uint8_t rss_key_len; /* Hash key length in bytes. */ + uint32_t rss_key_len; /* Hash key length in bytes. */ uint8_t rss_key[]; /* Hash key. */ }; @@ -237,20 +237,22 @@ int mlx5_rxq_releasable(struct rte_eth_dev *dev, uint16_t idx); int mlx5_rxq_verify(struct rte_eth_dev *dev); int rxq_alloc_elts(struct mlx5_rxq_ctrl *rxq_ctrl); struct mlx5_ind_table_ibv *mlx5_ind_table_ibv_new(struct rte_eth_dev *dev, - uint16_t queues[], - uint16_t queues_n); + const uint16_t *queues, + uint32_t queues_n); struct mlx5_ind_table_ibv *mlx5_ind_table_ibv_get(struct rte_eth_dev *dev, - uint16_t queues[], - uint16_t queues_n); + const uint16_t *queues, + uint32_t queues_n); int mlx5_ind_table_ibv_release(struct rte_eth_dev *dev, struct mlx5_ind_table_ibv *ind_tbl); int mlx5_ind_table_ibv_verify(struct rte_eth_dev *dev); -struct mlx5_hrxq *mlx5_hrxq_new(struct rte_eth_dev *dev, uint8_t *rss_key, - uint8_t rss_key_len, uint64_t hash_fields, - uint16_t queues[], uint16_t queues_n); -struct mlx5_hrxq *mlx5_hrxq_get(struct rte_eth_dev *dev, uint8_t *rss_key, - uint8_t rss_key_len, uint64_t hash_fields, - uint16_t queues[], uint16_t queues_n); +struct mlx5_hrxq *mlx5_hrxq_new(struct rte_eth_dev *dev, + const uint8_t *rss_key, uint32_t rss_key_len, + uint64_t hash_fields, + const uint16_t *queues, uint32_t queues_n); +struct mlx5_hrxq *mlx5_hrxq_get(struct rte_eth_dev *dev, + const uint8_t *rss_key, uint32_t rss_key_len, + uint64_t hash_fields, + const uint16_t *queues, uint32_t queues_n); int mlx5_hrxq_release(struct rte_eth_dev *dev, struct mlx5_hrxq *hxrq); int mlx5_hrxq_ibv_verify(struct rte_eth_dev *dev); uint64_t mlx5_get_rx_port_offloads(void); diff --git a/drivers/net/sfc/sfc_flow.c b/drivers/net/sfc/sfc_flow.c index 056405515..1a2c0299c 100644 --- a/drivers/net/sfc/sfc_flow.c +++ b/drivers/net/sfc/sfc_flow.c @@ -1234,13 +1234,11 @@ sfc_flow_parse_rss(struct sfc_adapter *sa, struct sfc_rxq *rxq; unsigned int rxq_hw_index_min; unsigned int rxq_hw_index_max; - const struct rte_eth_rss_conf *rss_conf = rss->rss_conf; - uint64_t rss_hf; - uint8_t *rss_key = NULL; + const uint8_t *rss_key; struct sfc_flow_rss *sfc_rss_conf = &flow->rss_conf; unsigned int i; - if (rss->num == 0) + if (rss->queue_num == 0) return -EINVAL; rxq_sw_index = sa->rxq_count - 1; @@ -1248,7 +1246,7 @@ sfc_flow_parse_rss(struct sfc_adapter *sa, rxq_hw_index_min = rxq->hw_index; rxq_hw_index_max = 0; - for (i = 0; i < rss->num; ++i) { + for (i = 0; i < rss->queue_num; ++i) { rxq_sw_index = rss->queue[i]; if (rxq_sw_index >= sa->rxq_count) @@ -1263,15 +1261,14 @@ sfc_flow_parse_rss(struct sfc_adapter *sa, rxq_hw_index_max = rxq->hw_index; } - rss_hf = (rss_conf != NULL) ? rss_conf->rss_hf : SFC_RSS_OFFLOADS; - if ((rss_hf & ~SFC_RSS_OFFLOADS) != 0) + if ((rss->types & ~SFC_RSS_OFFLOADS) != 0) return -EINVAL; - if (rss_conf != NULL) { - if (rss_conf->rss_key_len != sizeof(sa->rss_key)) + if (rss->key_len) { + if (rss->key_len != sizeof(sa->rss_key)) return -EINVAL; - rss_key = rss_conf->rss_key; + rss_key = rss->key; } else { rss_key = sa->rss_key; } @@ -1280,11 +1277,11 @@ sfc_flow_parse_rss(struct sfc_adapter *sa, sfc_rss_conf->rxq_hw_index_min = rxq_hw_index_min; sfc_rss_conf->rxq_hw_index_max = rxq_hw_index_max; - sfc_rss_conf->rss_hash_types = sfc_rte_to_efx_hash_type(rss_hf); + sfc_rss_conf->rss_hash_types = sfc_rte_to_efx_hash_type(rss->types); rte_memcpy(sfc_rss_conf->rss_key, rss_key, sizeof(sa->rss_key)); for (i = 0; i < RTE_DIM(sfc_rss_conf->rss_tbl); ++i) { - unsigned int rxq_sw_index = rss->queue[i % rss->num]; + unsigned int rxq_sw_index = rss->queue[i % rss->queue_num]; struct sfc_rxq *rxq = sa->rxq_info[rxq_sw_index].rxq; sfc_rss_conf->rss_tbl[i] = rxq->hw_index - rxq_hw_index_min; diff --git a/drivers/net/tap/tap_flow.c b/drivers/net/tap/tap_flow.c index fe2f94010..67146aaba 100644 --- a/drivers/net/tap/tap_flow.c +++ b/drivers/net/tap/tap_flow.c @@ -1215,7 +1215,7 @@ priv_flow_process(struct pmd_internals *pmd, if (err) goto exit_action_not_supported; } - if (flow && rss) + if (flow) err = rss_add_actions(flow, pmd, rss, error); } else { goto exit_action_not_supported; @@ -2050,7 +2050,7 @@ static int rss_add_actions(struct rte_flow *flow, struct pmd_internals *pmd, struct rte_flow_error *error) { /* 4096 is the maximum number of instructions for a BPF program */ - int i; + unsigned int i; int err; struct rss_key rss_entry = { .hash_fields = 0, .key_size = 0 }; @@ -2066,8 +2066,8 @@ static int rss_add_actions(struct rte_flow *flow, struct pmd_internals *pmd, } /* Update RSS map entry with queues */ - rss_entry.nb_queues = rss->num; - for (i = 0; i < rss->num; i++) + rss_entry.nb_queues = rss->queue_num; + for (i = 0; i < rss->queue_num; i++) rss_entry.queues[i] = rss->queue[i]; rss_entry.hash_fields = (1 << HASH_FIELD_IPV4_L3_L4) | (1 << HASH_FIELD_IPV6_L3_L4); diff --git a/examples/ipsec-secgw/ipsec.c b/examples/ipsec-secgw/ipsec.c index 8b2047adb..3ce76c413 100644 --- a/examples/ipsec-secgw/ipsec.c +++ b/examples/ipsec-secgw/ipsec.c @@ -202,9 +202,13 @@ create_session(struct ipsec_ctx *ipsec_ctx, struct ipsec_sa *sa) i < eth_dev->data->nb_rx_queues; ++i) if (eth_dev->data->rx_queues[i]) queue[j++] = i; - action_rss.rss_conf = &rss_conf; - action_rss.num = j; - action_rss.queue = queue; + action_rss = (struct rte_flow_action_rss){ + .types = rss_conf.rss_hf, + .key_len = rss_conf.rss_key_len, + .queue_num = j, + .key = rss_key, + .queue = queue, + }; ret = rte_flow_validate(sa->portid, &sa->attr, sa->pattern, sa->action, &err); diff --git a/lib/librte_ether/rte_flow.c b/lib/librte_ether/rte_flow.c index bb19e28c6..cc7819b6a 100644 --- a/lib/librte_ether/rte_flow.c +++ b/lib/librte_ether/rte_flow.c @@ -330,40 +330,27 @@ flow_action_conf_copy(void *buf, const struct rte_flow_action *action) off = 0; if (dst.rss) *dst.rss = (struct rte_flow_action_rss){ - .num = src.rss->num, + .types = src.rss->types, + .key_len = src.rss->key_len, + .queue_num = src.rss->queue_num, }; off += sizeof(*src.rss); - if (src.rss->num) { + if (src.rss->key_len) { off = RTE_ALIGN_CEIL(off, sizeof(double)); - size = sizeof(*src.rss->queue) * src.rss->num; + size = sizeof(*src.rss->key) * src.rss->key_len; if (dst.rss) - dst.rss->queue = memcpy + dst.rss->key = memcpy ((void *)((uintptr_t)dst.rss + off), - src.rss->queue, size); + src.rss->key, size); off += size; } - off = RTE_ALIGN_CEIL(off, sizeof(double)); - if (dst.rss) { - dst.rss->rss_conf = (void *)((uintptr_t)dst.rss + off); - *(struct rte_eth_rss_conf *)(uintptr_t) - dst.rss->rss_conf = (struct rte_eth_rss_conf){ - .rss_key_len = src.rss->rss_conf->rss_key_len, - .rss_hf = src.rss->rss_conf->rss_hf, - }; - } - off += sizeof(*src.rss->rss_conf); - if (src.rss->rss_conf->rss_key_len) { + if (src.rss->queue_num) { off = RTE_ALIGN_CEIL(off, sizeof(double)); - size = sizeof(*src.rss->rss_conf->rss_key) * - src.rss->rss_conf->rss_key_len; - if (dst.rss) { - ((struct rte_eth_rss_conf *)(uintptr_t) - dst.rss->rss_conf)->rss_key = - (void *)((uintptr_t)dst.rss + off); - memcpy(dst.rss->rss_conf->rss_key, - src.rss->rss_conf->rss_key, - size); - } + size = sizeof(*src.rss->queue) * src.rss->queue_num; + if (dst.rss) + dst.rss->queue = memcpy + ((void *)((uintptr_t)dst.rss + off), + src.rss->queue, size); off += size; } size = off; diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index ad2e55b8e..bbc408fa6 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -1033,13 +1033,21 @@ struct rte_flow_query_count { * Similar to QUEUE, except RSS is additionally performed on packets to * spread them among several queues according to the provided parameters. * + * Unlike global RSS settings used by other DPDK APIs, unsetting the + * @p types field does not disable RSS in a flow rule. Doing so instead + * requests safe unspecified "best-effort" settings from the underlying PMD, + * which depending on the flow rule, may result in anything ranging from + * empty (single queue) to all-inclusive RSS. + * * Note: RSS hash result is stored in the hash.rss mbuf field which overlaps * hash.fdir.lo. Since the MARK action sets the hash.fdir.hi field only, * both can be requested simultaneously. */ struct rte_flow_action_rss { - const struct rte_eth_rss_conf *rss_conf; /**< RSS parameters. */ - uint16_t num; /**< Number of entries in @p queue. */ + uint64_t types; /**< Specific RSS hash types (see ETH_RSS_*). */ + uint32_t key_len; /**< Hash key length in bytes. */ + uint32_t queue_num; /**< Number of entries in @p queue. */ + const uint8_t *key; /**< Hash key. */ const uint16_t *queue; /**< Queue indices to use. */ }; -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v4 08/16] ethdev: add hash function to RSS flow API action 2018-04-16 16:22 ` [dpdk-dev] [PATCH v4 00/16] Flow API overhaul for switch offloads Adrien Mazarguil ` (6 preceding siblings ...) 2018-04-16 16:22 ` [dpdk-dev] [PATCH v4 07/16] ethdev: flatten RSS configuration in " Adrien Mazarguil @ 2018-04-16 16:22 ` Adrien Mazarguil 2018-04-16 16:22 ` [dpdk-dev] [PATCH v4 09/16] ethdev: add encap level " Adrien Mazarguil ` (8 subsequent siblings) 16 siblings, 0 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-16 16:22 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev Cc: Wenzhuo Lu, Jingjing Wu, Beilei Xing, Qi Zhang, Konstantin Ananyev, Nelio Laranjeiro, Yongseok Koh, Andrew Rybchenko, Pascal Mazon By definition, RSS involves some kind of hash algorithm, usually Toeplitz. Until now it could not be modified on a flow rule basis and PMDs had to always assume RTE_ETH_HASH_FUNCTION_DEFAULT, which remains the default behavior when unspecified (0). This breaks ABI compatibility for the following public functions: - rte_flow_copy() - rte_flow_create() - rte_flow_query() - rte_flow_validate() Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Acked-by: Andrew Rybchenko <arybchenko@solarflare.com> Cc: Ferruh Yigit <ferruh.yigit@intel.com> Cc: Thomas Monjalon <thomas@monjalon.net> Cc: Wenzhuo Lu <wenzhuo.lu@intel.com> Cc: Jingjing Wu <jingjing.wu@intel.com> Cc: Beilei Xing <beilei.xing@intel.com> Cc: Qi Zhang <qi.z.zhang@intel.com> Cc: Konstantin Ananyev <konstantin.ananyev@intel.com> Cc: Nelio Laranjeiro <nelio.laranjeiro@6wind.com> Cc: Yongseok Koh <yskoh@mellanox.com> Cc: Andrew Rybchenko <arybchenko@solarflare.com> Cc: Pascal Mazon <pascal.mazon@6wind.com> --- v3 changes: - Although RTE_ETH_HASH_FUNCTION_DEFAULT is defined as 0, made comparisons more explicit where doing so would clarify the code. - Updated sfc to include Toeplitz as the other allowed value. Both according to Andrew's suggestions [1]. [1] http://dpdk.org/ml/archives/dev/2018-April/095840.html --- app/test-pmd/cmdline_flow.c | 72 ++++++++++++++++++++++++ app/test-pmd/config.c | 1 + doc/guides/prog_guide/rte_flow.rst | 2 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 3 + drivers/net/e1000/igb_flow.c | 4 ++ drivers/net/e1000/igb_rxtx.c | 4 +- drivers/net/i40e/i40e_ethdev.c | 4 +- drivers/net/i40e/i40e_flow.c | 4 ++ drivers/net/ixgbe/ixgbe_flow.c | 4 ++ drivers/net/ixgbe/ixgbe_rxtx.c | 4 +- drivers/net/mlx4/mlx4_flow.c | 7 +++ drivers/net/mlx5/mlx5_flow.c | 13 +++++ drivers/net/sfc/sfc_flow.c | 8 +++ drivers/net/tap/tap_flow.c | 6 ++ lib/librte_ether/rte_flow.c | 1 + lib/librte_ether/rte_flow.h | 2 + 16 files changed, 136 insertions(+), 3 deletions(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index c9c2c3ad9..7436e0356 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -14,6 +14,7 @@ #include <sys/socket.h> #include <rte_common.h> +#include <rte_eth_ctrl.h> #include <rte_ethdev.h> #include <rte_byteorder.h> #include <cmdline_parse.h> @@ -165,6 +166,10 @@ enum index { ACTION_DROP, ACTION_COUNT, ACTION_RSS, + ACTION_RSS_FUNC, + ACTION_RSS_FUNC_DEFAULT, + ACTION_RSS_FUNC_TOEPLITZ, + ACTION_RSS_FUNC_SIMPLE_XOR, ACTION_RSS_TYPES, ACTION_RSS_TYPE, ACTION_RSS_KEY, @@ -632,6 +637,7 @@ static const enum index action_queue[] = { }; static const enum index action_rss[] = { + ACTION_RSS_FUNC, ACTION_RSS_TYPES, ACTION_RSS_KEY, ACTION_RSS_KEY_LEN, @@ -666,6 +672,9 @@ static int parse_vc_conf(struct context *, const struct token *, static int parse_vc_action_rss(struct context *, const struct token *, const char *, unsigned int, void *, unsigned int); +static int parse_vc_action_rss_func(struct context *, const struct token *, + const char *, unsigned int, void *, + unsigned int); static int parse_vc_action_rss_type(struct context *, const struct token *, const char *, unsigned int, void *, unsigned int); @@ -1584,6 +1593,29 @@ static const struct token token_list[] = { .next = NEXT(action_rss), .call = parse_vc_action_rss, }, + [ACTION_RSS_FUNC] = { + .name = "func", + .help = "RSS hash function to apply", + .next = NEXT(action_rss, + NEXT_ENTRY(ACTION_RSS_FUNC_DEFAULT, + ACTION_RSS_FUNC_TOEPLITZ, + ACTION_RSS_FUNC_SIMPLE_XOR)), + }, + [ACTION_RSS_FUNC_DEFAULT] = { + .name = "default", + .help = "default hash function", + .call = parse_vc_action_rss_func, + }, + [ACTION_RSS_FUNC_TOEPLITZ] = { + .name = "toeplitz", + .help = "Toeplitz hash function", + .call = parse_vc_action_rss_func, + }, + [ACTION_RSS_FUNC_SIMPLE_XOR] = { + .name = "simple_xor", + .help = "simple XOR hash function", + .call = parse_vc_action_rss_func, + }, [ACTION_RSS_TYPES] = { .name = "types", .help = "specific RSS hash types", @@ -2074,6 +2106,7 @@ parse_vc_action_rss(struct context *ctx, const struct token *token, action_rss_data = ctx->object; *action_rss_data = (struct action_rss_data){ .conf = (struct rte_flow_action_rss){ + .func = RTE_ETH_HASH_FUNCTION_DEFAULT, .types = rss_hf, .key_len = sizeof(action_rss_data->key), .queue_num = RTE_MIN(nb_rxq, ACTION_RSS_QUEUE_NUM), @@ -2099,6 +2132,45 @@ parse_vc_action_rss(struct context *ctx, const struct token *token, } /** + * Parse func field for RSS action. + * + * The RTE_ETH_HASH_FUNCTION_* value to assign is derived from the + * ACTION_RSS_FUNC_* index that called this function. + */ +static int +parse_vc_action_rss_func(struct context *ctx, const struct token *token, + const char *str, unsigned int len, + void *buf, unsigned int size) +{ + struct action_rss_data *action_rss_data; + enum rte_eth_hash_function func; + + (void)buf; + (void)size; + /* Token name must match. */ + if (parse_default(ctx, token, str, len, NULL, 0) < 0) + return -1; + switch (ctx->curr) { + case ACTION_RSS_FUNC_DEFAULT: + func = RTE_ETH_HASH_FUNCTION_DEFAULT; + break; + case ACTION_RSS_FUNC_TOEPLITZ: + func = RTE_ETH_HASH_FUNCTION_TOEPLITZ; + break; + case ACTION_RSS_FUNC_SIMPLE_XOR: + func = RTE_ETH_HASH_FUNCTION_SIMPLE_XOR; + break; + default: + return -1; + } + if (!ctx->object) + return len; + action_rss_data = ctx->object; + action_rss_data->conf.func = func; + return len; +} + +/** * Parse type field for RSS action. * * Valid tokens are type field names and the "end" token. diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 3da09536a..19e27a6ca 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -1100,6 +1100,7 @@ flow_action_conf_copy(void *buf, const struct rte_flow_action *action) off = 0; if (dst.rss) *dst.rss = (struct rte_flow_action_rss){ + .func = src.rss->func, .types = src.rss->types, .key_len = src.rss->key_len, .queue_num = src.rss->queue_num, diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index cf252eeba..e0c68495c 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -1318,6 +1318,8 @@ field only, both can be requested simultaneously. +---------------+---------------------------------------------+ | Field | Value | +===============+=============================================+ + | ``func`` | RSS hash function to apply | + +---------------+---------------------------------------------+ | ``types`` | specific RSS hash types (see ``ETH_RSS_*``) | +---------------+---------------------------------------------+ | ``key_len`` | hash key length in bytes | diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index 17336d163..546ef3ab7 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3398,6 +3398,9 @@ This section lists supported actions and their attributes, if any. - ``rss``: spread packets among several queues. + - ``func {hash function}``: RSS hash function to apply, allowed tokens are + the same as `set_hash_global_config`_. + - ``types [{RSS hash type} [...]] end``: specific RSS hash types, allowed tokens are the same as `set_hash_input_set`_, except that an empty list does not disable RSS but instead requests unspecified "best-effort" diff --git a/drivers/net/e1000/igb_flow.c b/drivers/net/e1000/igb_flow.c index 8dc5f75f2..82307ec5d 100644 --- a/drivers/net/e1000/igb_flow.c +++ b/drivers/net/e1000/igb_flow.c @@ -1310,6 +1310,10 @@ igb_parse_rss_filter(struct rte_eth_dev *dev, } } + if (rss->func != RTE_ETH_HASH_FUNCTION_DEFAULT) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, + "non-default RSS hash functions are not supported"); if (rss->key_len && rss->key_len != RTE_DIM(rss_conf->key)) return rte_flow_error_set (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, diff --git a/drivers/net/e1000/igb_rxtx.c b/drivers/net/e1000/igb_rxtx.c index 45bb3455c..d5c1cd3d3 100644 --- a/drivers/net/e1000/igb_rxtx.c +++ b/drivers/net/e1000/igb_rxtx.c @@ -2905,6 +2905,7 @@ igb_rss_conf_init(struct igb_rte_flow_rss_conf *out, in->queue_num > RTE_DIM(out->queue)) return -EINVAL; out->conf = (struct rte_flow_action_rss){ + .func = in->func, .types = in->types, .key_len = in->key_len, .queue_num = in->queue_num, @@ -2919,7 +2920,8 @@ int igb_action_rss_same(const struct rte_flow_action_rss *comp, const struct rte_flow_action_rss *with) { - return (comp->types == with->types && + return (comp->func == with->func && + comp->types == with->types && comp->key_len == with->key_len && comp->queue_num == with->queue_num && !memcmp(comp->key, with->key, with->key_len) && diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index e65235fc3..5cb852f2c 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c @@ -12039,6 +12039,7 @@ i40e_rss_conf_init(struct i40e_rte_flow_rss_conf *out, in->queue_num > RTE_DIM(out->queue)) return -EINVAL; out->conf = (struct rte_flow_action_rss){ + .func = in->func, .types = in->types, .key_len = in->key_len, .queue_num = in->queue_num, @@ -12053,7 +12054,8 @@ int i40e_action_rss_same(const struct rte_flow_action_rss *comp, const struct rte_flow_action_rss *with) { - return (comp->types == with->types && + return (comp->func == with->func && + comp->types == with->types && comp->key_len == with->key_len && comp->queue_num == with->queue_num && !memcmp(comp->key, with->key, with->key_len) && diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c index ec6231003..897989bbd 100644 --- a/drivers/net/i40e/i40e_flow.c +++ b/drivers/net/i40e/i40e_flow.c @@ -4376,6 +4376,10 @@ i40e_flow_parse_rss_action(struct rte_eth_dev *dev, } /* Parse RSS related parameters from configuration */ + if (rss->func != RTE_ETH_HASH_FUNCTION_DEFAULT) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, + "non-default RSS hash functions are not supported"); if (rss->key_len && rss->key_len > RTE_DIM(rss_config->key)) return rte_flow_error_set (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, diff --git a/drivers/net/ixgbe/ixgbe_flow.c b/drivers/net/ixgbe/ixgbe_flow.c index 4e31c7c56..00d975b93 100644 --- a/drivers/net/ixgbe/ixgbe_flow.c +++ b/drivers/net/ixgbe/ixgbe_flow.c @@ -2779,6 +2779,10 @@ ixgbe_parse_rss_filter(struct rte_eth_dev *dev, } } + if (rss->func != RTE_ETH_HASH_FUNCTION_DEFAULT) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, + "non-default RSS hash functions are not supported"); if (rss->key_len && rss->key_len != RTE_DIM(rss_conf->key)) return rte_flow_error_set (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, diff --git a/drivers/net/ixgbe/ixgbe_rxtx.c b/drivers/net/ixgbe/ixgbe_rxtx.c index 94ea7444d..e17f5a433 100644 --- a/drivers/net/ixgbe/ixgbe_rxtx.c +++ b/drivers/net/ixgbe/ixgbe_rxtx.c @@ -5682,6 +5682,7 @@ ixgbe_rss_conf_init(struct ixgbe_rte_flow_rss_conf *out, in->queue_num > RTE_DIM(out->queue)) return -EINVAL; out->conf = (struct rte_flow_action_rss){ + .func = in->func, .types = in->types, .key_len = in->key_len, .queue_num = in->queue_num, @@ -5696,7 +5697,8 @@ int ixgbe_action_rss_same(const struct rte_flow_action_rss *comp, const struct rte_flow_action_rss *with) { - return (comp->types == with->types && + return (comp->func == with->func && + comp->types == with->types && comp->key_len == with->key_len && comp->queue_num == with->queue_num && !memcmp(comp->key, with->key, with->key_len) && diff --git a/drivers/net/mlx4/mlx4_flow.c b/drivers/net/mlx4/mlx4_flow.c index dd86e4ce7..002003235 100644 --- a/drivers/net/mlx4/mlx4_flow.c +++ b/drivers/net/mlx4/mlx4_flow.c @@ -790,6 +790,12 @@ mlx4_flow_prepare(struct priv *priv, " of the context size"; goto exit_action_not_supported; } + if (rss->func && + rss->func != RTE_ETH_HASH_FUNCTION_TOEPLITZ) { + msg = "the only supported RSS hash function" + " is Toeplitz"; + goto exit_action_not_supported; + } rte_errno = 0; fields = mlx4_conv_rss_types(priv, rss->types); if (fields == (uint64_t)-1 && rte_errno) { @@ -1283,6 +1289,7 @@ mlx4_flow_internal(struct priv *priv, struct rte_flow_error *error) rte_align32pow2(priv->dev->data->nb_rx_queues + 1) >> 1; uint16_t queue[queues]; struct rte_flow_action_rss action_rss = { + .func = RTE_ETH_HASH_FUNCTION_DEFAULT, .types = -1, .key_len = MLX4_RSS_HASH_KEY_SIZE, .queue_num = queues, diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 86870b0cb..c86703f4c 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -18,6 +18,7 @@ #endif #include <rte_common.h> +#include <rte_eth_ctrl.h> #include <rte_ethdev_driver.h> #include <rte_flow.h> #include <rte_flow_driver.h> @@ -634,6 +635,15 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, if (overlap & FATE) goto exit_action_overlap; overlap |= FATE; + if (rss->func && + rss->func != RTE_ETH_HASH_FUNCTION_TOEPLITZ) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION, + actions, + "the only supported RSS hash" + " function is Toeplitz"); + return -rte_errno; + } if (rss->types & MLX5_RSS_HF_MASK) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, @@ -683,6 +693,7 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, } } parser->rss_conf = (struct rte_flow_action_rss){ + .func = RTE_ETH_HASH_FUNCTION_DEFAULT, .types = rss->types, .key_len = rss_key_len, .queue_num = rss->queue_num, @@ -1915,6 +1926,7 @@ mlx5_flow_list_create(struct rte_eth_dev *dev, /* Copy configuration. */ flow->queues = (uint16_t (*)[])(flow + 1); flow->rss_conf = (struct rte_flow_action_rss){ + .func = RTE_ETH_HASH_FUNCTION_DEFAULT, .types = parser.rss_conf.types, .key_len = parser.rss_conf.key_len, .queue_num = parser.rss_conf.queue_num, @@ -2429,6 +2441,7 @@ mlx5_ctrl_flow_vlan(struct rte_eth_dev *dev, }; uint16_t queue[priv->reta_idx_n]; struct rte_flow_action_rss action_rss = { + .func = RTE_ETH_HASH_FUNCTION_DEFAULT, .types = priv->rss_conf.rss_hf, .key_len = priv->rss_conf.rss_key_len, .queue_num = priv->reta_idx_n, diff --git a/drivers/net/sfc/sfc_flow.c b/drivers/net/sfc/sfc_flow.c index 1a2c0299c..779edad0c 100644 --- a/drivers/net/sfc/sfc_flow.c +++ b/drivers/net/sfc/sfc_flow.c @@ -1261,6 +1261,14 @@ sfc_flow_parse_rss(struct sfc_adapter *sa, rxq_hw_index_max = rxq->hw_index; } + switch (rss->func) { + case RTE_ETH_HASH_FUNCTION_DEFAULT: + case RTE_ETH_HASH_FUNCTION_TOEPLITZ: + break; + default: + return -EINVAL; + } + if ((rss->types & ~SFC_RSS_OFFLOADS) != 0) return -EINVAL; diff --git a/drivers/net/tap/tap_flow.c b/drivers/net/tap/tap_flow.c index 67146aaba..845031a31 100644 --- a/drivers/net/tap/tap_flow.c +++ b/drivers/net/tap/tap_flow.c @@ -2055,6 +2055,12 @@ static int rss_add_actions(struct rte_flow *flow, struct pmd_internals *pmd, struct rss_key rss_entry = { .hash_fields = 0, .key_size = 0 }; + /* Check supported hash functions */ + if (rss->func != RTE_ETH_HASH_FUNCTION_DEFAULT) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, + "non-default RSS hash functions are not supported"); + /* Get a new map key for a new RSS rule */ err = bpf_rss_key(KEY_CMD_GET, &flow->key_idx); if (err < 0) { diff --git a/lib/librte_ether/rte_flow.c b/lib/librte_ether/rte_flow.c index cc7819b6a..a2b51f1e0 100644 --- a/lib/librte_ether/rte_flow.c +++ b/lib/librte_ether/rte_flow.c @@ -330,6 +330,7 @@ flow_action_conf_copy(void *buf, const struct rte_flow_action *action) off = 0; if (dst.rss) *dst.rss = (struct rte_flow_action_rss){ + .func = src.rss->func, .types = src.rss->types, .key_len = src.rss->key_len, .queue_num = src.rss->queue_num, diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index bbc408fa6..97d7d3594 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -19,6 +19,7 @@ #include <rte_arp.h> #include <rte_ether.h> +#include <rte_eth_ctrl.h> #include <rte_icmp.h> #include <rte_ip.h> #include <rte_sctp.h> @@ -1044,6 +1045,7 @@ struct rte_flow_query_count { * both can be requested simultaneously. */ struct rte_flow_action_rss { + enum rte_eth_hash_function func; /**< RSS hash function to apply. */ uint64_t types; /**< Specific RSS hash types (see ETH_RSS_*). */ uint32_t key_len; /**< Hash key length in bytes. */ uint32_t queue_num; /**< Number of entries in @p queue. */ -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v4 09/16] ethdev: add encap level to RSS flow API action 2018-04-16 16:22 ` [dpdk-dev] [PATCH v4 00/16] Flow API overhaul for switch offloads Adrien Mazarguil ` (7 preceding siblings ...) 2018-04-16 16:22 ` [dpdk-dev] [PATCH v4 08/16] ethdev: add hash function to RSS flow API action Adrien Mazarguil @ 2018-04-16 16:22 ` Adrien Mazarguil 2018-04-16 16:22 ` [dpdk-dev] [PATCH v4 10/16] ethdev: refine TPID handling in flow API Adrien Mazarguil ` (7 subsequent siblings) 16 siblings, 0 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-16 16:22 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev Cc: Xueming Li, Wenzhuo Lu, Jingjing Wu, Beilei Xing, Qi Zhang, Konstantin Ananyev, Nelio Laranjeiro, Yongseok Koh, Andrew Rybchenko, Pascal Mazon RSS hash types (ETH_RSS_* macros defined in rte_ethdev.h) describe the protocol header fields of a packet that must be taken into account while computing RSS. When facing encapsulated (e.g. tunneled) packets, there is an ambiguity as to whether these should apply to inner or outer packets. Applications need the ability to tell exactly "where" RSS must be performed. This is addressed by adding encapsulation level information to the RSS flow action. Its default value is 0 and stands for the usual unspecified behavior. Other values provide a specific encapsulation level. Contrary to the change announced by commit 676b605182a5 ("doc: announce ethdev API change for RSS configuration"), this patch does not affect struct rte_eth_rss_conf but struct rte_flow_action_rss as the former is not used anymore by the RSS flow action. ABI impact is therefore limited to rte_flow. This breaks ABI compatibility for the following public functions: - rte_flow_copy() - rte_flow_create() - rte_flow_query() - rte_flow_validate() Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Acked-by: Andrew Rybchenko <arybchenko@solarflare.com> Cc: Xueming Li <xuemingl@mellanox.com> Cc: Ferruh Yigit <ferruh.yigit@intel.com> Cc: Thomas Monjalon <thomas@monjalon.net> Cc: Wenzhuo Lu <wenzhuo.lu@intel.com> Cc: Jingjing Wu <jingjing.wu@intel.com> Cc: Beilei Xing <beilei.xing@intel.com> Cc: Qi Zhang <qi.z.zhang@intel.com> Cc: Konstantin Ananyev <konstantin.ananyev@intel.com> Cc: Nelio Laranjeiro <nelio.laranjeiro@6wind.com> Cc: Yongseok Koh <yskoh@mellanox.com> Cc: Andrew Rybchenko <arybchenko@solarflare.com> Cc: Pascal Mazon <pascal.mazon@6wind.com> --- app/test-pmd/cmdline_flow.c | 13 ++++++++++++ app/test-pmd/config.c | 1 + doc/guides/prog_guide/rte_flow.rst | 24 ++++++++++++++++++++++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 2 ++ drivers/net/e1000/igb_flow.c | 4 ++++ drivers/net/e1000/igb_rxtx.c | 2 ++ drivers/net/i40e/i40e_ethdev.c | 2 ++ drivers/net/i40e/i40e_flow.c | 4 ++++ drivers/net/ixgbe/ixgbe_flow.c | 4 ++++ drivers/net/ixgbe/ixgbe_rxtx.c | 2 ++ drivers/net/mlx4/mlx4_flow.c | 6 ++++++ drivers/net/mlx5/mlx5_flow.c | 11 ++++++++++ drivers/net/sfc/sfc_flow.c | 3 +++ drivers/net/tap/tap_flow.c | 6 +++++- lib/librte_ether/rte_flow.c | 1 + lib/librte_ether/rte_flow.h | 26 ++++++++++++++++++++++++ 16 files changed, 110 insertions(+), 1 deletion(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 7436e0356..976fde7cd 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -167,6 +167,7 @@ enum index { ACTION_COUNT, ACTION_RSS, ACTION_RSS_FUNC, + ACTION_RSS_LEVEL, ACTION_RSS_FUNC_DEFAULT, ACTION_RSS_FUNC_TOEPLITZ, ACTION_RSS_FUNC_SIMPLE_XOR, @@ -638,6 +639,7 @@ static const enum index action_queue[] = { static const enum index action_rss[] = { ACTION_RSS_FUNC, + ACTION_RSS_LEVEL, ACTION_RSS_TYPES, ACTION_RSS_KEY, ACTION_RSS_KEY_LEN, @@ -1616,6 +1618,16 @@ static const struct token token_list[] = { .help = "simple XOR hash function", .call = parse_vc_action_rss_func, }, + [ACTION_RSS_LEVEL] = { + .name = "level", + .help = "encapsulation level for \"types\"", + .next = NEXT(action_rss, NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY_ARB + (offsetof(struct action_rss_data, conf) + + offsetof(struct rte_flow_action_rss, level), + sizeof(((struct rte_flow_action_rss *)0)-> + level))), + }, [ACTION_RSS_TYPES] = { .name = "types", .help = "specific RSS hash types", @@ -2107,6 +2119,7 @@ parse_vc_action_rss(struct context *ctx, const struct token *token, *action_rss_data = (struct action_rss_data){ .conf = (struct rte_flow_action_rss){ .func = RTE_ETH_HASH_FUNCTION_DEFAULT, + .level = 0, .types = rss_hf, .key_len = sizeof(action_rss_data->key), .queue_num = RTE_MIN(nb_rxq, ACTION_RSS_QUEUE_NUM), diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 19e27a6ca..562fb2f8d 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -1101,6 +1101,7 @@ flow_action_conf_copy(void *buf, const struct rte_flow_action *action) if (dst.rss) *dst.rss = (struct rte_flow_action_rss){ .func = src.rss->func, + .level = src.rss->level, .types = src.rss->types, .key_len = src.rss->key_len, .queue_num = src.rss->queue_num, diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index e0c68495c..1a09e8a0f 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -1311,6 +1311,28 @@ Note: RSS hash result is stored in the ``hash.rss`` mbuf field which overlaps ``hash.fdir.lo``. Since `Action: MARK`_ sets the ``hash.fdir.hi`` field only, both can be requested simultaneously. +Also, regarding packet encapsulation ``level``: + +- ``0`` requests the default behavior. Depending on the packet type, it can + mean outermost, innermost, anything in between or even no RSS. + + It basically stands for the innermost encapsulation level RSS can be + performed on according to PMD and device capabilities. + +- ``1`` requests RSS to be performed on the outermost packet encapsulation + level. + +- ``2`` and subsequent values request RSS to be performed on the specified + inner packet encapsulation level, from outermost to innermost (lower to + higher values). + +Values other than ``0`` are not necessarily supported. + +Requesting a specific RSS level on unrecognized traffic results in undefined +behavior. For predictable results, it is recommended to make the flow rule +pattern match packet headers up to the requested encapsulation level so that +only matching traffic goes through. + .. _table_rte_flow_action_rss: .. table:: RSS @@ -1320,6 +1342,8 @@ field only, both can be requested simultaneously. +===============+=============================================+ | ``func`` | RSS hash function to apply | +---------------+---------------------------------------------+ + | ``level`` | encapsulation level for ``types`` | + +---------------+---------------------------------------------+ | ``types`` | specific RSS hash types (see ``ETH_RSS_*``) | +---------------+---------------------------------------------+ | ``key_len`` | hash key length in bytes | diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index 546ef3ab7..3b1073bfc 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3401,6 +3401,8 @@ This section lists supported actions and their attributes, if any. - ``func {hash function}``: RSS hash function to apply, allowed tokens are the same as `set_hash_global_config`_. + - ``level {unsigned}``: encapsulation level for ``types``. + - ``types [{RSS hash type} [...]] end``: specific RSS hash types, allowed tokens are the same as `set_hash_input_set`_, except that an empty list does not disable RSS but instead requests unspecified "best-effort" diff --git a/drivers/net/e1000/igb_flow.c b/drivers/net/e1000/igb_flow.c index 82307ec5d..d1c0b4b8d 100644 --- a/drivers/net/e1000/igb_flow.c +++ b/drivers/net/e1000/igb_flow.c @@ -1314,6 +1314,10 @@ igb_parse_rss_filter(struct rte_eth_dev *dev, return rte_flow_error_set (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, "non-default RSS hash functions are not supported"); + if (rss->level) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, + "a nonzero RSS encapsulation level is not supported"); if (rss->key_len && rss->key_len != RTE_DIM(rss_conf->key)) return rte_flow_error_set (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, diff --git a/drivers/net/e1000/igb_rxtx.c b/drivers/net/e1000/igb_rxtx.c index d5c1cd3d3..a3776a0d7 100644 --- a/drivers/net/e1000/igb_rxtx.c +++ b/drivers/net/e1000/igb_rxtx.c @@ -2906,6 +2906,7 @@ igb_rss_conf_init(struct igb_rte_flow_rss_conf *out, return -EINVAL; out->conf = (struct rte_flow_action_rss){ .func = in->func, + .level = in->level, .types = in->types, .key_len = in->key_len, .queue_num = in->queue_num, @@ -2921,6 +2922,7 @@ igb_action_rss_same(const struct rte_flow_action_rss *comp, const struct rte_flow_action_rss *with) { return (comp->func == with->func && + comp->level == with->level && comp->types == with->types && comp->key_len == with->key_len && comp->queue_num == with->queue_num && diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index 5cb852f2c..42002422b 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c @@ -12040,6 +12040,7 @@ i40e_rss_conf_init(struct i40e_rte_flow_rss_conf *out, return -EINVAL; out->conf = (struct rte_flow_action_rss){ .func = in->func, + .level = in->level, .types = in->types, .key_len = in->key_len, .queue_num = in->queue_num, @@ -12055,6 +12056,7 @@ i40e_action_rss_same(const struct rte_flow_action_rss *comp, const struct rte_flow_action_rss *with) { return (comp->func == with->func && + comp->level == with->level && comp->types == with->types && comp->key_len == with->key_len && comp->queue_num == with->queue_num && diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c index 897989bbd..db668835d 100644 --- a/drivers/net/i40e/i40e_flow.c +++ b/drivers/net/i40e/i40e_flow.c @@ -4380,6 +4380,10 @@ i40e_flow_parse_rss_action(struct rte_eth_dev *dev, return rte_flow_error_set (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, "non-default RSS hash functions are not supported"); + if (rss->level) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, + "a nonzero RSS encapsulation level is not supported"); if (rss->key_len && rss->key_len > RTE_DIM(rss_config->key)) return rte_flow_error_set (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, diff --git a/drivers/net/ixgbe/ixgbe_flow.c b/drivers/net/ixgbe/ixgbe_flow.c index 00d975b93..438bfcdfb 100644 --- a/drivers/net/ixgbe/ixgbe_flow.c +++ b/drivers/net/ixgbe/ixgbe_flow.c @@ -2783,6 +2783,10 @@ ixgbe_parse_rss_filter(struct rte_eth_dev *dev, return rte_flow_error_set (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, "non-default RSS hash functions are not supported"); + if (rss->level) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, + "a nonzero RSS encapsulation level is not supported"); if (rss->key_len && rss->key_len != RTE_DIM(rss_conf->key)) return rte_flow_error_set (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, diff --git a/drivers/net/ixgbe/ixgbe_rxtx.c b/drivers/net/ixgbe/ixgbe_rxtx.c index e17f5a433..23af21712 100644 --- a/drivers/net/ixgbe/ixgbe_rxtx.c +++ b/drivers/net/ixgbe/ixgbe_rxtx.c @@ -5683,6 +5683,7 @@ ixgbe_rss_conf_init(struct ixgbe_rte_flow_rss_conf *out, return -EINVAL; out->conf = (struct rte_flow_action_rss){ .func = in->func, + .level = in->level, .types = in->types, .key_len = in->key_len, .queue_num = in->queue_num, @@ -5698,6 +5699,7 @@ ixgbe_action_rss_same(const struct rte_flow_action_rss *comp, const struct rte_flow_action_rss *with) { return (comp->func == with->func && + comp->level == with->level && comp->types == with->types && comp->key_len == with->key_len && comp->queue_num == with->queue_num && diff --git a/drivers/net/mlx4/mlx4_flow.c b/drivers/net/mlx4/mlx4_flow.c index 002003235..ce36ac715 100644 --- a/drivers/net/mlx4/mlx4_flow.c +++ b/drivers/net/mlx4/mlx4_flow.c @@ -796,6 +796,11 @@ mlx4_flow_prepare(struct priv *priv, " is Toeplitz"; goto exit_action_not_supported; } + if (rss->level) { + msg = "a nonzero RSS encapsulation level is" + " not supported"; + goto exit_action_not_supported; + } rte_errno = 0; fields = mlx4_conv_rss_types(priv, rss->types); if (fields == (uint64_t)-1 && rte_errno) { @@ -1290,6 +1295,7 @@ mlx4_flow_internal(struct priv *priv, struct rte_flow_error *error) uint16_t queue[queues]; struct rte_flow_action_rss action_rss = { .func = RTE_ETH_HASH_FUNCTION_DEFAULT, + .level = 0, .types = -1, .key_len = MLX4_RSS_HASH_KEY_SIZE, .queue_num = queues, diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index c86703f4c..76a1053ec 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -644,6 +644,14 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, " function is Toeplitz"); return -rte_errno; } + if (rss->level) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION, + actions, + "a nonzero RSS encapsulation" + " level is not supported"); + return -rte_errno; + } if (rss->types & MLX5_RSS_HF_MASK) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, @@ -694,6 +702,7 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, } parser->rss_conf = (struct rte_flow_action_rss){ .func = RTE_ETH_HASH_FUNCTION_DEFAULT, + .level = 0, .types = rss->types, .key_len = rss_key_len, .queue_num = rss->queue_num, @@ -1927,6 +1936,7 @@ mlx5_flow_list_create(struct rte_eth_dev *dev, flow->queues = (uint16_t (*)[])(flow + 1); flow->rss_conf = (struct rte_flow_action_rss){ .func = RTE_ETH_HASH_FUNCTION_DEFAULT, + .level = 0, .types = parser.rss_conf.types, .key_len = parser.rss_conf.key_len, .queue_num = parser.rss_conf.queue_num, @@ -2442,6 +2452,7 @@ mlx5_ctrl_flow_vlan(struct rte_eth_dev *dev, uint16_t queue[priv->reta_idx_n]; struct rte_flow_action_rss action_rss = { .func = RTE_ETH_HASH_FUNCTION_DEFAULT, + .level = 0, .types = priv->rss_conf.rss_hf, .key_len = priv->rss_conf.rss_key_len, .queue_num = priv->reta_idx_n, diff --git a/drivers/net/sfc/sfc_flow.c b/drivers/net/sfc/sfc_flow.c index 779edad0c..3028efbf9 100644 --- a/drivers/net/sfc/sfc_flow.c +++ b/drivers/net/sfc/sfc_flow.c @@ -1269,6 +1269,9 @@ sfc_flow_parse_rss(struct sfc_adapter *sa, return -EINVAL; } + if (rss->level) + return -EINVAL; + if ((rss->types & ~SFC_RSS_OFFLOADS) != 0) return -EINVAL; diff --git a/drivers/net/tap/tap_flow.c b/drivers/net/tap/tap_flow.c index 845031a31..7dfaf9ac5 100644 --- a/drivers/net/tap/tap_flow.c +++ b/drivers/net/tap/tap_flow.c @@ -2055,11 +2055,15 @@ static int rss_add_actions(struct rte_flow *flow, struct pmd_internals *pmd, struct rss_key rss_entry = { .hash_fields = 0, .key_size = 0 }; - /* Check supported hash functions */ + /* Check supported RSS features */ if (rss->func != RTE_ETH_HASH_FUNCTION_DEFAULT) return rte_flow_error_set (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, "non-default RSS hash functions are not supported"); + if (rss->level) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, + "a nonzero RSS encapsulation level is not supported"); /* Get a new map key for a new RSS rule */ err = bpf_rss_key(KEY_CMD_GET, &flow->key_idx); diff --git a/lib/librte_ether/rte_flow.c b/lib/librte_ether/rte_flow.c index a2b51f1e0..83b733ff0 100644 --- a/lib/librte_ether/rte_flow.c +++ b/lib/librte_ether/rte_flow.c @@ -331,6 +331,7 @@ flow_action_conf_copy(void *buf, const struct rte_flow_action *action) if (dst.rss) *dst.rss = (struct rte_flow_action_rss){ .func = src.rss->func, + .level = src.rss->level, .types = src.rss->types, .key_len = src.rss->key_len, .queue_num = src.rss->queue_num, diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index 97d7d3594..d0ff26aa3 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -1046,6 +1046,32 @@ struct rte_flow_query_count { */ struct rte_flow_action_rss { enum rte_eth_hash_function func; /**< RSS hash function to apply. */ + /** + * Packet encapsulation level RSS hash @p types apply to. + * + * - @p 0 requests the default behavior. Depending on the packet + * type, it can mean outermost, innermost, anything in between or + * even no RSS. + * + * It basically stands for the innermost encapsulation level RSS + * can be performed on according to PMD and device capabilities. + * + * - @p 1 requests RSS to be performed on the outermost packet + * encapsulation level. + * + * - @p 2 and subsequent values request RSS to be performed on the + * specified inner packet encapsulation level, from outermost to + * innermost (lower to higher values). + * + * Values other than @p 0 are not necessarily supported. + * + * Requesting a specific RSS level on unrecognized traffic results + * in undefined behavior. For predictable results, it is recommended + * to make the flow rule pattern match packet headers up to the + * requested encapsulation level so that only matching traffic goes + * through. + */ + uint32_t level; uint64_t types; /**< Specific RSS hash types (see ETH_RSS_*). */ uint32_t key_len; /**< Hash key length in bytes. */ uint32_t queue_num; /**< Number of entries in @p queue. */ -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v4 10/16] ethdev: refine TPID handling in flow API 2018-04-16 16:22 ` [dpdk-dev] [PATCH v4 00/16] Flow API overhaul for switch offloads Adrien Mazarguil ` (8 preceding siblings ...) 2018-04-16 16:22 ` [dpdk-dev] [PATCH v4 09/16] ethdev: add encap level " Adrien Mazarguil @ 2018-04-16 16:22 ` Adrien Mazarguil 2018-04-16 16:22 ` [dpdk-dev] [PATCH v4 11/16] ethdev: limit default VLAN TCI mask " Adrien Mazarguil ` (6 subsequent siblings) 16 siblings, 0 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-16 16:22 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev Cc: Wenzhuo Lu, Jingjing Wu, Ajit Khaparde, Somnath Kotur, John Daley, Hyong Youb Kim, Beilei Xing, Qi Zhang, Konstantin Ananyev, Nelio Laranjeiro, Yongseok Koh, Tomasz Duszynski, Dmitri Epshtein, Natalie Samsonov, Jianbo Liu, Andrew Rybchenko, Pascal Mazon TPID handling in rte_flow VLAN and E_TAG pattern item definitions is not consistent with the normal stacking order of pattern items, which is confusing to applications. Problem is that when followed by one of these layers, the EtherType field of the preceding layer keeps its "inner" definition, and the "outer" TPID is provided by the subsequent layer, the reverse of how a packet looks like on the wire: Wire: [ ETH TPID = A | VLAN EtherType = B | B DATA ] rte_flow: [ ETH EtherType = B | VLAN TPID = A | B DATA ] Worse, when QinQ is involved, the stacking order of VLAN layers is unspecified. It is unclear whether it should be reversed (innermost to outermost) as well given TPID applies to the previous layer: Wire: [ ETH TPID = A | VLAN TPID = B | VLAN EtherType = C | C DATA ] rte_flow 1: [ ETH EtherType = C | VLAN TPID = B | VLAN TPID = A | C DATA ] rte_flow 2: [ ETH EtherType = C | VLAN TPID = A | VLAN TPID = B | C DATA ] While specifying EtherType/TPID is hopefully rarely necessary, the stacking order in case of QinQ and the lack of documentation remain an issue. This patch replaces TPID in the VLAN pattern item with an inner EtherType/TPID as is usually done everywhere else (e.g. struct vlan_hdr), clarifies documentation and updates all relevant code. It breaks ABI compatibility for the following public functions: - rte_flow_copy() - rte_flow_create() - rte_flow_query() - rte_flow_validate() Summary of changes for PMDs that implement ETH, VLAN or E_TAG pattern items: - bnxt: EtherType matching is supported with and without VLAN, but TPID matching is not and triggers an error. - e1000: EtherType matching is only supported with the ETHERTYPE filter, which does not support VLAN matching, therefore no impact. - enic: same as bnxt. - i40e: same as bnxt with existing FDIR limitations on allowed EtherType values. The remaining filter types (VXLAN, NVGRE, QINQ) do not support EtherType matching. - ixgbe: same as e1000, with additional minor change to rely on the new E-Tag macro definition. - mlx4: EtherType/TPID matching is not supported, no impact. - mlx5: same as bnxt. - mvpp2: same as bnxt. - sfc: same as bnxt. - tap: same as bnxt. Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Acked-by: Andrew Rybchenko <arybchenko@solarflare.com> Cc: Ferruh Yigit <ferruh.yigit@intel.com> Cc: Thomas Monjalon <thomas@monjalon.net> Cc: Wenzhuo Lu <wenzhuo.lu@intel.com> Cc: Jingjing Wu <jingjing.wu@intel.com> Cc: Ajit Khaparde <ajit.khaparde@broadcom.com> Cc: Somnath Kotur <somnath.kotur@broadcom.com> Cc: John Daley <johndale@cisco.com> Cc: Hyong Youb Kim <hyonkim@cisco.com> Cc: Beilei Xing <beilei.xing@intel.com> Cc: Qi Zhang <qi.z.zhang@intel.com> Cc: Konstantin Ananyev <konstantin.ananyev@intel.com> Cc: Nelio Laranjeiro <nelio.laranjeiro@6wind.com> Cc: Yongseok Koh <yskoh@mellanox.com> Cc: Tomasz Duszynski <tdu@semihalf.com> Cc: Dmitri Epshtein <dima@marvell.com> Cc: Natalie Samsonov <nsamsono@marvell.com> Cc: Jianbo Liu <jianbo.liu@arm.com> Cc: Andrew Rybchenko <arybchenko@solarflare.com> Cc: Pascal Mazon <pascal.mazon@6wind.com> --- v3 changes: Updated mrvl to mvpp2. Moved unrelated default TCI mask update to separate patch. Fixed sfc according to Andrew's comments [1], which made so much sense that I standardized on the same behavior for all other PMDs: matching outer TPID is never supported when a VLAN pattern item is present. This is done because many devices accept several TPIDs but do not provide means to match a given one explicitly, it's all or nothing, and that makes the resulting flow rule inaccurate. [1] http://dpdk.org/ml/archives/dev/2018-April/095870.html --- app/test-pmd/cmdline_flow.c | 17 +++---- doc/guides/nics/tap.rst | 2 +- doc/guides/prog_guide/rte_flow.rst | 19 ++++++-- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 4 +- drivers/net/bnxt/bnxt_filter.c | 35 +++++++++++--- drivers/net/enic/enic_flow.c | 19 +++++--- drivers/net/i40e/i40e_flow.c | 60 ++++++++++++++++++++---- drivers/net/ixgbe/ixgbe_ethdev.c | 3 +- drivers/net/mlx5/mlx5_flow.c | 13 ++++- drivers/net/mvpp2/mrvl_flow.c | 26 +++++++--- drivers/net/sfc/sfc_flow.c | 18 +++++++ drivers/net/tap/tap_flow.c | 14 ++++-- lib/librte_ether/rte_flow.h | 22 ++++++--- lib/librte_net/rte_ether.h | 1 + 14 files changed, 198 insertions(+), 55 deletions(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 976fde7cd..f8f2a559e 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -99,11 +99,11 @@ enum index { ITEM_ETH_SRC, ITEM_ETH_TYPE, ITEM_VLAN, - ITEM_VLAN_TPID, ITEM_VLAN_TCI, ITEM_VLAN_PCP, ITEM_VLAN_DEI, ITEM_VLAN_VID, + ITEM_VLAN_INNER_TYPE, ITEM_IPV4, ITEM_IPV4_TOS, ITEM_IPV4_TTL, @@ -505,11 +505,11 @@ static const enum index item_eth[] = { }; static const enum index item_vlan[] = { - ITEM_VLAN_TPID, ITEM_VLAN_TCI, ITEM_VLAN_PCP, ITEM_VLAN_DEI, ITEM_VLAN_VID, + ITEM_VLAN_INNER_TYPE, ITEM_NEXT, ZERO, }; @@ -1142,12 +1142,6 @@ static const struct token token_list[] = { .next = NEXT(item_vlan), .call = parse_vc, }, - [ITEM_VLAN_TPID] = { - .name = "tpid", - .help = "tag protocol identifier", - .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param), - .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vlan, tpid)), - }, [ITEM_VLAN_TCI] = { .name = "tci", .help = "tag control information", @@ -1175,6 +1169,13 @@ static const struct token token_list[] = { .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan, tci, "\x0f\xff")), }, + [ITEM_VLAN_INNER_TYPE] = { + .name = "inner_type", + .help = "inner EtherType", + .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vlan, + inner_type)), + }, [ITEM_IPV4] = { .name = "ipv4", .help = "match IPv4 header", diff --git a/doc/guides/nics/tap.rst b/doc/guides/nics/tap.rst index c97786aca..3f7a15147 100644 --- a/doc/guides/nics/tap.rst +++ b/doc/guides/nics/tap.rst @@ -108,7 +108,7 @@ The kernel support can be checked with this command:: Supported items: - eth: src and dst (with variable masks), and eth_type (0xffff mask). -- vlan: vid, pcp, tpid, but not eid. (requires kernel 4.9) +- vlan: vid, pcp, but not eid. (requires kernel 4.9) - ipv4/6: src and dst (with variable masks), and ip_proto (0xffff mask). - udp/tcp: src and dst port (0xffff) mask. diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 1a09e8a0f..fd317b48c 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -784,9 +784,15 @@ Item: ``ETH`` Matches an Ethernet header. +The ``type`` field either stands for "EtherType" or "TPID" when followed by +so-called layer 2.5 pattern items such as ``RTE_FLOW_ITEM_TYPE_VLAN``. In +the latter case, ``type`` refers to that of the outer header, with the inner +EtherType/TPID provided by the subsequent pattern item. This is the same +order as on the wire. + - ``dst``: destination MAC. - ``src``: source MAC. -- ``type``: EtherType. +- ``type``: EtherType or TPID. - Default ``mask`` matches destination and source addresses only. Item: ``VLAN`` @@ -794,8 +800,12 @@ Item: ``VLAN`` Matches an 802.1Q/ad VLAN tag. -- ``tpid``: tag protocol identifier. +The corresponding standard outer EtherType (TPID) values are +``ETHER_TYPE_VLAN`` or ``ETHER_TYPE_QINQ``. It can be overridden by the +preceding pattern item. + - ``tci``: tag control information. +- ``inner_type``: inner EtherType or TPID. - Default ``mask`` matches TCI only. Item: ``IPV4`` @@ -866,12 +876,15 @@ Item: ``E_TAG`` Matches an IEEE 802.1BR E-Tag header. -- ``tpid``: tag protocol identifier (0x893F) +The corresponding standard outer EtherType (TPID) value is +``ETHER_TYPE_ETAG``. It can be overridden by the preceding pattern item. + - ``epcp_edei_in_ecid_b``: E-Tag control information (E-TCI), E-PCP (3b), E-DEI (1b), ingress E-CID base (12b). - ``rsvd_grp_ecid_b``: reserved (2b), GRP (2b), E-CID base (12b). - ``in_ecid_e``: ingress E-CID ext. - ``ecid_e``: E-CID ext. +- ``inner_type``: inner EtherType or TPID. - Default ``mask`` simultaneously matches GRP and E-CID base. Item: ``NVGRE`` diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index 3b1073bfc..923664f7d 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3223,15 +3223,15 @@ This section lists supported pattern items and their attributes, if any. - ``dst {MAC-48}``: destination MAC. - ``src {MAC-48}``: source MAC. - - ``type {unsigned}``: EtherType. + - ``type {unsigned}``: EtherType or TPID. - ``vlan``: match 802.1Q/ad VLAN tag. - - ``tpid {unsigned}``: tag protocol identifier. - ``tci {unsigned}``: tag control information. - ``pcp {unsigned}``: priority code point. - ``dei {unsigned}``: drop eligible indicator. - ``vid {unsigned}``: VLAN identifier. + - ``inner_type {unsigned}``: inner EtherType or TPID. - ``ipv4``: match IPv4 header. diff --git a/drivers/net/bnxt/bnxt_filter.c b/drivers/net/bnxt/bnxt_filter.c index 0f9c1c9ae..9bb1575cb 100644 --- a/drivers/net/bnxt/bnxt_filter.c +++ b/drivers/net/bnxt/bnxt_filter.c @@ -299,6 +299,7 @@ bnxt_validate_and_parse_flow_type(struct bnxt *bp, uint32_t vf = 0; int use_ntuple; uint32_t en = 0; + uint32_t en_ethertype; int dflt_vnic; use_ntuple = bnxt_filter_type_check(pattern, error); @@ -308,6 +309,9 @@ bnxt_validate_and_parse_flow_type(struct bnxt *bp, filter->filter_type = use_ntuple ? HWRM_CFA_NTUPLE_FILTER : HWRM_CFA_EM_FILTER; + en_ethertype = use_ntuple ? + NTUPLE_FLTR_ALLOC_INPUT_EN_ETHERTYPE : + EM_FLOW_ALLOC_INPUT_EN_ETHERTYPE; while (item->type != RTE_FLOW_ITEM_TYPE_END) { if (item->last) { @@ -377,30 +381,49 @@ bnxt_validate_and_parse_flow_type(struct bnxt *bp, if (eth_mask->type) { filter->ethertype = rte_be_to_cpu_16(eth_spec->type); - en |= use_ntuple ? - NTUPLE_FLTR_ALLOC_INPUT_EN_ETHERTYPE : - EM_FLOW_ALLOC_INPUT_EN_ETHERTYPE; + en |= en_ethertype; } break; case RTE_FLOW_ITEM_TYPE_VLAN: vlan_spec = item->spec; vlan_mask = item->mask; + if (en & en_ethertype) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, + item, + "VLAN TPID matching is not" + " supported"); + return -rte_errno; + } if (vlan_mask->tci && - vlan_mask->tci == RTE_BE16(0x0fff) && - !vlan_mask->tpid) { + vlan_mask->tci == RTE_BE16(0x0fff)) { /* Only the VLAN ID can be matched. */ filter->l2_ovlan = rte_be_to_cpu_16(vlan_spec->tci & RTE_BE16(0x0fff)); en |= EM_FLOW_ALLOC_INPUT_EN_OVLAN_VID; - } else if (vlan_mask->tci || vlan_mask->tpid) { + } else if (vlan_mask->tci) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM, item, "VLAN mask is invalid"); return -rte_errno; } + if (vlan_mask->inner_type && + vlan_mask->inner_type != RTE_BE16(0xffff)) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, + item, + "inner ethertype mask not" + " valid"); + return -rte_errno; + } + if (vlan_mask->inner_type) { + filter->ethertype = + rte_be_to_cpu_16(vlan_spec->inner_type); + en |= en_ethertype; + } break; case RTE_FLOW_ITEM_TYPE_IPV4: diff --git a/drivers/net/enic/enic_flow.c b/drivers/net/enic/enic_flow.c index a5c6a1670..20d6b9d59 100644 --- a/drivers/net/enic/enic_flow.c +++ b/drivers/net/enic/enic_flow.c @@ -557,16 +557,21 @@ enic_copy_item_vlan_v2(const struct rte_flow_item *item, if (!spec) return 0; - /* Don't support filtering in tpid */ - if (mask) { - if (mask->tpid != 0) - return ENOTSUP; - } else { + if (!mask) mask = &rte_flow_item_vlan_mask; - RTE_ASSERT(mask->tpid == 0); - } if (*inner_ofst == 0) { + struct ether_hdr *eth_mask = + (void *)gp->layer[FILTER_GENERIC_1_L2].mask; + struct ether_hdr *eth_val = + (void *)gp->layer[FILTER_GENERIC_1_L2].val; + + /* Outer TPID cannot be matched */ + if (eth_mask->ether_type) + return ENOTSUP; + eth_mask->ether_type = mask->inner_type; + eth_val->ether_type = spec->inner_type; + /* Outer header. Use the vlan mask/val fields */ gp->mask_vlan = mask->tci; gp->val_vlan = spec->tci; diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c index db668835d..470ab93d6 100644 --- a/drivers/net/i40e/i40e_flow.c +++ b/drivers/net/i40e/i40e_flow.c @@ -10,6 +10,7 @@ #include <unistd.h> #include <stdarg.h> +#include <rte_debug.h> #include <rte_ether.h> #include <rte_ethdev_driver.h> #include <rte_log.h> @@ -2491,16 +2492,22 @@ i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev, "Invalid MAC_addr mask."); return -rte_errno; } + } + if (eth_spec && eth_mask && eth_mask->type) { + enum rte_flow_item_type next = (item + 1)->type; - if ((eth_mask->type & UINT16_MAX) == - UINT16_MAX) { - input_set |= I40E_INSET_LAST_ETHER_TYPE; - filter->input.flow.l2_flow.ether_type = - eth_spec->type; + if (eth_mask->type != RTE_BE16(0xffff)) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, + item, + "Invalid type mask."); + return -rte_errno; } ether_type = rte_be_to_cpu_16(eth_spec->type); - if (ether_type == ETHER_TYPE_IPv4 || + + if (next == RTE_FLOW_ITEM_TYPE_VLAN || + ether_type == ETHER_TYPE_IPv4 || ether_type == ETHER_TYPE_IPv6 || ether_type == ETHER_TYPE_ARP || ether_type == outer_tpid) { @@ -2510,6 +2517,9 @@ i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev, "Unsupported ether_type."); return -rte_errno; } + input_set |= I40E_INSET_LAST_ETHER_TYPE; + filter->input.flow.l2_flow.ether_type = + eth_spec->type; } pctype = I40E_FILTER_PCTYPE_L2_PAYLOAD; @@ -2519,6 +2529,8 @@ i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev, case RTE_FLOW_ITEM_TYPE_VLAN: vlan_spec = item->spec; vlan_mask = item->mask; + + RTE_ASSERT(!(input_set & I40E_INSET_LAST_ETHER_TYPE)); if (vlan_spec && vlan_mask) { if (vlan_mask->tci == rte_cpu_to_be_16(I40E_TCI_MASK)) { @@ -2527,6 +2539,33 @@ i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev, vlan_spec->tci; } } + if (vlan_spec && vlan_mask && vlan_mask->inner_type) { + if (vlan_mask->inner_type != RTE_BE16(0xffff)) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, + item, + "Invalid inner_type" + " mask."); + return -rte_errno; + } + + ether_type = + rte_be_to_cpu_16(vlan_spec->inner_type); + + if (ether_type == ETHER_TYPE_IPv4 || + ether_type == ETHER_TYPE_IPv6 || + ether_type == ETHER_TYPE_ARP || + ether_type == outer_tpid) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, + item, + "Unsupported inner_type."); + return -rte_errno; + } + input_set |= I40E_INSET_LAST_ETHER_TYPE; + filter->input.flow.l2_flow.ether_type = + vlan_spec->inner_type; + } pctype = I40E_FILTER_PCTYPE_L2_PAYLOAD; layer_idx = I40E_FLXPLD_L2_IDX; @@ -3285,7 +3324,8 @@ i40e_flow_parse_vxlan_pattern(__rte_unused struct rte_eth_dev *dev, case RTE_FLOW_ITEM_TYPE_VLAN: vlan_spec = item->spec; vlan_mask = item->mask; - if (!(vlan_spec && vlan_mask)) { + if (!(vlan_spec && vlan_mask) || + vlan_mask->inner_type) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM, item, @@ -3515,7 +3555,8 @@ i40e_flow_parse_nvgre_pattern(__rte_unused struct rte_eth_dev *dev, case RTE_FLOW_ITEM_TYPE_VLAN: vlan_spec = item->spec; vlan_mask = item->mask; - if (!(vlan_spec && vlan_mask)) { + if (!(vlan_spec && vlan_mask) || + vlan_mask->inner_type) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM, item, @@ -4023,7 +4064,8 @@ i40e_flow_parse_qinq_pattern(__rte_unused struct rte_eth_dev *dev, vlan_spec = item->spec; vlan_mask = item->mask; - if (!(vlan_spec && vlan_mask)) { + if (!(vlan_spec && vlan_mask) || + vlan_mask->inner_type) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM, item, diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c index 25a8d041d..ac2204971 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.c +++ b/drivers/net/ixgbe/ixgbe_ethdev.c @@ -115,7 +115,6 @@ #define IXGBE_VT_CTL_POOLING_MODE_MASK 0x00030000 #define IXGBE_VT_CTL_POOLING_MODE_ETAG 0x00010000 -#define DEFAULT_ETAG_ETYPE 0x893f #define IXGBE_ETAG_ETYPE 0x00005084 #define IXGBE_ETAG_ETYPE_MASK 0x0000ffff #define IXGBE_ETAG_ETYPE_VALID 0x80000000 @@ -1481,7 +1480,7 @@ static int ixgbe_l2_tn_filter_init(struct rte_eth_dev *eth_dev) } l2_tn_info->e_tag_en = FALSE; l2_tn_info->e_tag_fwd_en = FALSE; - l2_tn_info->e_tag_ether_type = DEFAULT_ETAG_ETYPE; + l2_tn_info->e_tag_ether_type = ETHER_TYPE_ETAG; return 0; } diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 76a1053ec..4a2411010 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -18,6 +18,7 @@ #endif #include <rte_common.h> +#include <rte_ether.h> #include <rte_eth_ctrl.h> #include <rte_ethdev_driver.h> #include <rte_flow.h> @@ -306,6 +307,7 @@ static const struct mlx5_flow_items mlx5_flow_items[] = { .actions = valid_actions, .mask = &(const struct rte_flow_item_vlan){ .tci = -1, + .inner_type = -1, }, .default_mask = &rte_flow_item_vlan_mask, .mask_sz = sizeof(struct rte_flow_item_vlan), @@ -1285,6 +1287,7 @@ mlx5_flow_create_vlan(const struct rte_flow_item *item, struct mlx5_flow_parse *parser = data->parser; struct ibv_flow_spec_eth *eth; const unsigned int eth_size = sizeof(struct ibv_flow_spec_eth); + const char *msg = "VLAN cannot be empty"; if (spec) { unsigned int i; @@ -1306,12 +1309,20 @@ mlx5_flow_create_vlan(const struct rte_flow_item *item, */ if (!eth->mask.vlan_tag) goto error; + /* Outer TPID cannot be matched. */ + if (eth->mask.ether_type) { + msg = "VLAN TPID matching is not supported"; + goto error; + } + eth->val.ether_type = spec->inner_type; + eth->mask.ether_type = mask->inner_type; + eth->val.ether_type &= eth->mask.ether_type; } return 0; } error: return rte_flow_error_set(data->error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM, - item, "VLAN cannot be empty"); + item, msg); } /** diff --git a/drivers/net/mvpp2/mrvl_flow.c b/drivers/net/mvpp2/mrvl_flow.c index 8fd4dbfb1..6478eb2fe 100644 --- a/drivers/net/mvpp2/mrvl_flow.c +++ b/drivers/net/mvpp2/mrvl_flow.c @@ -1091,12 +1091,6 @@ mrvl_parse_vlan(const struct rte_flow_item *item, if (ret) return ret; - if (mask->tpid) { - rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM, - NULL, "Not supported by classifier\n"); - return -rte_errno; - } - m = rte_be_to_cpu_16(mask->tci); if (m & MRVL_VLAN_ID_MASK) { RTE_LOG(WARNING, PMD, "vlan id mask is ignored\n"); @@ -1112,6 +1106,26 @@ mrvl_parse_vlan(const struct rte_flow_item *item, goto out; } + if (flow->pattern & F_TYPE) { + rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ITEM, item, + "VLAN TPID matching is not supported\n"); + return -rte_errno; + } + if (mask->inner_type) { + struct rte_flow_item_eth spec_eth = { + .type = spec->inner_type, + }; + struct rte_flow_item_eth mask_eth = { + .type = mask->inner_type, + }; + + RTE_LOG(WARNING, PMD, "inner eth type mask is ignored\n"); + ret = mrvl_parse_type(spec_eth, mask_eth, flow); + if (ret) + goto out; + } + return 0; out: rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, diff --git a/drivers/net/sfc/sfc_flow.c b/drivers/net/sfc/sfc_flow.c index 3028efbf9..cd6a61b39 100644 --- a/drivers/net/sfc/sfc_flow.c +++ b/drivers/net/sfc/sfc_flow.c @@ -7,6 +7,7 @@ * for Solarflare) and Solarflare Communications, Inc. */ +#include <rte_byteorder.h> #include <rte_tailq.h> #include <rte_common.h> #include <rte_ethdev_driver.h> @@ -351,6 +352,7 @@ sfc_flow_parse_vlan(const struct rte_flow_item *item, const struct rte_flow_item_vlan *mask = NULL; const struct rte_flow_item_vlan supp_mask = { .tci = rte_cpu_to_be_16(ETH_VLAN_ID_MAX), + .inner_type = RTE_BE16(0xffff), }; rc = sfc_flow_parse_init(item, @@ -393,6 +395,22 @@ sfc_flow_parse_vlan(const struct rte_flow_item *item, return -rte_errno; } + if (efx_spec->efs_match_flags & EFX_FILTER_MATCH_ETHER_TYPE) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, item, + "VLAN TPID matching is not supported"); + return -rte_errno; + } + if (mask->inner_type == supp_mask.inner_type) { + efx_spec->efs_match_flags |= EFX_FILTER_MATCH_ETHER_TYPE; + efx_spec->efs_ether_type = rte_bswap16(spec->inner_type); + } else if (mask->inner_type) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, item, + "Bad mask for VLAN inner_type"); + return -rte_errno; + } + return 0; } diff --git a/drivers/net/tap/tap_flow.c b/drivers/net/tap/tap_flow.c index 7dfaf9ac5..dff09313a 100644 --- a/drivers/net/tap/tap_flow.c +++ b/drivers/net/tap/tap_flow.c @@ -270,13 +270,13 @@ static const struct tap_flow_items tap_flow_items[] = { .items = ITEMS(RTE_FLOW_ITEM_TYPE_IPV4, RTE_FLOW_ITEM_TYPE_IPV6), .mask = &(const struct rte_flow_item_vlan){ - .tpid = -1, /* DEI matching is not supported */ #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN .tci = 0xffef, #else .tci = 0xefff, #endif + .inner_type = -1, }, .mask_sz = sizeof(struct rte_flow_item_vlan), .default_mask = &rte_flow_item_vlan_mask, @@ -578,13 +578,19 @@ tap_flow_create_vlan(const struct rte_flow_item *item, void *data) /* use default mask if none provided */ if (!mask) mask = tap_flow_items[RTE_FLOW_ITEM_TYPE_VLAN].default_mask; - /* TC does not support tpid masking. Only accept if exact match. */ - if (mask->tpid && mask->tpid != 0xffff) + /* Outer TPID cannot be matched. */ + if (info->eth_type) return -1; /* Double-tagging not supported. */ - if (spec && mask->tpid && spec->tpid != htons(ETH_P_8021Q)) + if (info->vlan) return -1; info->vlan = 1; + if (mask->inner_type) { + /* TC does not support partial eth_type masking */ + if (mask->inner_type != RTE_BE16(0xffff)) + return -1; + info->eth_type = spec->inner_type; + } if (!flow) return 0; msg = &flow->msg; diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index d0ff26aa3..8e50384d0 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -454,11 +454,17 @@ static const struct rte_flow_item_raw rte_flow_item_raw_mask = { * RTE_FLOW_ITEM_TYPE_ETH * * Matches an Ethernet header. + * + * The @p type field either stands for "EtherType" or "TPID" when followed + * by so-called layer 2.5 pattern items such as RTE_FLOW_ITEM_TYPE_VLAN. In + * the latter case, @p type refers to that of the outer header, with the + * inner EtherType/TPID provided by the subsequent pattern item. This is the + * same order as on the wire. */ struct rte_flow_item_eth { struct ether_addr dst; /**< Destination MAC. */ struct ether_addr src; /**< Source MAC. */ - rte_be16_t type; /**< EtherType. */ + rte_be16_t type; /**< EtherType or TPID. */ }; /** Default mask for RTE_FLOW_ITEM_TYPE_ETH. */ @@ -475,19 +481,20 @@ static const struct rte_flow_item_eth rte_flow_item_eth_mask = { * * Matches an 802.1Q/ad VLAN tag. * - * This type normally follows either RTE_FLOW_ITEM_TYPE_ETH or - * RTE_FLOW_ITEM_TYPE_VLAN. + * The corresponding standard outer EtherType (TPID) values are + * ETHER_TYPE_VLAN or ETHER_TYPE_QINQ. It can be overridden by the preceding + * pattern item. */ struct rte_flow_item_vlan { - rte_be16_t tpid; /**< Tag protocol identifier. */ rte_be16_t tci; /**< Tag control information. */ + rte_be16_t inner_type; /**< Inner EtherType or TPID. */ }; /** Default mask for RTE_FLOW_ITEM_TYPE_VLAN. */ #ifndef __cplusplus static const struct rte_flow_item_vlan rte_flow_item_vlan_mask = { - .tpid = RTE_BE16(0x0000), .tci = RTE_BE16(0xffff), + .inner_type = RTE_BE16(0x0000), }; #endif @@ -636,9 +643,11 @@ static const struct rte_flow_item_vxlan rte_flow_item_vxlan_mask = { * RTE_FLOW_ITEM_TYPE_E_TAG. * * Matches a E-tag header. + * + * The corresponding standard outer EtherType (TPID) value is + * ETHER_TYPE_ETAG. It can be overridden by the preceding pattern item. */ struct rte_flow_item_e_tag { - rte_be16_t tpid; /**< Tag protocol identifier (0x893F). */ /** * E-Tag control information (E-TCI). * E-PCP (3b), E-DEI (1b), ingress E-CID base (12b). @@ -648,6 +657,7 @@ struct rte_flow_item_e_tag { rte_be16_t rsvd_grp_ecid_b; uint8_t in_ecid_e; /**< Ingress E-CID ext. */ uint8_t ecid_e; /**< E-CID ext. */ + rte_be16_t inner_type; /**< Inner EtherType or TPID. */ }; /** Default mask for RTE_FLOW_ITEM_TYPE_E_TAG. */ diff --git a/lib/librte_net/rte_ether.h b/lib/librte_net/rte_ether.h index 45daa911a..a271d1c86 100644 --- a/lib/librte_net/rte_ether.h +++ b/lib/librte_net/rte_ether.h @@ -301,6 +301,7 @@ struct vxlan_hdr { #define ETHER_TYPE_RARP 0x8035 /**< Reverse Arp Protocol. */ #define ETHER_TYPE_VLAN 0x8100 /**< IEEE 802.1Q VLAN tagging. */ #define ETHER_TYPE_QINQ 0x88A8 /**< IEEE 802.1ad QinQ tagging. */ +#define ETHER_TYPE_ETAG 0x893F /**< IEEE 802.1BR E-Tag. */ #define ETHER_TYPE_1588 0x88F7 /**< IEEE 802.1AS 1588 Precise Time Protocol. */ #define ETHER_TYPE_SLOW 0x8809 /**< Slow protocols (LACP and Marker). */ #define ETHER_TYPE_TEB 0x6558 /**< Transparent Ethernet Bridging. */ -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v4 11/16] ethdev: limit default VLAN TCI mask in flow API 2018-04-16 16:22 ` [dpdk-dev] [PATCH v4 00/16] Flow API overhaul for switch offloads Adrien Mazarguil ` (9 preceding siblings ...) 2018-04-16 16:22 ` [dpdk-dev] [PATCH v4 10/16] ethdev: refine TPID handling in flow API Adrien Mazarguil @ 2018-04-16 16:22 ` Adrien Mazarguil 2018-04-16 16:22 ` [dpdk-dev] [PATCH v4 12/16] ethdev: add transfer attribute to " Adrien Mazarguil ` (5 subsequent siblings) 16 siblings, 0 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-16 16:22 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev Cc: Wenzhuo Lu, Jingjing Wu, Ajit Khaparde, Somnath Kotur, John Daley, Hyong Youb Kim, Beilei Xing, Qi Zhang, Konstantin Ananyev, Nelio Laranjeiro, Yongseok Koh, Tomasz Duszynski, Dmitri Epshtein, Natalie Samsonov, Jianbo Liu, Andrew Rybchenko, Pascal Mazon VLAN TCI is a 16-bit field broken down as PCP (3b), DEI (1b) and VID (12b). The default mask used by PMDs for the VLAN pattern when one isn't provided by the application comprises the entire TCI, which is problematic because most devices only support VID matching. This forces applications to always provide a mask limited to the VID part in order to successfully apply a flow rule with a VLAN pattern item. Moreover, applications rarely want to match PCP and DEI intentionally. Given the above and since VID is what is commonly referred to when talking about VLAN, this commit excludes PCP and DEI from the default mask. Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Acked-by: Andrew Rybchenko <arybchenko@solarflare.com> Cc: Ferruh Yigit <ferruh.yigit@intel.com> Cc: Thomas Monjalon <thomas@monjalon.net> Cc: Wenzhuo Lu <wenzhuo.lu@intel.com> Cc: Jingjing Wu <jingjing.wu@intel.com> Cc: Ajit Khaparde <ajit.khaparde@broadcom.com> Cc: Somnath Kotur <somnath.kotur@broadcom.com> Cc: John Daley <johndale@cisco.com> Cc: Hyong Youb Kim <hyonkim@cisco.com> Cc: Beilei Xing <beilei.xing@intel.com> Cc: Qi Zhang <qi.z.zhang@intel.com> Cc: Konstantin Ananyev <konstantin.ananyev@intel.com> Cc: Nelio Laranjeiro <nelio.laranjeiro@6wind.com> Cc: Yongseok Koh <yskoh@mellanox.com> Cc: Tomasz Duszynski <tdu@semihalf.com> Cc: Dmitri Epshtein <dima@marvell.com> Cc: Natalie Samsonov <nsamsono@marvell.com> Cc: Jianbo Liu <jianbo.liu@arm.com> Cc: Andrew Rybchenko <arybchenko@solarflare.com> Cc: Pascal Mazon <pascal.mazon@6wind.com> --- v3 changes: These changes were previously mistakenly made part of the previous patch ("ethdev: refine TPID handling in flow API") from which they were split following Andrew's rightful comment [1]. [1] http://dpdk.org/ml/archives/dev/2018-April/095870.html --- doc/guides/prog_guide/rte_flow.rst | 2 +- lib/librte_ether/rte_flow.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index fd317b48c..c62a80566 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -806,7 +806,7 @@ preceding pattern item. - ``tci``: tag control information. - ``inner_type``: inner EtherType or TPID. -- Default ``mask`` matches TCI only. +- Default ``mask`` matches the VID part of TCI only (lower 12 bits). Item: ``IPV4`` ^^^^^^^^^^^^^^ diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index 8e50384d0..513734dce 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -493,7 +493,7 @@ struct rte_flow_item_vlan { /** Default mask for RTE_FLOW_ITEM_TYPE_VLAN. */ #ifndef __cplusplus static const struct rte_flow_item_vlan rte_flow_item_vlan_mask = { - .tci = RTE_BE16(0xffff), + .tci = RTE_BE16(0x0fff), .inner_type = RTE_BE16(0x0000), }; #endif -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v4 12/16] ethdev: add transfer attribute to flow API 2018-04-16 16:22 ` [dpdk-dev] [PATCH v4 00/16] Flow API overhaul for switch offloads Adrien Mazarguil ` (10 preceding siblings ...) 2018-04-16 16:22 ` [dpdk-dev] [PATCH v4 11/16] ethdev: limit default VLAN TCI mask " Adrien Mazarguil @ 2018-04-16 16:22 ` Adrien Mazarguil 2018-04-16 16:22 ` [dpdk-dev] [PATCH v4 13/16] ethdev: update behavior of VF/PF in " Adrien Mazarguil ` (4 subsequent siblings) 16 siblings, 0 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-16 16:22 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev; +Cc: Andrew Rybchenko This new attribute enables applications to create flow rules that do not simply match traffic whose origin is specified in the pattern (e.g. some non-default physical port or VF), but actively affect it by applying the flow rule at the lowest possible level in the underlying device. It breaks ABI compatibility for the following public functions: - rte_flow_copy() - rte_flow_create() - rte_flow_validate() Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Cc: Andrew Rybchenko <arybchenko@solarflare.com> --- v3 changes: Clarified definition for ingress and egress following Andrew's comment on subsequent patch. [1] http://dpdk.org/ml/archives/dev/2018-April/095961.html --- app/test-pmd/cmdline_flow.c | 11 +++++ app/test-pmd/config.c | 6 ++- doc/guides/prog_guide/rte_flow.rst | 26 +++++++++++- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 11 ++--- drivers/net/bnxt/bnxt_filter.c | 8 ++++ drivers/net/e1000/igb_flow.c | 44 ++++++++++++++++++++ drivers/net/enic/enic_flow.c | 6 +++ drivers/net/i40e/i40e_flow.c | 8 ++++ drivers/net/ixgbe/ixgbe_flow.c | 53 ++++++++++++++++++++++++ drivers/net/mlx4/mlx4_flow.c | 4 ++ drivers/net/mlx5/mlx5_flow.c | 7 ++++ drivers/net/mvpp2/mrvl_flow.c | 6 +++ drivers/net/sfc/sfc_flow.c | 6 +++ drivers/net/tap/tap_flow.c | 6 +++ lib/librte_ether/rte_flow.h | 22 +++++++++- 15 files changed, 215 insertions(+), 9 deletions(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index f8f2a559e..1c6b5a112 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -69,6 +69,7 @@ enum index { PRIORITY, INGRESS, EGRESS, + TRANSFER, /* Validate/create pattern. */ PATTERN, @@ -407,6 +408,7 @@ static const enum index next_vc_attr[] = { PRIORITY, INGRESS, EGRESS, + TRANSFER, PATTERN, ZERO, }; @@ -960,6 +962,12 @@ static const struct token token_list[] = { .next = NEXT(next_vc_attr), .call = parse_vc, }, + [TRANSFER] = { + .name = "transfer", + .help = "apply rule directly to endpoints found in pattern", + .next = NEXT(next_vc_attr), + .call = parse_vc, + }, /* Validate/create pattern. */ [PATTERN] = { .name = "pattern", @@ -1945,6 +1953,9 @@ parse_vc(struct context *ctx, const struct token *token, case EGRESS: out->args.vc.attr.egress = 1; return len; + case TRANSFER: + out->args.vc.attr.transfer = 1; + return len; case PATTERN: out->args.vc.pattern = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1), diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 562fb2f8d..a50a5c544 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -1239,6 +1239,7 @@ port_flow_complain(struct rte_flow_error *error) [RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY] = "priority field", [RTE_FLOW_ERROR_TYPE_ATTR_INGRESS] = "ingress field", [RTE_FLOW_ERROR_TYPE_ATTR_EGRESS] = "egress field", + [RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER] = "transfer field", [RTE_FLOW_ERROR_TYPE_ATTR] = "attributes structure", [RTE_FLOW_ERROR_TYPE_ITEM_NUM] = "pattern length", [RTE_FLOW_ERROR_TYPE_ITEM_SPEC] = "item specification", @@ -1504,12 +1505,13 @@ port_flow_list(portid_t port_id, uint32_t n, const uint32_t group[n]) const struct rte_flow_item *item = pf->pattern; const struct rte_flow_action *action = pf->actions; - printf("%" PRIu32 "\t%" PRIu32 "\t%" PRIu32 "\t%c%c\t", + printf("%" PRIu32 "\t%" PRIu32 "\t%" PRIu32 "\t%c%c%c\t", pf->id, pf->attr.group, pf->attr.priority, pf->attr.ingress ? 'i' : '-', - pf->attr.egress ? 'e' : '-'); + pf->attr.egress ? 'e' : '-', + pf->attr.transfer ? 't' : '-'); while (item->type != RTE_FLOW_ITEM_TYPE_END) { if (item->type != RTE_FLOW_ITEM_TYPE_VOID) printf("%s ", flow_item[item->type].name); diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index c62a80566..550a4c95b 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -170,7 +170,13 @@ Note that support for more than a single priority level is not guaranteed. Attribute: Traffic direction ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Flow rules can apply to inbound and/or outbound traffic (ingress/egress). +Flow rule patterns apply to inbound and/or outbound traffic. + +In the context of this API, **ingress** and **egress** respectively stand +for **inbound** and **outbound** based on the standpoint of the application +creating a flow rule. + +There are no exceptions to this definition. Several pattern items and actions are valid and can be used in both directions. At least one direction must be specified. @@ -178,6 +184,24 @@ directions. At least one direction must be specified. Specifying both directions at once for a given rule is not recommended but may be valid in a few cases (e.g. shared counters). +Attribute: Transfer +^^^^^^^^^^^^^^^^^^^ + +Instead of simply matching the properties of traffic as it would appear on a +given DPDK port ID, enabling this attribute transfers a flow rule to the +lowest possible level of any device endpoints found in the pattern. + +When supported, this effectively enables an application to reroute traffic +not necessarily intended for it (e.g. coming from or addressed to different +physical ports, VFs or applications) at the device level. + +It complements the behavior of some pattern items such as `Item: PORT`_ and +is meaningless without them. + +When transferring flow rules, **ingress** and **egress** attributes +(`Attribute: Traffic direction`_) keep their original meaning, as if +processing traffic emitted or received by the application. + Pattern item ~~~~~~~~~~~~ diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index 923664f7d..0bf6c33c9 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -2970,14 +2970,14 @@ following sections. - Check whether a flow rule can be created:: flow validate {port_id} - [group {group_id}] [priority {level}] [ingress] [egress] + [group {group_id}] [priority {level}] [ingress] [egress] [transfer] pattern {item} [/ {item} [...]] / end actions {action} [/ {action} [...]] / end - Create a flow rule:: flow create {port_id} - [group {group_id}] [priority {level}] [ingress] [egress] + [group {group_id}] [priority {level}] [ingress] [egress] [transfer] pattern {item} [/ {item} [...]] / end actions {action} [/ {action} [...]] / end @@ -3010,7 +3010,7 @@ underlying device in its current state but stops short of creating it. It is bound to ``rte_flow_validate()``:: flow validate {port_id} - [group {group_id}] [priority {level}] [ingress] [egress] + [group {group_id}] [priority {level}] [ingress] [egress] [transfer] pattern {item} [/ {item} [...]] / end actions {action} [/ {action} [...]] / end @@ -3047,7 +3047,7 @@ Creating flow rules to ``rte_flow_create()``:: flow create {port_id} - [group {group_id}] [priority {level}] [ingress] [egress] + [group {group_id}] [priority {level}] [ingress] [egress] [transfer] pattern {item} [/ {item} [...]] / end actions {action} [/ {action} [...]] / end @@ -3061,7 +3061,7 @@ Otherwise it will show an error message of the form:: Parameters describe in the following order: -- Attributes (*group*, *priority*, *ingress*, *egress* tokens). +- Attributes (*group*, *priority*, *ingress*, *egress*, *transfer* tokens). - A matching pattern, starting with the *pattern* token and terminated by an *end* pattern item. - Actions, starting with the *actions* token and terminated by an *end* @@ -3089,6 +3089,7 @@ specified before the ``pattern`` token. - ``priority {level}``: priority level within group. - ``ingress``: rule applies to ingress traffic. - ``egress``: rule applies to egress traffic. +- ``transfer``: apply rule directly to endpoints found in pattern. Each instance of an attribute specified several times overrides the previous value as shown below (group 4 is used):: diff --git a/drivers/net/bnxt/bnxt_filter.c b/drivers/net/bnxt/bnxt_filter.c index 9bb1575cb..bd166370a 100644 --- a/drivers/net/bnxt/bnxt_filter.c +++ b/drivers/net/bnxt/bnxt_filter.c @@ -746,6 +746,14 @@ bnxt_flow_parse_attr(const struct rte_flow_attr *attr, } /* Not supported */ + if (attr->transfer) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + attr, "No support for transfer."); + return -rte_errno; + } + + /* Not supported */ if (attr->priority) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, diff --git a/drivers/net/e1000/igb_flow.c b/drivers/net/e1000/igb_flow.c index d1c0b4b8d..073852913 100644 --- a/drivers/net/e1000/igb_flow.c +++ b/drivers/net/e1000/igb_flow.c @@ -379,6 +379,15 @@ cons_parse_ntuple_filter(const struct rte_flow_attr *attr, return -rte_errno; } + /* not supported */ + if (attr->transfer) { + memset(filter, 0, sizeof(struct rte_eth_ntuple_filter)); + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + attr, "No support for transfer."); + return -rte_errno; + } + if (attr->priority > 0xFFFF) { memset(filter, 0, sizeof(struct rte_eth_ntuple_filter)); rte_flow_error_set(error, EINVAL, @@ -624,6 +633,14 @@ cons_parse_ethertype_filter(const struct rte_flow_attr *attr, } /* Not supported */ + if (attr->transfer) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + attr, "No support for transfer."); + return -rte_errno; + } + + /* Not supported */ if (attr->priority) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, @@ -923,6 +940,15 @@ cons_parse_syn_filter(const struct rte_flow_attr *attr, return -rte_errno; } + /* not supported */ + if (attr->transfer) { + memset(filter, 0, sizeof(struct rte_eth_syn_filter)); + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + attr, "No support for transfer."); + return -rte_errno; + } + /* Support 2 priorities, the lowest or highest. */ if (!attr->priority) { filter->hig_pri = 0; @@ -1211,6 +1237,15 @@ cons_parse_flex_filter(const struct rte_flow_attr *attr, return -rte_errno; } + /* not supported */ + if (attr->transfer) { + memset(filter, 0, sizeof(struct rte_eth_flex_filter)); + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + attr, "No support for transfer."); + return -rte_errno; + } + if (attr->priority > 0xFFFF) { memset(filter, 0, sizeof(struct rte_eth_flex_filter)); rte_flow_error_set(error, EINVAL, @@ -1361,6 +1396,15 @@ igb_parse_rss_filter(struct rte_eth_dev *dev, return -rte_errno; } + /* not supported */ + if (attr->transfer) { + memset(rss_conf, 0, sizeof(struct igb_rte_flow_rss_conf)); + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + attr, "No support for transfer."); + return -rte_errno; + } + if (attr->priority > 0xFFFF) { memset(rss_conf, 0, sizeof(struct igb_rte_flow_rss_conf)); rte_flow_error_set(error, EINVAL, diff --git a/drivers/net/enic/enic_flow.c b/drivers/net/enic/enic_flow.c index 20d6b9d59..3a0086399 100644 --- a/drivers/net/enic/enic_flow.c +++ b/drivers/net/enic/enic_flow.c @@ -1318,6 +1318,12 @@ enic_flow_parse(struct rte_eth_dev *dev, NULL, "egress is not supported"); return -rte_errno; + } else if (attrs->transfer) { + rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + NULL, + "transfer is not supported"); + return -rte_errno; } else if (!attrs->ingress) { rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c index 470ab93d6..f416b6a00 100644 --- a/drivers/net/i40e/i40e_flow.c +++ b/drivers/net/i40e/i40e_flow.c @@ -1918,6 +1918,14 @@ i40e_flow_parse_attr(const struct rte_flow_attr *attr, } /* Not supported */ + if (attr->transfer) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + attr, "No support for transfer."); + return -rte_errno; + } + + /* Not supported */ if (attr->priority) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, diff --git a/drivers/net/ixgbe/ixgbe_flow.c b/drivers/net/ixgbe/ixgbe_flow.c index 438bfcdfb..eb0644c82 100644 --- a/drivers/net/ixgbe/ixgbe_flow.c +++ b/drivers/net/ixgbe/ixgbe_flow.c @@ -557,6 +557,15 @@ cons_parse_ntuple_filter(const struct rte_flow_attr *attr, return -rte_errno; } + /* not supported */ + if (attr->transfer) { + memset(filter, 0, sizeof(struct rte_eth_ntuple_filter)); + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + attr, "No support for transfer."); + return -rte_errno; + } + if (attr->priority > 0xFFFF) { memset(filter, 0, sizeof(struct rte_eth_ntuple_filter)); rte_flow_error_set(error, EINVAL, @@ -787,6 +796,14 @@ cons_parse_ethertype_filter(const struct rte_flow_attr *attr, } /* Not supported */ + if (attr->transfer) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + attr, "No support for transfer."); + return -rte_errno; + } + + /* Not supported */ if (attr->priority) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, @@ -1078,6 +1095,15 @@ cons_parse_syn_filter(const struct rte_flow_attr *attr, return -rte_errno; } + /* not supported */ + if (attr->transfer) { + memset(filter, 0, sizeof(struct rte_eth_syn_filter)); + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + attr, "No support for transfer."); + return -rte_errno; + } + /* Support 2 priorities, the lowest or highest. */ if (!attr->priority) { filter->hig_pri = 0; @@ -1250,6 +1276,15 @@ cons_parse_l2_tn_filter(struct rte_eth_dev *dev, } /* not supported */ + if (attr->transfer) { + memset(filter, 0, sizeof(struct rte_eth_l2_tunnel_conf)); + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + attr, "No support for transfer."); + return -rte_errno; + } + + /* not supported */ if (attr->priority) { memset(filter, 0, sizeof(struct rte_eth_l2_tunnel_conf)); rte_flow_error_set(error, EINVAL, @@ -1354,6 +1389,15 @@ ixgbe_parse_fdir_act_attr(const struct rte_flow_attr *attr, } /* not supported */ + if (attr->transfer) { + memset(rule, 0, sizeof(struct ixgbe_fdir_rule)); + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + attr, "No support for transfer."); + return -rte_errno; + } + + /* not supported */ if (attr->priority) { memset(rule, 0, sizeof(struct ixgbe_fdir_rule)); rte_flow_error_set(error, EINVAL, @@ -2829,6 +2873,15 @@ ixgbe_parse_rss_filter(struct rte_eth_dev *dev, return -rte_errno; } + /* not supported */ + if (attr->transfer) { + memset(rss_conf, 0, sizeof(struct ixgbe_rte_flow_rss_conf)); + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + attr, "No support for transfer."); + return -rte_errno; + } + if (attr->priority > 0xFFFF) { memset(rss_conf, 0, sizeof(struct ixgbe_rte_flow_rss_conf)); rte_flow_error_set(error, EINVAL, diff --git a/drivers/net/mlx4/mlx4_flow.c b/drivers/net/mlx4/mlx4_flow.c index ce36ac715..e3d7aa8ef 100644 --- a/drivers/net/mlx4/mlx4_flow.c +++ b/drivers/net/mlx4/mlx4_flow.c @@ -652,6 +652,10 @@ mlx4_flow_prepare(struct priv *priv, return rte_flow_error_set (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, NULL, "egress is not supported"); + if (attr->transfer) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + NULL, "transfer is not supported"); if (!attr->ingress) return rte_flow_error_set (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 4a2411010..968bef746 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -568,6 +568,13 @@ mlx5_flow_convert_attributes(const struct rte_flow_attr *attr, "egress is not supported"); return -rte_errno; } + if (attr->transfer) { + rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + NULL, + "transfer is not supported"); + return -rte_errno; + } if (!attr->ingress) { rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, diff --git a/drivers/net/mvpp2/mrvl_flow.c b/drivers/net/mvpp2/mrvl_flow.c index 6478eb2fe..a2e2129cc 100644 --- a/drivers/net/mvpp2/mrvl_flow.c +++ b/drivers/net/mvpp2/mrvl_flow.c @@ -2187,6 +2187,12 @@ mrvl_flow_parse_attr(struct mrvl_priv *priv __rte_unused, "Egress is not supported"); return -rte_errno; } + if (attr->transfer) { + rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, NULL, + "Transfer is not supported"); + return -rte_errno; + } return 0; } diff --git a/drivers/net/sfc/sfc_flow.c b/drivers/net/sfc/sfc_flow.c index cd6a61b39..bcde2c2f7 100644 --- a/drivers/net/sfc/sfc_flow.c +++ b/drivers/net/sfc/sfc_flow.c @@ -1116,6 +1116,12 @@ sfc_flow_parse_attr(const struct rte_flow_attr *attr, "Egress is not supported"); return -rte_errno; } + if (attr->transfer != 0) { + rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, attr, + "Transfer is not supported"); + return -rte_errno; + } if (attr->ingress == 0) { rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, attr, diff --git a/drivers/net/tap/tap_flow.c b/drivers/net/tap/tap_flow.c index dff09313a..ad2ba9f4e 100644 --- a/drivers/net/tap/tap_flow.c +++ b/drivers/net/tap/tap_flow.c @@ -1039,6 +1039,12 @@ priv_flow_process(struct pmd_internals *pmd, }; int action = 0; /* Only one action authorized for now */ + if (attr->transfer) { + rte_flow_error_set( + error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + NULL, "transfer is not supported"); + return -rte_errno; + } if (attr->group > MAX_GROUP) { rte_flow_error_set( error, EINVAL, RTE_FLOW_ERROR_TYPE_ATTR_GROUP, diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index 513734dce..ab2bf2dce 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -72,7 +72,26 @@ struct rte_flow_attr { uint32_t priority; /**< Priority level within group. */ uint32_t ingress:1; /**< Rule applies to ingress traffic. */ uint32_t egress:1; /**< Rule applies to egress traffic. */ - uint32_t reserved:30; /**< Reserved, must be zero. */ + /** + * Instead of simply matching the properties of traffic as it would + * appear on a given DPDK port ID, enabling this attribute transfers + * a flow rule to the lowest possible level of any device endpoints + * found in the pattern. + * + * When supported, this effectively enables an application to + * re-route traffic not necessarily intended for it (e.g. coming + * from or addressed to different physical ports, VFs or + * applications) at the device level. + * + * It complements the behavior of some pattern items such as + * RTE_FLOW_ITEM_TYPE_PORT and is meaningless without them. + * + * When transferring flow rules, ingress and egress attributes keep + * their original meaning, as if processing traffic emitted or + * received by the application. + */ + uint32_t transfer:1; + uint32_t reserved:29; /**< Reserved, must be zero. */ }; /** @@ -1181,6 +1200,7 @@ enum rte_flow_error_type { RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, /**< Priority field. */ RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, /**< Ingress field. */ RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, /**< Egress field. */ + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, /**< Transfer field. */ RTE_FLOW_ERROR_TYPE_ATTR, /**< Attributes structure. */ RTE_FLOW_ERROR_TYPE_ITEM_NUM, /**< Pattern length. */ RTE_FLOW_ERROR_TYPE_ITEM_SPEC, /**< Item specification. */ -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v4 13/16] ethdev: update behavior of VF/PF in flow API 2018-04-16 16:22 ` [dpdk-dev] [PATCH v4 00/16] Flow API overhaul for switch offloads Adrien Mazarguil ` (11 preceding siblings ...) 2018-04-16 16:22 ` [dpdk-dev] [PATCH v4 12/16] ethdev: add transfer attribute to " Adrien Mazarguil @ 2018-04-16 16:22 ` Adrien Mazarguil 2018-04-16 16:22 ` [dpdk-dev] [PATCH v4 14/16] ethdev: rename physical port item " Adrien Mazarguil ` (3 subsequent siblings) 16 siblings, 0 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-16 16:22 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev Cc: Ajit Khaparde, Somnath Kotur, Beilei Xing, Qi Zhang Contrary to all other pattern items, these are inconsistently documented as affecting traffic instead of simply matching its origin, without provision for the latter. This commit clarifies documentation and updates PMDs since the original behavior now has to be explicitly requested using the new transfer attribute. It breaks ABI compatibility for the following public functions: - rte_flow_create() - rte_flow_validate() Impacted PMDs are bnxt and i40e, for which the VF pattern item is now only supported when a transfer attribute is also present. Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Cc: Ajit Khaparde <ajit.khaparde@broadcom.com> Cc: Somnath Kotur <somnath.kotur@broadcom.com> Cc: Beilei Xing <beilei.xing@intel.com> Cc: Qi Zhang <qi.z.zhang@intel.com> --- app/test-pmd/cmdline_flow.c | 12 +++--- doc/guides/prog_guide/rte_flow.rst | 36 +++++++++--------- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 12 +++--- drivers/net/bnxt/bnxt_filter.c | 22 ++++++----- drivers/net/i40e/i40e_flow.c | 23 +++++++----- lib/librte_ether/rte_flow.h | 47 ++++++++++-------------- 6 files changed, 77 insertions(+), 75 deletions(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 1c6b5a112..41103de67 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -1041,21 +1041,21 @@ static const struct token token_list[] = { }, [ITEM_PF] = { .name = "pf", - .help = "match packets addressed to the physical function", + .help = "match traffic from/to the physical function", .priv = PRIV_ITEM(PF, 0), .next = NEXT(NEXT_ENTRY(ITEM_NEXT)), .call = parse_vc, }, [ITEM_VF] = { .name = "vf", - .help = "match packets addressed to a virtual function ID", + .help = "match traffic from/to a virtual function ID", .priv = PRIV_ITEM(VF, sizeof(struct rte_flow_item_vf)), .next = NEXT(item_vf), .call = parse_vc, }, [ITEM_VF_ID] = { .name = "id", - .help = "destination VF ID", + .help = "VF ID", .next = NEXT(item_vf, NEXT_ENTRY(UNSIGNED), item_param), .args = ARGS(ARGS_ENTRY(struct rte_flow_item_vf, id)), }, @@ -1686,14 +1686,14 @@ static const struct token token_list[] = { }, [ACTION_PF] = { .name = "pf", - .help = "redirect packets to physical device function", + .help = "direct traffic to physical function", .priv = PRIV_ACTION(PF, 0), .next = NEXT(NEXT_ENTRY(ACTION_NEXT)), .call = parse_vc, }, [ACTION_VF] = { .name = "vf", - .help = "redirect packets to virtual device function", + .help = "direct traffic to a virtual function ID", .priv = PRIV_ACTION(VF, sizeof(struct rte_flow_action_vf)), .next = NEXT(action_vf), .call = parse_vc, @@ -1708,7 +1708,7 @@ static const struct token token_list[] = { }, [ACTION_VF_ID] = { .name = "id", - .help = "VF ID to redirect packets to", + .help = "VF ID", .next = NEXT(action_vf, NEXT_ENTRY(UNSIGNED)), .args = ARGS(ARGS_ENTRY(struct rte_flow_action_vf, id)), .call = parse_vc_conf, diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 550a4c95b..a0a124aa2 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -528,15 +528,12 @@ Usage example, matching non-TCPv4 packets only: Item: ``PF`` ^^^^^^^^^^^^ -Matches packets addressed to the physical function of the device. +Matches traffic originating from (ingress) or going to (egress) the physical +function of the current device. -If the underlying device function differs from the one that would normally -receive the matched traffic, specifying this item prevents it from reaching -that device unless the flow rule contains a `Action: PF`_. Packets are not -duplicated between device instances by default. +If supported, should work even if the physical function is not managed by +the application and thus not associated with a DPDK port ID. -- Likely to return an error or never match any traffic if applied to a VF - device. - Can be combined with any number of `Item: VF`_ to match both PF and VF traffic. - ``spec``, ``last`` and ``mask`` must not be set. @@ -558,15 +555,15 @@ duplicated between device instances by default. Item: ``VF`` ^^^^^^^^^^^^ -Matches packets addressed to a virtual function ID of the device. +Matches traffic originating from (ingress) or going to (egress) a given +virtual function of the current device. -If the underlying device function differs from the one that would normally -receive the matched traffic, specifying this item prevents it from reaching -that device unless the flow rule contains a `Action: VF`_. Packets are not -duplicated between device instances by default. +If supported, should work even if the virtual function is not managed by the +application and thus not associated with a DPDK port ID. + +Note this pattern item does not match VF representors traffic which, as +separate entities, should be addressed through their own DPDK port IDs. -- Likely to return an error or never match any traffic if this causes a VF - device to match traffic addressed to a different VF. - Can be specified multiple times to match traffic addressed to several VF IDs. - Can be combined with a PF item to match both PF and VF traffic. @@ -1395,7 +1392,10 @@ only matching traffic goes through. Action: ``PF`` ^^^^^^^^^^^^^^ -Redirects packets to the physical function (PF) of the current device. +Directs matching traffic to the physical function (PF) of the current +device. + +See `Item: PF`_. - No configurable properties. @@ -1412,13 +1412,15 @@ Redirects packets to the physical function (PF) of the current device. Action: ``VF`` ^^^^^^^^^^^^^^ -Redirects packets to a virtual function (VF) of the current device. +Directs matching traffic to a given virtual function of the current device. Packets matched by a VF pattern item can be redirected to their original VF ID instead of the specified one. This parameter may not be available and is not guaranteed to work properly if the VF part is matched by a prior flow rule or if packets are not addressed to a VF in the first place. +See `Item: VF`_. + .. _table_rte_flow_action_vf: .. table:: VF @@ -1428,7 +1430,7 @@ rule or if packets are not addressed to a VF in the first place. +==============+================================+ | ``original`` | use original VF ID if possible | +--------------+--------------------------------+ - | ``vf`` | VF ID to redirect packets to | + | ``id`` | VF ID | +--------------+--------------------------------+ Action: ``METER`` diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index 0bf6c33c9..af37c3d82 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3202,11 +3202,11 @@ This section lists supported pattern items and their attributes, if any. - ``num {unsigned}``: number of layers covered. -- ``pf``: match packets addressed to the physical function. +- ``pf``: match traffic from/to the physical function. -- ``vf``: match packets addressed to a virtual function ID. +- ``vf``: match traffic from/to a virtual function ID. - - ``id {unsigned}``: destination VF ID. + - ``id {unsigned}``: VF ID. - ``port``: device-specific physical port index to use. @@ -3416,12 +3416,12 @@ This section lists supported actions and their attributes, if any. - ``queues [{unsigned} [...]] end``: queue indices to use. -- ``pf``: redirect packets to physical device function. +- ``pf``: direct traffic to physical function. -- ``vf``: redirect packets to virtual device function. +- ``vf``: direct traffic to a virtual function ID. - ``original {boolean}``: use original VF ID if possible. - - ``id {unsigned}``: VF ID to redirect packets to. + - ``id {unsigned}``: VF ID. Destroying flow rules ~~~~~~~~~~~~~~~~~~~~~ diff --git a/drivers/net/bnxt/bnxt_filter.c b/drivers/net/bnxt/bnxt_filter.c index bd166370a..f964b5ea4 100644 --- a/drivers/net/bnxt/bnxt_filter.c +++ b/drivers/net/bnxt/bnxt_filter.c @@ -275,6 +275,7 @@ bnxt_filter_type_check(const struct rte_flow_item pattern[], static int bnxt_validate_and_parse_flow_type(struct bnxt *bp, + const struct rte_flow_attr *attr, const struct rte_flow_item pattern[], struct rte_flow_error *error, struct bnxt_filter_info *filter) @@ -699,6 +700,16 @@ bnxt_validate_and_parse_flow_type(struct bnxt *bp, return -rte_errno; } + if (!attr->transfer) { + rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ITEM, + item, + "Matching VF traffic without" + " affecting it (transfer attribute)" + " is unsupported"); + return -rte_errno; + } + filter->mirror_vnic_id = dflt_vnic = bnxt_hwrm_func_qcfg_vf_dflt_vnic_id(bp, vf); if (dflt_vnic < 0) { @@ -746,14 +757,6 @@ bnxt_flow_parse_attr(const struct rte_flow_attr *attr, } /* Not supported */ - if (attr->transfer) { - rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, - attr, "No support for transfer."); - return -rte_errno; - } - - /* Not supported */ if (attr->priority) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, @@ -833,7 +836,8 @@ bnxt_validate_and_parse_flow(struct rte_eth_dev *dev, goto ret; } - rc = bnxt_validate_and_parse_flow_type(bp, pattern, error, filter); + rc = bnxt_validate_and_parse_flow_type(bp, attr, pattern, error, + filter); if (rc != 0) goto ret; diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c index f416b6a00..057e4f96d 100644 --- a/drivers/net/i40e/i40e_flow.c +++ b/drivers/net/i40e/i40e_flow.c @@ -54,6 +54,7 @@ static int i40e_flow_parse_ethertype_action(struct rte_eth_dev *dev, struct rte_flow_error *error, struct rte_eth_ethertype_filter *filter); static int i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev, + const struct rte_flow_attr *attr, const struct rte_flow_item *pattern, struct rte_flow_error *error, struct i40e_fdir_filter_conf *filter); @@ -1918,14 +1919,6 @@ i40e_flow_parse_attr(const struct rte_flow_attr *attr, } /* Not supported */ - if (attr->transfer) { - rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, - attr, "No support for transfer."); - return -rte_errno; - } - - /* Not supported */ if (attr->priority) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, @@ -2429,6 +2422,7 @@ i40e_flow_fdir_get_pctype_value(struct i40e_pf *pf, */ static int i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev, + const struct rte_flow_attr *attr, const struct rte_flow_item *pattern, struct rte_flow_error *error, struct i40e_fdir_filter_conf *filter) @@ -2966,6 +2960,16 @@ i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev, break; case RTE_FLOW_ITEM_TYPE_VF: vf_spec = item->spec; + if (!attr->transfer) { + rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ITEM, + item, + "Matching VF traffic" + " without affecting it" + " (transfer attribute)" + " is unsupported"); + return -rte_errno; + } filter->input.flow_ext.is_vf = 1; filter->input.flow_ext.dst_id = vf_spec->id; if (filter->input.flow_ext.is_vf && @@ -3128,7 +3132,8 @@ i40e_flow_parse_fdir_filter(struct rte_eth_dev *dev, &filter->fdir_filter; int ret; - ret = i40e_flow_parse_fdir_pattern(dev, pattern, error, fdir_filter); + ret = i40e_flow_parse_fdir_pattern(dev, attr, pattern, error, + fdir_filter); if (ret) return ret; diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index ab2bf2dce..f1c7a664e 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -152,13 +152,8 @@ enum rte_flow_item_type { /** * [META] * - * Matches packets addressed to the physical function of the device. - * - * If the underlying device function differs from the one that would - * normally receive the matched traffic, specifying this item - * prevents it from reaching that device unless the flow rule - * contains a PF action. Packets are not duplicated between device - * instances by default. + * Matches traffic originating from (ingress) or going to (egress) + * the physical function of the current device. * * No associated specification structure. */ @@ -167,13 +162,8 @@ enum rte_flow_item_type { /** * [META] * - * Matches packets addressed to a virtual function ID of the device. - * - * If the underlying device function differs from the one that would - * normally receive the matched traffic, specifying this item - * prevents it from reaching that device unless the flow rule - * contains a VF action. Packets are not duplicated between device - * instances by default. + * Matches traffic originating from (ingress) or going to (egress) a + * given virtual function of the current device. * * See struct rte_flow_item_vf. */ @@ -371,15 +361,15 @@ static const struct rte_flow_item_any rte_flow_item_any_mask = { /** * RTE_FLOW_ITEM_TYPE_VF * - * Matches packets addressed to a virtual function ID of the device. + * Matches traffic originating from (ingress) or going to (egress) a given + * virtual function of the current device. * - * If the underlying device function differs from the one that would - * normally receive the matched traffic, specifying this item prevents it - * from reaching that device unless the flow rule contains a VF - * action. Packets are not duplicated between device instances by default. + * If supported, should work even if the virtual function is not managed by + * the application and thus not associated with a DPDK port ID. + * + * Note this pattern item does not match VF representors traffic which, as + * separate entities, should be addressed through their own DPDK port IDs. * - * - Likely to return an error or never match any traffic if this causes a - * VF device to match traffic addressed to a different VF. * - Can be specified multiple times to match traffic addressed to several * VF IDs. * - Can be combined with a PF item to match both PF and VF traffic. @@ -387,7 +377,7 @@ static const struct rte_flow_item_any rte_flow_item_any_mask = { * A zeroed mask can be used to match any VF ID. */ struct rte_flow_item_vf { - uint32_t id; /**< Destination VF ID. */ + uint32_t id; /**< VF ID. */ }; /** Default mask for RTE_FLOW_ITEM_TYPE_VF. */ @@ -988,16 +978,16 @@ enum rte_flow_action_type { RTE_FLOW_ACTION_TYPE_RSS, /** - * Redirects packets to the physical function (PF) of the current - * device. + * Directs matching traffic to the physical function (PF) of the + * current device. * * No associated configuration structure. */ RTE_FLOW_ACTION_TYPE_PF, /** - * Redirects packets to the virtual function (VF) of the current - * device with the specified ID. + * Directs matching traffic to a given virtual function of the + * current device. * * See struct rte_flow_action_vf. */ @@ -1111,7 +1101,8 @@ struct rte_flow_action_rss { /** * RTE_FLOW_ACTION_TYPE_VF * - * Redirects packets to a virtual function (VF) of the current device. + * Directs matching traffic to a given virtual function of the current + * device. * * Packets matched by a VF pattern item can be redirected to their original * VF ID instead of the specified one. This parameter may not be available @@ -1122,7 +1113,7 @@ struct rte_flow_action_rss { struct rte_flow_action_vf { uint32_t original:1; /**< Use original VF ID if possible. */ uint32_t reserved:31; /**< Reserved, must be zero. */ - uint32_t id; /**< VF ID to redirect packets to. */ + uint32_t id; /**< VF ID. */ }; /** -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v4 14/16] ethdev: rename physical port item in flow API 2018-04-16 16:22 ` [dpdk-dev] [PATCH v4 00/16] Flow API overhaul for switch offloads Adrien Mazarguil ` (12 preceding siblings ...) 2018-04-16 16:22 ` [dpdk-dev] [PATCH v4 13/16] ethdev: update behavior of VF/PF in " Adrien Mazarguil @ 2018-04-16 16:22 ` Adrien Mazarguil 2018-04-16 16:22 ` [dpdk-dev] [PATCH v4 15/16] ethdev: add physical port action to " Adrien Mazarguil ` (2 subsequent siblings) 16 siblings, 0 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-16 16:22 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev While RTE_FLOW_ITEM_TYPE_PORT refers to physical ports of the underlying device using specific identifiers, these are often confused with DPDK port IDs exposed to applications in the global name space. Since this pattern item is seldom used, rename it RTE_FLOW_ITEM_PHY_PORT for better clarity. No ABI impact. Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Acked-by: Andrew Rybchenko <arybchenko@solarflare.com> --- app/test-pmd/cmdline_flow.c | 27 +++++++++++---------- app/test-pmd/config.c | 2 +- doc/guides/prog_guide/rte_flow.rst | 22 ++++++++--------- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 2 +- lib/librte_ether/rte_flow.c | 2 +- lib/librte_ether/rte_flow.h | 31 ++++++++++-------------- 6 files changed, 41 insertions(+), 45 deletions(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 41103de67..f9f937277 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -87,8 +87,8 @@ enum index { ITEM_PF, ITEM_VF, ITEM_VF_ID, - ITEM_PORT, - ITEM_PORT_INDEX, + ITEM_PHY_PORT, + ITEM_PHY_PORT_INDEX, ITEM_RAW, ITEM_RAW_RELATIVE, ITEM_RAW_SEARCH, @@ -441,7 +441,7 @@ static const enum index next_item[] = { ITEM_ANY, ITEM_PF, ITEM_VF, - ITEM_PORT, + ITEM_PHY_PORT, ITEM_RAW, ITEM_ETH, ITEM_VLAN, @@ -482,8 +482,8 @@ static const enum index item_vf[] = { ZERO, }; -static const enum index item_port[] = { - ITEM_PORT_INDEX, +static const enum index item_phy_port[] = { + ITEM_PHY_PORT_INDEX, ITEM_NEXT, ZERO, }; @@ -1059,18 +1059,19 @@ static const struct token token_list[] = { .next = NEXT(item_vf, NEXT_ENTRY(UNSIGNED), item_param), .args = ARGS(ARGS_ENTRY(struct rte_flow_item_vf, id)), }, - [ITEM_PORT] = { - .name = "port", - .help = "device-specific physical port index to use", - .priv = PRIV_ITEM(PORT, sizeof(struct rte_flow_item_port)), - .next = NEXT(item_port), + [ITEM_PHY_PORT] = { + .name = "phy_port", + .help = "match traffic from/to a specific physical port", + .priv = PRIV_ITEM(PHY_PORT, + sizeof(struct rte_flow_item_phy_port)), + .next = NEXT(item_phy_port), .call = parse_vc, }, - [ITEM_PORT_INDEX] = { + [ITEM_PHY_PORT_INDEX] = { .name = "index", .help = "physical port index", - .next = NEXT(item_port, NEXT_ENTRY(UNSIGNED), item_param), - .args = ARGS(ARGS_ENTRY(struct rte_flow_item_port, index)), + .next = NEXT(item_phy_port, NEXT_ENTRY(UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_phy_port, index)), }, [ITEM_RAW] = { .name = "raw", diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index a50a5c544..840320108 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -976,7 +976,7 @@ static const struct { MK_FLOW_ITEM(ANY, sizeof(struct rte_flow_item_any)), MK_FLOW_ITEM(PF, 0), MK_FLOW_ITEM(VF, sizeof(struct rte_flow_item_vf)), - MK_FLOW_ITEM(PORT, sizeof(struct rte_flow_item_port)), + MK_FLOW_ITEM(PHY_PORT, sizeof(struct rte_flow_item_phy_port)), MK_FLOW_ITEM(RAW, sizeof(struct rte_flow_item_raw)), MK_FLOW_ITEM(ETH, sizeof(struct rte_flow_item_eth)), MK_FLOW_ITEM(VLAN, sizeof(struct rte_flow_item_vlan)), diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index a0a124aa2..4e053c24b 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -195,8 +195,8 @@ When supported, this effectively enables an application to reroute traffic not necessarily intended for it (e.g. coming from or addressed to different physical ports, VFs or applications) at the device level. -It complements the behavior of some pattern items such as `Item: PORT`_ and -is meaningless without them. +It complements the behavior of some pattern items such as `Item: PHY_PORT`_ +and is meaningless without them. When transferring flow rules, **ingress** and **egress** attributes (`Attribute: Traffic direction`_) keep their original meaning, as if @@ -583,15 +583,15 @@ separate entities, should be addressed through their own DPDK port IDs. | ``mask`` | ``id`` | zeroed to match any VF ID | +----------+----------+---------------------------+ -Item: ``PORT`` -^^^^^^^^^^^^^^ +Item: ``PHY_PORT`` +^^^^^^^^^^^^^^^^^^ -Matches packets coming from the specified physical port of the underlying -device. +Matches traffic originating from (ingress) or going to (egress) a physical +port of the underlying device. -The first PORT item overrides the physical port normally associated with the -specified DPDK input port (port_id). This item can be provided several times -to match additional physical ports. +The first PHY_PORT item overrides the physical port normally associated with +the specified DPDK input port (port_id). This item can be provided several +times to match additional physical ports. Note that physical ports are not necessarily tied to DPDK input ports (port_id) when those are not under DPDK control. Possible values are @@ -603,9 +603,9 @@ associated with a port_id should be retrieved by other means. - Default ``mask`` matches any port index. -.. _table_rte_flow_item_port: +.. _table_rte_flow_item_phy_port: -.. table:: PORT +.. table:: PHY_PORT +----------+-----------+--------------------------------+ | Field | Subfield | Value | diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index af37c3d82..a2bbd1930 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3208,7 +3208,7 @@ This section lists supported pattern items and their attributes, if any. - ``id {unsigned}``: VF ID. -- ``port``: device-specific physical port index to use. +- ``phy_port``: match traffic from/to a specific physical port. - ``index {unsigned}``: physical port index. diff --git a/lib/librte_ether/rte_flow.c b/lib/librte_ether/rte_flow.c index 83b733ff0..36e277a4f 100644 --- a/lib/librte_ether/rte_flow.c +++ b/lib/librte_ether/rte_flow.c @@ -38,7 +38,7 @@ static const struct rte_flow_desc_data rte_flow_desc_item[] = { MK_FLOW_ITEM(ANY, sizeof(struct rte_flow_item_any)), MK_FLOW_ITEM(PF, 0), MK_FLOW_ITEM(VF, sizeof(struct rte_flow_item_vf)), - MK_FLOW_ITEM(PORT, sizeof(struct rte_flow_item_port)), + MK_FLOW_ITEM(PHY_PORT, sizeof(struct rte_flow_item_phy_port)), MK_FLOW_ITEM(RAW, sizeof(struct rte_flow_item_raw)), MK_FLOW_ITEM(ETH, sizeof(struct rte_flow_item_eth)), MK_FLOW_ITEM(VLAN, sizeof(struct rte_flow_item_vlan)), diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index f1c7a664e..2c7c4d009 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -84,7 +84,7 @@ struct rte_flow_attr { * applications) at the device level. * * It complements the behavior of some pattern items such as - * RTE_FLOW_ITEM_TYPE_PORT and is meaningless without them. + * RTE_FLOW_ITEM_TYPE_PHY_PORT and is meaningless without them. * * When transferring flow rules, ingress and egress attributes keep * their original meaning, as if processing traffic emitted or @@ -172,17 +172,12 @@ enum rte_flow_item_type { /** * [META] * - * Matches packets coming from the specified physical port of the - * underlying device. - * - * The first PORT item overrides the physical port normally - * associated with the specified DPDK input port (port_id). This - * item can be provided several times to match additional physical - * ports. + * Matches traffic originating from (ingress) or going to (egress) a + * physical port of the underlying device. * - * See struct rte_flow_item_port. + * See struct rte_flow_item_phy_port. */ - RTE_FLOW_ITEM_TYPE_PORT, + RTE_FLOW_ITEM_TYPE_PHY_PORT, /** * Matches a byte string of a given length at a given offset. @@ -388,13 +383,13 @@ static const struct rte_flow_item_vf rte_flow_item_vf_mask = { #endif /** - * RTE_FLOW_ITEM_TYPE_PORT + * RTE_FLOW_ITEM_TYPE_PHY_PORT * - * Matches packets coming from the specified physical port of the underlying - * device. + * Matches traffic originating from (ingress) or going to (egress) a + * physical port of the underlying device. * - * The first PORT item overrides the physical port normally associated with - * the specified DPDK input port (port_id). This item can be provided + * The first PHY_PORT item overrides the physical port normally associated + * with the specified DPDK input port (port_id). This item can be provided * several times to match additional physical ports. * * Note that physical ports are not necessarily tied to DPDK input ports @@ -407,13 +402,13 @@ static const struct rte_flow_item_vf rte_flow_item_vf_mask = { * * A zeroed mask can be used to match any port index. */ -struct rte_flow_item_port { +struct rte_flow_item_phy_port { uint32_t index; /**< Physical port index. */ }; -/** Default mask for RTE_FLOW_ITEM_TYPE_PORT. */ +/** Default mask for RTE_FLOW_ITEM_TYPE_PHY_PORT. */ #ifndef __cplusplus -static const struct rte_flow_item_port rte_flow_item_port_mask = { +static const struct rte_flow_item_phy_port rte_flow_item_phy_port_mask = { .index = 0x00000000, }; #endif -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v4 15/16] ethdev: add physical port action to flow API 2018-04-16 16:22 ` [dpdk-dev] [PATCH v4 00/16] Flow API overhaul for switch offloads Adrien Mazarguil ` (13 preceding siblings ...) 2018-04-16 16:22 ` [dpdk-dev] [PATCH v4 14/16] ethdev: rename physical port item " Adrien Mazarguil @ 2018-04-16 16:22 ` Adrien Mazarguil 2018-04-17 9:08 ` Mohammad Abdul Awal 2018-04-16 16:23 ` [dpdk-dev] [PATCH v4 16/16] ethdev: add port ID item and " Adrien Mazarguil 2018-04-19 10:16 ` [dpdk-dev] [PATCH v5 00/16] Flow API overhaul for switch offloads Adrien Mazarguil 16 siblings, 1 reply; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-16 16:22 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev; +Cc: Zhang, Qi Z This patch adds the missing action counterpart to the PHY_PORT pattern item, that is, the ability to directly inject matching traffic into a physical port of the underlying device. It breaks ABI compatibility for the following public functions: - rte_flow_copy() - rte_flow_create() - rte_flow_query() - rte_flow_validate() Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Acked-by: Andrew Rybchenko <arybchenko@solarflare.com> Cc: "Zhang, Qi Z" <qi.z.zhang@intel.com> --- app/test-pmd/cmdline_flow.c | 35 ++++++++++++++++++++++++ app/test-pmd/config.c | 1 + doc/guides/prog_guide/rte_flow.rst | 20 ++++++++++++++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 5 ++++ lib/librte_ether/rte_flow.c | 1 + lib/librte_ether/rte_flow.h | 22 +++++++++++++++ 6 files changed, 84 insertions(+) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index f9f937277..356714801 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -182,6 +182,9 @@ enum index { ACTION_VF, ACTION_VF_ORIGINAL, ACTION_VF_ID, + ACTION_PHY_PORT, + ACTION_PHY_PORT_ORIGINAL, + ACTION_PHY_PORT_INDEX, ACTION_METER, ACTION_METER_ID, }; @@ -623,6 +626,7 @@ static const enum index next_action[] = { ACTION_RSS, ACTION_PF, ACTION_VF, + ACTION_PHY_PORT, ACTION_METER, ZERO, }; @@ -657,6 +661,13 @@ static const enum index action_vf[] = { ZERO, }; +static const enum index action_phy_port[] = { + ACTION_PHY_PORT_ORIGINAL, + ACTION_PHY_PORT_INDEX, + ACTION_NEXT, + ZERO, +}; + static const enum index action_meter[] = { ACTION_METER_ID, ACTION_NEXT, @@ -1714,6 +1725,30 @@ static const struct token token_list[] = { .args = ARGS(ARGS_ENTRY(struct rte_flow_action_vf, id)), .call = parse_vc_conf, }, + [ACTION_PHY_PORT] = { + .name = "phy_port", + .help = "direct packets to physical port index", + .priv = PRIV_ACTION(PHY_PORT, + sizeof(struct rte_flow_action_phy_port)), + .next = NEXT(action_phy_port), + .call = parse_vc, + }, + [ACTION_PHY_PORT_ORIGINAL] = { + .name = "original", + .help = "use original port index if possible", + .next = NEXT(action_phy_port, NEXT_ENTRY(BOOLEAN)), + .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_phy_port, + original, 1)), + .call = parse_vc_conf, + }, + [ACTION_PHY_PORT_INDEX] = { + .name = "index", + .help = "physical port index", + .next = NEXT(action_phy_port, NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_phy_port, + index)), + .call = parse_vc_conf, + }, [ACTION_METER] = { .name = "meter", .help = "meter the directed packets at given id", diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 840320108..2d68f1fb0 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -1074,6 +1074,7 @@ static const struct { MK_FLOW_ACTION(RSS, sizeof(struct rte_flow_action_rss)), MK_FLOW_ACTION(PF, 0), MK_FLOW_ACTION(VF, sizeof(struct rte_flow_action_vf)), + MK_FLOW_ACTION(PHY_PORT, sizeof(struct rte_flow_action_phy_port)), MK_FLOW_ACTION(METER, sizeof(struct rte_flow_action_meter)), }; diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 4e053c24b..a39c1e1b0 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -1433,6 +1433,26 @@ See `Item: VF`_. | ``id`` | VF ID | +--------------+--------------------------------+ +Action: ``PHY_PORT`` +^^^^^^^^^^^^^^^^^^^^ + +Directs matching traffic to a given physical port index of the underlying +device. + +See `Item: PHY_PORT`_. + +.. _table_rte_flow_action_phy_port: + +.. table:: PHY_PORT + + +--------------+-------------------------------------+ + | Field | Value | + +==============+=====================================+ + | ``original`` | use original port index if possible | + +--------------+-------------------------------------+ + | ``index`` | physical port index | + +--------------+-------------------------------------+ + Action: ``METER`` ^^^^^^^^^^^^^^^^^ diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index a2bbd1930..64d8dfddb 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3423,6 +3423,11 @@ This section lists supported actions and their attributes, if any. - ``original {boolean}``: use original VF ID if possible. - ``id {unsigned}``: VF ID. +- ``phy_port``: direct packets to physical port index. + + - ``original {boolean}``: use original port index if possible. + - ``index {unsigned}``: physical port index. + Destroying flow rules ~~~~~~~~~~~~~~~~~~~~~ diff --git a/lib/librte_ether/rte_flow.c b/lib/librte_ether/rte_flow.c index 36e277a4f..00989c73b 100644 --- a/lib/librte_ether/rte_flow.c +++ b/lib/librte_ether/rte_flow.c @@ -76,6 +76,7 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = { MK_FLOW_ACTION(RSS, sizeof(struct rte_flow_action_rss)), MK_FLOW_ACTION(PF, 0), MK_FLOW_ACTION(VF, sizeof(struct rte_flow_action_vf)), + MK_FLOW_ACTION(PHY_PORT, sizeof(struct rte_flow_action_phy_port)), }; static int diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index 2c7c4d009..58b75e934 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -989,6 +989,14 @@ enum rte_flow_action_type { RTE_FLOW_ACTION_TYPE_VF, /** + * Directs packets to a given physical port index of the underlying + * device. + * + * See struct rte_flow_action_phy_port. + */ + RTE_FLOW_ACTION_TYPE_PHY_PORT, + + /** * Traffic metering and policing (MTR). * * See struct rte_flow_action_meter. @@ -1112,6 +1120,20 @@ struct rte_flow_action_vf { }; /** + * RTE_FLOW_ACTION_TYPE_PHY_PORT + * + * Directs packets to a given physical port index of the underlying + * device. + * + * @see RTE_FLOW_ITEM_TYPE_PHY_PORT + */ +struct rte_flow_action_phy_port { + uint32_t original:1; /**< Use original port index if possible. */ + uint32_t reserved:31; /**< Reserved, must be zero. */ + uint32_t index; /**< Physical port index. */ +}; + +/** * RTE_FLOW_ACTION_TYPE_METER * * Traffic metering and policing (MTR). -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [dpdk-dev] [PATCH v4 15/16] ethdev: add physical port action to flow API 2018-04-16 16:22 ` [dpdk-dev] [PATCH v4 15/16] ethdev: add physical port action to " Adrien Mazarguil @ 2018-04-17 9:08 ` Mohammad Abdul Awal 0 siblings, 0 replies; 157+ messages in thread From: Mohammad Abdul Awal @ 2018-04-17 9:08 UTC (permalink / raw) To: Adrien Mazarguil, Thomas Monjalon, Ferruh Yigit, dev; +Cc: Zhang, Qi Z On 16/04/2018 17:22, Adrien Mazarguil wrote: > This patch adds the missing action counterpart to the PHY_PORT pattern > item, that is, the ability to directly inject matching traffic into a > physical port of the underlying device. > > It breaks ABI compatibility for the following public functions: > > - rte_flow_copy() > - rte_flow_create() > - rte_flow_query() > - rte_flow_validate() > > Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> > Acked-by: Andrew Rybchenko <arybchenko@solarflare.com> > Cc: "Zhang, Qi Z" <qi.z.zhang@intel.com> Acked-by: Mohammad Abdul Awal <mohammad.abdul.awal@intel.com> > --- > app/test-pmd/cmdline_flow.c | 35 ++++++++++++++++++++++++ > app/test-pmd/config.c | 1 + > doc/guides/prog_guide/rte_flow.rst | 20 ++++++++++++++ > doc/guides/testpmd_app_ug/testpmd_funcs.rst | 5 ++++ > lib/librte_ether/rte_flow.c | 1 + > lib/librte_ether/rte_flow.h | 22 +++++++++++++++ > 6 files changed, 84 insertions(+) > > diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c > index f9f937277..356714801 100644 > --- a/app/test-pmd/cmdline_flow.c > +++ b/app/test-pmd/cmdline_flow.c > @@ -182,6 +182,9 @@ enum index { > ACTION_VF, > ACTION_VF_ORIGINAL, > ACTION_VF_ID, > + ACTION_PHY_PORT, > + ACTION_PHY_PORT_ORIGINAL, > + ACTION_PHY_PORT_INDEX, > ACTION_METER, > ACTION_METER_ID, > }; > @@ -623,6 +626,7 @@ static const enum index next_action[] = { > ACTION_RSS, > ACTION_PF, > ACTION_VF, > + ACTION_PHY_PORT, > ACTION_METER, > ZERO, > }; > @@ -657,6 +661,13 @@ static const enum index action_vf[] = { > ZERO, > }; > > +static const enum index action_phy_port[] = { > + ACTION_PHY_PORT_ORIGINAL, > + ACTION_PHY_PORT_INDEX, > + ACTION_NEXT, > + ZERO, > +}; > + > static const enum index action_meter[] = { > ACTION_METER_ID, > ACTION_NEXT, > @@ -1714,6 +1725,30 @@ static const struct token token_list[] = { > .args = ARGS(ARGS_ENTRY(struct rte_flow_action_vf, id)), > .call = parse_vc_conf, > }, > + [ACTION_PHY_PORT] = { > + .name = "phy_port", > + .help = "direct packets to physical port index", > + .priv = PRIV_ACTION(PHY_PORT, > + sizeof(struct rte_flow_action_phy_port)), > + .next = NEXT(action_phy_port), > + .call = parse_vc, > + }, > + [ACTION_PHY_PORT_ORIGINAL] = { > + .name = "original", > + .help = "use original port index if possible", > + .next = NEXT(action_phy_port, NEXT_ENTRY(BOOLEAN)), > + .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_phy_port, > + original, 1)), > + .call = parse_vc_conf, > + }, > + [ACTION_PHY_PORT_INDEX] = { > + .name = "index", > + .help = "physical port index", > + .next = NEXT(action_phy_port, NEXT_ENTRY(UNSIGNED)), > + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_phy_port, > + index)), > + .call = parse_vc_conf, > + }, > [ACTION_METER] = { > .name = "meter", > .help = "meter the directed packets at given id", > diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c > index 840320108..2d68f1fb0 100644 > --- a/app/test-pmd/config.c > +++ b/app/test-pmd/config.c > @@ -1074,6 +1074,7 @@ static const struct { > MK_FLOW_ACTION(RSS, sizeof(struct rte_flow_action_rss)), > MK_FLOW_ACTION(PF, 0), > MK_FLOW_ACTION(VF, sizeof(struct rte_flow_action_vf)), > + MK_FLOW_ACTION(PHY_PORT, sizeof(struct rte_flow_action_phy_port)), > MK_FLOW_ACTION(METER, sizeof(struct rte_flow_action_meter)), > }; > > diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst > index 4e053c24b..a39c1e1b0 100644 > --- a/doc/guides/prog_guide/rte_flow.rst > +++ b/doc/guides/prog_guide/rte_flow.rst > @@ -1433,6 +1433,26 @@ See `Item: VF`_. > | ``id`` | VF ID | > +--------------+--------------------------------+ > > +Action: ``PHY_PORT`` > +^^^^^^^^^^^^^^^^^^^^ > + > +Directs matching traffic to a given physical port index of the underlying > +device. > + > +See `Item: PHY_PORT`_. > + > +.. _table_rte_flow_action_phy_port: > + > +.. table:: PHY_PORT > + > + +--------------+-------------------------------------+ > + | Field | Value | > + +==============+=====================================+ > + | ``original`` | use original port index if possible | > + +--------------+-------------------------------------+ > + | ``index`` | physical port index | > + +--------------+-------------------------------------+ > + > Action: ``METER`` > ^^^^^^^^^^^^^^^^^ > > diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst > index a2bbd1930..64d8dfddb 100644 > --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst > +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst > @@ -3423,6 +3423,11 @@ This section lists supported actions and their attributes, if any. > - ``original {boolean}``: use original VF ID if possible. > - ``id {unsigned}``: VF ID. > > +- ``phy_port``: direct packets to physical port index. > + > + - ``original {boolean}``: use original port index if possible. > + - ``index {unsigned}``: physical port index. > + > Destroying flow rules > ~~~~~~~~~~~~~~~~~~~~~ > > diff --git a/lib/librte_ether/rte_flow.c b/lib/librte_ether/rte_flow.c > index 36e277a4f..00989c73b 100644 > --- a/lib/librte_ether/rte_flow.c > +++ b/lib/librte_ether/rte_flow.c > @@ -76,6 +76,7 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = { > MK_FLOW_ACTION(RSS, sizeof(struct rte_flow_action_rss)), > MK_FLOW_ACTION(PF, 0), > MK_FLOW_ACTION(VF, sizeof(struct rte_flow_action_vf)), > + MK_FLOW_ACTION(PHY_PORT, sizeof(struct rte_flow_action_phy_port)), > }; > > static int > diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h > index 2c7c4d009..58b75e934 100644 > --- a/lib/librte_ether/rte_flow.h > +++ b/lib/librte_ether/rte_flow.h > @@ -989,6 +989,14 @@ enum rte_flow_action_type { > RTE_FLOW_ACTION_TYPE_VF, > > /** > + * Directs packets to a given physical port index of the underlying > + * device. > + * > + * See struct rte_flow_action_phy_port. > + */ > + RTE_FLOW_ACTION_TYPE_PHY_PORT, > + > + /** > * Traffic metering and policing (MTR). > * > * See struct rte_flow_action_meter. > @@ -1112,6 +1120,20 @@ struct rte_flow_action_vf { > }; > > /** > + * RTE_FLOW_ACTION_TYPE_PHY_PORT > + * > + * Directs packets to a given physical port index of the underlying > + * device. > + * > + * @see RTE_FLOW_ITEM_TYPE_PHY_PORT > + */ > +struct rte_flow_action_phy_port { > + uint32_t original:1; /**< Use original port index if possible. */ > + uint32_t reserved:31; /**< Reserved, must be zero. */ > + uint32_t index; /**< Physical port index. */ > +}; > + > +/** > * RTE_FLOW_ACTION_TYPE_METER > * > * Traffic metering and policing (MTR). ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v4 16/16] ethdev: add port ID item and action to flow API 2018-04-16 16:22 ` [dpdk-dev] [PATCH v4 00/16] Flow API overhaul for switch offloads Adrien Mazarguil ` (14 preceding siblings ...) 2018-04-16 16:22 ` [dpdk-dev] [PATCH v4 15/16] ethdev: add physical port action to " Adrien Mazarguil @ 2018-04-16 16:23 ` Adrien Mazarguil 2018-04-19 10:16 ` [dpdk-dev] [PATCH v5 00/16] Flow API overhaul for switch offloads Adrien Mazarguil 16 siblings, 0 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-16 16:23 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev; +Cc: Zhang, Qi Z, Declan Doherty RTE_FLOW_ACTION_TYPE_PORT_ID brings the ability to inject matching traffic into a different device, as identified by its DPDK port ID. This is normally only supported when the target port ID has some kind of relationship with the port ID the flow rule is created against, such as being exposed by a common physical device (e.g. a different port of an Ethernet switch). The converse pattern item, RTE_FLOW_ITEM_TYPE_PORT_ID, makes the resulting flow rule match traffic whose origin is the specified port ID. Note that specifying a port ID that differs from the one the flow rule is created against is normally meaningless (if even accepted), but can make sense if combined with the transfer attribute. These must not be confused with their PHY_PORT counterparts, which refer to physical ports using device-specific indices, but unlike PORT_ID are not necessarily tied to DPDK port IDs. This breaks ABI compatibility for the following public functions: - rte_flow_copy() - rte_flow_create() - rte_flow_query() - rte_flow_validate() Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Reviewed-by: Qi Zhang <qi.z.zhang@intel.com> Acked-by: Andrew Rybchenko <arybchenko@solarflare.com> Cc: "Zhang, Qi Z" <qi.z.zhang@intel.com> Cc: Declan Doherty <declan.doherty@intel.com> --- This patch provides the same functionality and supersedes Qi Zhang's "ether: add flow action to redirect packet to a port" [1]. The main differences are: - Action is named PORT_ID instead of PORT. - Addition of a PORT_ID pattern item. - More extensive documentation. - Testpmd support. - rte_flow_copy() support. [1] http://dpdk.org/ml/archives/dev/2018-April/094648.html --- app/test-pmd/cmdline_flow.c | 57 ++++++++++++++++++++++++ app/test-pmd/config.c | 2 + doc/guides/prog_guide/rte_flow.rst | 48 ++++++++++++++++++++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 9 ++++ lib/librte_ether/rte_flow.c | 2 + lib/librte_ether/rte_flow.h | 56 +++++++++++++++++++++++ 6 files changed, 174 insertions(+) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 356714801..32fe6645a 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -89,6 +89,8 @@ enum index { ITEM_VF_ID, ITEM_PHY_PORT, ITEM_PHY_PORT_INDEX, + ITEM_PORT_ID, + ITEM_PORT_ID_ID, ITEM_RAW, ITEM_RAW_RELATIVE, ITEM_RAW_SEARCH, @@ -185,6 +187,9 @@ enum index { ACTION_PHY_PORT, ACTION_PHY_PORT_ORIGINAL, ACTION_PHY_PORT_INDEX, + ACTION_PORT_ID, + ACTION_PORT_ID_ORIGINAL, + ACTION_PORT_ID_ID, ACTION_METER, ACTION_METER_ID, }; @@ -445,6 +450,7 @@ static const enum index next_item[] = { ITEM_PF, ITEM_VF, ITEM_PHY_PORT, + ITEM_PORT_ID, ITEM_RAW, ITEM_ETH, ITEM_VLAN, @@ -491,6 +497,12 @@ static const enum index item_phy_port[] = { ZERO, }; +static const enum index item_port_id[] = { + ITEM_PORT_ID_ID, + ITEM_NEXT, + ZERO, +}; + static const enum index item_raw[] = { ITEM_RAW_RELATIVE, ITEM_RAW_SEARCH, @@ -627,6 +639,7 @@ static const enum index next_action[] = { ACTION_PF, ACTION_VF, ACTION_PHY_PORT, + ACTION_PORT_ID, ACTION_METER, ZERO, }; @@ -668,6 +681,13 @@ static const enum index action_phy_port[] = { ZERO, }; +static const enum index action_port_id[] = { + ACTION_PORT_ID_ORIGINAL, + ACTION_PORT_ID_ID, + ACTION_NEXT, + ZERO, +}; + static const enum index action_meter[] = { ACTION_METER_ID, ACTION_NEXT, @@ -1084,6 +1104,20 @@ static const struct token token_list[] = { .next = NEXT(item_phy_port, NEXT_ENTRY(UNSIGNED), item_param), .args = ARGS(ARGS_ENTRY(struct rte_flow_item_phy_port, index)), }, + [ITEM_PORT_ID] = { + .name = "port_id", + .help = "match traffic from/to a given DPDK port ID", + .priv = PRIV_ITEM(PORT_ID, + sizeof(struct rte_flow_item_port_id)), + .next = NEXT(item_port_id), + .call = parse_vc, + }, + [ITEM_PORT_ID_ID] = { + .name = "id", + .help = "DPDK port ID", + .next = NEXT(item_port_id, NEXT_ENTRY(UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_port_id, id)), + }, [ITEM_RAW] = { .name = "raw", .help = "match an arbitrary byte string", @@ -1749,6 +1783,29 @@ static const struct token token_list[] = { index)), .call = parse_vc_conf, }, + [ACTION_PORT_ID] = { + .name = "port_id", + .help = "direct matching traffic to a given DPDK port ID", + .priv = PRIV_ACTION(PORT_ID, + sizeof(struct rte_flow_action_port_id)), + .next = NEXT(action_port_id), + .call = parse_vc, + }, + [ACTION_PORT_ID_ORIGINAL] = { + .name = "original", + .help = "use original DPDK port ID if possible", + .next = NEXT(action_port_id, NEXT_ENTRY(BOOLEAN)), + .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_port_id, + original, 1)), + .call = parse_vc_conf, + }, + [ACTION_PORT_ID_ID] = { + .name = "id", + .help = "DPDK port ID", + .next = NEXT(action_port_id, NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_port_id, id)), + .call = parse_vc_conf, + }, [ACTION_METER] = { .name = "meter", .help = "meter the directed packets at given id", diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 2d68f1fb0..e7026011b 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -977,6 +977,7 @@ static const struct { MK_FLOW_ITEM(PF, 0), MK_FLOW_ITEM(VF, sizeof(struct rte_flow_item_vf)), MK_FLOW_ITEM(PHY_PORT, sizeof(struct rte_flow_item_phy_port)), + MK_FLOW_ITEM(PORT_ID, sizeof(struct rte_flow_item_port_id)), MK_FLOW_ITEM(RAW, sizeof(struct rte_flow_item_raw)), MK_FLOW_ITEM(ETH, sizeof(struct rte_flow_item_eth)), MK_FLOW_ITEM(VLAN, sizeof(struct rte_flow_item_vlan)), @@ -1075,6 +1076,7 @@ static const struct { MK_FLOW_ACTION(PF, 0), MK_FLOW_ACTION(VF, sizeof(struct rte_flow_action_vf)), MK_FLOW_ACTION(PHY_PORT, sizeof(struct rte_flow_action_phy_port)), + MK_FLOW_ACTION(PORT_ID, sizeof(struct rte_flow_action_port_id)), MK_FLOW_ACTION(METER, sizeof(struct rte_flow_action_meter)), }; diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index a39c1e1b0..2fb8e9c3f 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -617,6 +617,36 @@ associated with a port_id should be retrieved by other means. | ``mask`` | ``index`` | zeroed to match any port index | +----------+-----------+--------------------------------+ +Item: ``PORT_ID`` +^^^^^^^^^^^^^^^^^ + +Matches traffic originating from (ingress) or going to (egress) a given DPDK +port ID. + +Normally only supported if the port ID in question is known by the +underlying PMD and related to the device the flow rule is created against. + +This must not be confused with `Item: PHY_PORT`_ which refers to the +physical port of a device, whereas `Item: PORT_ID`_ refers to a ``struct +rte_eth_dev`` object on the application side (also known as "port +representor" depending on the kind of underlying device). + +- Default ``mask`` matches the specified DPDK port ID. + +.. _table_rte_flow_item_port_id: + +.. table:: PORT_ID + + +----------+----------+-----------------------------+ + | Field | Subfield | Value | + +==========+==========+=============================+ + | ``spec`` | ``id`` | DPDK port ID | + +----------+----------+-----------------------------+ + | ``last`` | ``id`` | upper range value | + +----------+----------+-----------------------------+ + | ``mask`` | ``id`` | zeroed to match any port ID | + +----------+----------+-----------------------------+ + Data matching item types ~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1453,6 +1483,24 @@ See `Item: PHY_PORT`_. | ``index`` | physical port index | +--------------+-------------------------------------+ +Action: ``PORT_ID`` +^^^^^^^^^^^^^^^^^^^ +Directs matching traffic to a given DPDK port ID. + +See `Item: PORT_ID`_. + +.. _table_rte_flow_action_port_id: + +.. table:: PORT_ID + + +--------------+---------------------------------------+ + | Field | Value | + +==============+=======================================+ + | ``original`` | use original DPDK port ID if possible | + +--------------+---------------------------------------+ + | ``id`` | DPDK port ID | + +--------------+---------------------------------------+ + Action: ``METER`` ^^^^^^^^^^^^^^^^^ diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index 64d8dfddb..bfb5ad027 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3212,6 +3212,10 @@ This section lists supported pattern items and their attributes, if any. - ``index {unsigned}``: physical port index. +- ``port_id``: match traffic from/to a given DPDK port ID. + + - ``id {unsigned}``: DPDK port ID. + - ``raw``: match an arbitrary byte string. - ``relative {boolean}``: look for pattern after the previous item. @@ -3428,6 +3432,11 @@ This section lists supported actions and their attributes, if any. - ``original {boolean}``: use original port index if possible. - ``index {unsigned}``: physical port index. +- ``port_id``: direct matching traffic to a given DPDK port ID. + + - ``original {boolean}``: use original DPDK port ID if possible. + - ``id {unsigned}``: DPDK port ID. + Destroying flow rules ~~~~~~~~~~~~~~~~~~~~~ diff --git a/lib/librte_ether/rte_flow.c b/lib/librte_ether/rte_flow.c index 00989c73b..cecab59f6 100644 --- a/lib/librte_ether/rte_flow.c +++ b/lib/librte_ether/rte_flow.c @@ -39,6 +39,7 @@ static const struct rte_flow_desc_data rte_flow_desc_item[] = { MK_FLOW_ITEM(PF, 0), MK_FLOW_ITEM(VF, sizeof(struct rte_flow_item_vf)), MK_FLOW_ITEM(PHY_PORT, sizeof(struct rte_flow_item_phy_port)), + MK_FLOW_ITEM(PORT_ID, sizeof(struct rte_flow_item_port_id)), MK_FLOW_ITEM(RAW, sizeof(struct rte_flow_item_raw)), MK_FLOW_ITEM(ETH, sizeof(struct rte_flow_item_eth)), MK_FLOW_ITEM(VLAN, sizeof(struct rte_flow_item_vlan)), @@ -77,6 +78,7 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = { MK_FLOW_ACTION(PF, 0), MK_FLOW_ACTION(VF, sizeof(struct rte_flow_action_vf)), MK_FLOW_ACTION(PHY_PORT, sizeof(struct rte_flow_action_phy_port)), + MK_FLOW_ACTION(PORT_ID, sizeof(struct rte_flow_action_port_id)), }; static int diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index 58b75e934..09a21e531 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -180,6 +180,16 @@ enum rte_flow_item_type { RTE_FLOW_ITEM_TYPE_PHY_PORT, /** + * [META] + * + * Matches traffic originating from (ingress) or going to (egress) a + * given DPDK port ID. + * + * See struct rte_flow_item_port_id. + */ + RTE_FLOW_ITEM_TYPE_PORT_ID, + + /** * Matches a byte string of a given length at a given offset. * * See struct rte_flow_item_raw. @@ -414,6 +424,32 @@ static const struct rte_flow_item_phy_port rte_flow_item_phy_port_mask = { #endif /** + * RTE_FLOW_ITEM_TYPE_PORT_ID + * + * Matches traffic originating from (ingress) or going to (egress) a given + * DPDK port ID. + * + * Normally only supported if the port ID in question is known by the + * underlying PMD and related to the device the flow rule is created + * against. + * + * This must not be confused with @p PHY_PORT which refers to the physical + * port of a device, whereas @p PORT_ID refers to a struct rte_eth_dev + * object on the application side (also known as "port representor" + * depending on the kind of underlying device). + */ +struct rte_flow_item_port_id { + uint32_t id; /**< DPDK port ID. */ +}; + +/** Default mask for RTE_FLOW_ITEM_TYPE_PORT_ID. */ +#ifndef __cplusplus +static const struct rte_flow_item_port_id rte_flow_item_port_id_mask = { + .id = 0xffffffff, +}; +#endif + +/** * RTE_FLOW_ITEM_TYPE_RAW * * Matches a byte string of a given length at a given offset. @@ -997,6 +1033,13 @@ enum rte_flow_action_type { RTE_FLOW_ACTION_TYPE_PHY_PORT, /** + * Directs matching traffic to a given DPDK port ID. + * + * See struct rte_flow_action_port_id. + */ + RTE_FLOW_ACTION_TYPE_PORT_ID, + + /** * Traffic metering and policing (MTR). * * See struct rte_flow_action_meter. @@ -1134,6 +1177,19 @@ struct rte_flow_action_phy_port { }; /** + * RTE_FLOW_ACTION_TYPE_PORT_ID + * + * Directs matching traffic to a given DPDK port ID. + * + * @see RTE_FLOW_ITEM_TYPE_PORT_ID + */ +struct rte_flow_action_port_id { + uint32_t original:1; /**< Use original DPDK port ID if possible. */ + uint32_t reserved:31; /**< Reserved, must be zero. */ + uint32_t id; /**< DPDK port ID. */ +}; + +/** * RTE_FLOW_ACTION_TYPE_METER * * Traffic metering and policing (MTR). -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v5 00/16] Flow API overhaul for switch offloads 2018-04-16 16:22 ` [dpdk-dev] [PATCH v4 00/16] Flow API overhaul for switch offloads Adrien Mazarguil ` (15 preceding siblings ...) 2018-04-16 16:23 ` [dpdk-dev] [PATCH v4 16/16] ethdev: add port ID item and " Adrien Mazarguil @ 2018-04-19 10:16 ` Adrien Mazarguil 2018-04-19 10:16 ` [dpdk-dev] [PATCH v5 01/16] ethdev: add error types to flow API Adrien Mazarguil ` (16 more replies) 16 siblings, 17 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-19 10:16 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev As summarized in a prior RFC [1], the flow API (rte_flow) was chosen as a means to manage switch offloads supported by many devices (usually going by names such as E-Switch or vSwitch) through user-specified flow rules. Combined with the need to support encap/decap actions, this requires a change in the way flow actions are processed (in order and possibly repeated) which modifies the behavior of some of the existing actions, thus warranting a major ABI breakage. Given this ABI breakage is also required by other work submitted for the current release [2][3], this series addresses various longstanding issues with the flow API and makes minor improvements in preparation for upcoming features. Changes summary: - Additional error types. - Clearer documentation. - Improved C++ compatibility. - Exhaustive RSS action. - Consistent behavior of VLAN pattern item. - New "transfer" attribute bringing consistency to VF/PF pattern items. - Confusing "PORT" pattern item renamed "PHY_PORT", with new action counterpart. - New "PORT_ID" pattern item and action to be used with port representors. This series piggybacks on the major ABI update introduced by a prior commit [4] for DPDK 18.05 and depends on several fixes [5] which must be applied first. [1] "[RFC] Switch device offload with DPDK" http://dpdk.org/ml/archives/dev/2018-March/092513.html [2] commit 676b605182a5 ("doc: announce ethdev API change for RSS configuration") [3] "[PATCH v1 00/21] MLX5 tunnel Rx offloading" http://dpdk.org/ml/archives/dev/2018-March/092264.html [4] commit 653e038efc9b ("ethdev: remove versioning of filter control function") [5] "[PATCH v6 00/11] Bunch of flow API-related fixes" http://dpdk.org/ml/archives/dev/2018-April/098035.html v5 changes: - Fixed errors reported by GCC and Clang in patch 05/16 ("ethdev: alter behavior of flow API actions"). - Rebased series once again. v4 changes: - No change besides new acked-by lines, rebased series to address conflicts. v3 changes: - Rebased series, fixed latest conflicts. - Addressed Andrew's comments, see affected patches for details: - Empty RSS types in flow rule means PMD-specific RSS instead of no RSS. - RSS hash function now explicitly compared against RTE_ETH_HASH_FUNCTION_DEFAULT instead of 0 in all PMDs. - sfc PMD updated to also accept Toeplitz. - Implicit VLAN TPID matching now removed from all PMDs. - Default mask upate for VLAN TCI now split as separate patch #11. - Ingress/egress definition clarified in patch #12. v2 changes: - Squashed "ethdev: update ABI for flow API functions" in subsequent patches. - Emphasized ABI impact in relevant commit logs. - Modified documentation in "ethdev: alter behavior of flow API actions" to describe how terminating flow rules without any action of the fate kind result in undefined behavior instead of dropping traffic. - Fixed other minor documentation formatting issues. - Modified "ethdev: refine TPID handling in flow API" as follows: - Using standard macro definitions for VLAN, QinQ and E-Tag EtherTypes. - Fixed endian conversion in sfc. - Replaced a condition in VLAN pattern item processing with an assertion check for i40e. Adrien Mazarguil (16): ethdev: add error types to flow API ethdev: clarify flow API pattern items and actions doc: remove flow API migration section ethdev: remove DUP action from flow API ethdev: alter behavior of flow API actions ethdev: remove C99 flexible arrays from flow API ethdev: flatten RSS configuration in flow API ethdev: add hash function to RSS flow API action ethdev: add encap level to RSS flow API action ethdev: refine TPID handling in flow API ethdev: limit default VLAN TCI mask in flow API ethdev: add transfer attribute to flow API ethdev: update behavior of VF/PF in flow API ethdev: rename physical port item in flow API ethdev: add physical port action to flow API ethdev: add port ID item and action to flow API app/test-pmd/cmdline_flow.c | 394 +++++++++++---- app/test-pmd/config.c | 78 +-- doc/guides/nics/tap.rst | 2 +- doc/guides/prog_guide/rte_flow.rst | 618 ++++++++--------------- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 60 ++- drivers/net/bnxt/bnxt_filter.c | 49 +- drivers/net/e1000/e1000_ethdev.h | 13 +- drivers/net/e1000/igb_ethdev.c | 4 +- drivers/net/e1000/igb_flow.c | 83 ++- drivers/net/e1000/igb_rxtx.c | 55 +- drivers/net/enic/enic_flow.c | 50 +- drivers/net/i40e/i40e_ethdev.c | 57 ++- drivers/net/i40e/i40e_ethdev.h | 15 +- drivers/net/i40e/i40e_flow.c | 130 +++-- drivers/net/ixgbe/ixgbe_ethdev.c | 7 +- drivers/net/ixgbe/ixgbe_ethdev.h | 13 +- drivers/net/ixgbe/ixgbe_flow.c | 91 +++- drivers/net/ixgbe/ixgbe_rxtx.c | 55 +- drivers/net/mlx4/mlx4.c | 2 +- drivers/net/mlx4/mlx4_flow.c | 117 +++-- drivers/net/mlx4/mlx4_flow.h | 2 +- drivers/net/mlx4/mlx4_rxq.c | 2 +- drivers/net/mlx4/mlx4_rxtx.h | 2 +- drivers/net/mlx5/mlx5_flow.c | 316 ++++++------ drivers/net/mlx5/mlx5_rxq.c | 22 +- drivers/net/mlx5/mlx5_rxtx.h | 26 +- drivers/net/mvpp2/mrvl_flow.c | 32 +- drivers/net/sfc/sfc_flow.c | 78 ++- drivers/net/tap/tap_flow.c | 49 +- examples/ipsec-secgw/ipsec.c | 21 +- lib/librte_ether/rte_ethdev_version.map | 22 +- lib/librte_ether/rte_flow.c | 68 +-- lib/librte_ether/rte_flow.h | 339 ++++++++----- lib/librte_net/rte_ether.h | 1 + 34 files changed, 1750 insertions(+), 1123 deletions(-) -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v5 01/16] ethdev: add error types to flow API 2018-04-19 10:16 ` [dpdk-dev] [PATCH v5 00/16] Flow API overhaul for switch offloads Adrien Mazarguil @ 2018-04-19 10:16 ` Adrien Mazarguil 2018-04-19 10:16 ` [dpdk-dev] [PATCH v5 02/16] ethdev: clarify flow API pattern items and actions Adrien Mazarguil ` (15 subsequent siblings) 16 siblings, 0 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-19 10:16 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev These enable more precise reporting of objects responsible for errors. This breaks ABI compatibility for the following public functions: - rte_flow_create() - rte_flow_destroy() - rte_flow_error_set() - rte_flow_flush() - rte_flow_isolate() - rte_flow_query() - rte_flow_validate() Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Acked-by: Andrew Rybchenko <arybchenko@solarflare.com> --- app/test-pmd/config.c | 4 ++++ lib/librte_ether/rte_ethdev_version.map | 20 +++++++++++++------- lib/librte_ether/rte_flow.h | 4 ++++ 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 5daa93bb3..a7645adb8 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -1244,8 +1244,12 @@ port_flow_complain(struct rte_flow_error *error) [RTE_FLOW_ERROR_TYPE_ATTR_EGRESS] = "egress field", [RTE_FLOW_ERROR_TYPE_ATTR] = "attributes structure", [RTE_FLOW_ERROR_TYPE_ITEM_NUM] = "pattern length", + [RTE_FLOW_ERROR_TYPE_ITEM_SPEC] = "item specification", + [RTE_FLOW_ERROR_TYPE_ITEM_LAST] = "item specification range", + [RTE_FLOW_ERROR_TYPE_ITEM_MASK] = "item specification mask", [RTE_FLOW_ERROR_TYPE_ITEM] = "specific pattern item", [RTE_FLOW_ERROR_TYPE_ACTION_NUM] = "number of actions", + [RTE_FLOW_ERROR_TYPE_ACTION_CONF] = "action configuration", [RTE_FLOW_ERROR_TYPE_ACTION] = "specific action", }; const char *errstr; diff --git a/lib/librte_ether/rte_ethdev_version.map b/lib/librte_ether/rte_ethdev_version.map index 34df6c8b5..e915e7929 100644 --- a/lib/librte_ether/rte_ethdev_version.map +++ b/lib/librte_ether/rte_ethdev_version.map @@ -127,11 +127,6 @@ DPDK_17.02 { _rte_eth_dev_reset; rte_eth_dev_fw_version_get; - rte_flow_create; - rte_flow_destroy; - rte_flow_flush; - rte_flow_query; - rte_flow_validate; } DPDK_16.07; @@ -153,7 +148,6 @@ DPDK_17.08 { _rte_eth_dev_callback_process; rte_eth_dev_adjust_nb_rx_tx_desc; rte_flow_copy; - rte_flow_isolate; rte_tm_capabilities_get; rte_tm_hierarchy_commit; rte_tm_level_capabilities_get; @@ -192,7 +186,6 @@ DPDK_17.11 { rte_eth_dev_get_sec_ctx; rte_eth_dev_pool_ops_supported; rte_eth_dev_reset; - rte_flow_error_set; } DPDK_17.08; @@ -203,6 +196,19 @@ DPDK_18.02 { } DPDK_17.11; +DPDK_18.05 { + global: + + rte_flow_create; + rte_flow_destroy; + rte_flow_error_set; + rte_flow_flush; + rte_flow_isolate; + rte_flow_query; + rte_flow_validate; + +} DPDK_18.02; + EXPERIMENTAL { global: diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index 44ae19d3b..26b95c772 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -1186,8 +1186,12 @@ enum rte_flow_error_type { RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, /**< Egress field. */ RTE_FLOW_ERROR_TYPE_ATTR, /**< Attributes structure. */ RTE_FLOW_ERROR_TYPE_ITEM_NUM, /**< Pattern length. */ + RTE_FLOW_ERROR_TYPE_ITEM_SPEC, /**< Item specification. */ + RTE_FLOW_ERROR_TYPE_ITEM_LAST, /**< Item specification range. */ + RTE_FLOW_ERROR_TYPE_ITEM_MASK, /**< Item specification mask. */ RTE_FLOW_ERROR_TYPE_ITEM, /**< Specific pattern item. */ RTE_FLOW_ERROR_TYPE_ACTION_NUM, /**< Number of actions. */ + RTE_FLOW_ERROR_TYPE_ACTION_CONF, /**< Action configuration. */ RTE_FLOW_ERROR_TYPE_ACTION, /**< Specific action. */ }; -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v5 02/16] ethdev: clarify flow API pattern items and actions 2018-04-19 10:16 ` [dpdk-dev] [PATCH v5 00/16] Flow API overhaul for switch offloads Adrien Mazarguil 2018-04-19 10:16 ` [dpdk-dev] [PATCH v5 01/16] ethdev: add error types to flow API Adrien Mazarguil @ 2018-04-19 10:16 ` Adrien Mazarguil 2018-04-19 10:16 ` [dpdk-dev] [PATCH v5 03/16] doc: remove flow API migration section Adrien Mazarguil ` (14 subsequent siblings) 16 siblings, 0 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-19 10:16 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev Although pattern items and actions examples end with "and so on", these lists include all existing definitions and as a result are updated almost every time new types are added. This is cumbersome and pointless. This patch also synchronizes Doxygen and external API documentation wording with a slight clarification regarding meta pattern items. No fundamental API change. Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Acked-by: Andrew Rybchenko <arybchenko@solarflare.com> --- doc/guides/prog_guide/rte_flow.rst | 23 +++++++++++------------ lib/librte_ether/rte_flow.h | 23 ++++++++++------------- 2 files changed, 21 insertions(+), 25 deletions(-) diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 961943dda..a11ebd617 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -186,12 +186,13 @@ Pattern item Pattern items fall in two categories: -- Matching protocol headers and packet data (ANY, RAW, ETH, VLAN, IPV4, - IPV6, ICMP, UDP, TCP, SCTP, VXLAN, MPLS, GRE, ESP and so on), usually - associated with a specification structure. +- Matching protocol headers and packet data, usually associated with a + specification structure. These must be stacked in the same order as the + protocol layers to match inside packets, starting from the lowest. -- Matching meta-data or affecting pattern processing (END, VOID, INVERT, PF, - VF, PORT and so on), often without a specification structure. +- Matching meta-data or affecting pattern processing, often without a + specification structure. Since they do not match packet contents, their + position in the list is usually not relevant. Item specification structures are used to match specific values among protocol fields (or item properties). Documentation describes for each item @@ -1001,15 +1002,13 @@ to a flow rule. That list is not ordered. They fall in three categories: -- Terminating actions (such as QUEUE, DROP, RSS, PF, VF) that prevent - processing matched packets by subsequent flow rules, unless overridden - with PASSTHRU. +- Terminating actions that prevent processing matched packets by subsequent + flow rules, unless overridden with PASSTHRU. -- Non-terminating actions (PASSTHRU, DUP) that leave matched packets up for - additional processing by subsequent flow rules. +- Non-terminating actions that leave matched packets up for additional + processing by subsequent flow rules. -- Other non-terminating meta actions that do not affect the fate of packets - (END, VOID, MARK, FLAG, COUNT, SECURITY). +- Other non-terminating meta actions that do not affect the fate of packets. When several actions are combined in a flow rule, they should all have different types (e.g. dropping a packet twice is not possible). diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index 26b95c772..d28a2a473 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -78,15 +78,13 @@ struct rte_flow_attr { * * Pattern items fall in two categories: * - * - Matching protocol headers and packet data (ANY, RAW, ETH, VLAN, IPV4, - * IPV6, ICMP, UDP, TCP, SCTP, VXLAN and so on), usually associated with a + * - Matching protocol headers and packet data, usually associated with a * specification structure. These must be stacked in the same order as the - * protocol layers to match, starting from the lowest. + * protocol layers to match inside packets, starting from the lowest. * - * - Matching meta-data or affecting pattern processing (END, VOID, INVERT, - * PF, VF, PORT and so on), often without a specification structure. Since - * they do not match packet contents, these can be specified anywhere - * within item lists without affecting others. + * - Matching meta-data or affecting pattern processing, often without a + * specification structure. Since they do not match packet contents, their + * position in the list is usually not relevant. * * See the description of individual types for more information. Those * marked with [META] fall into the second category. @@ -865,15 +863,14 @@ struct rte_flow_item { * * They fall in three categories: * - * - Terminating actions (such as QUEUE, DROP, RSS, PF, VF) that prevent - * processing matched packets by subsequent flow rules, unless overridden - * with PASSTHRU. + * - Terminating actions that prevent processing matched packets by + * subsequent flow rules, unless overridden with PASSTHRU. * - * - Non terminating actions (PASSTHRU, DUP) that leave matched packets up - * for additional processing by subsequent flow rules. + * - Non terminating actions that leave matched packets up for additional + * processing by subsequent flow rules. * * - Other non terminating meta actions that do not affect the fate of - * packets (END, VOID, MARK, FLAG, COUNT). + * packets. * * When several actions are combined in a flow rule, they should all have * different types (e.g. dropping a packet twice is not possible). -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v5 03/16] doc: remove flow API migration section 2018-04-19 10:16 ` [dpdk-dev] [PATCH v5 00/16] Flow API overhaul for switch offloads Adrien Mazarguil 2018-04-19 10:16 ` [dpdk-dev] [PATCH v5 01/16] ethdev: add error types to flow API Adrien Mazarguil 2018-04-19 10:16 ` [dpdk-dev] [PATCH v5 02/16] ethdev: clarify flow API pattern items and actions Adrien Mazarguil @ 2018-04-19 10:16 ` Adrien Mazarguil 2018-04-19 10:16 ` [dpdk-dev] [PATCH v5 04/16] ethdev: remove DUP action from flow API Adrien Mazarguil ` (13 subsequent siblings) 16 siblings, 0 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-19 10:16 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev This section has become less relevant since the flow API (rte_flow) is now a mature DPDK API with applications developed directly on top of it instead of an afterthought. This patch removes it for the following reasons: - It has never been updated to track the latest changes in the legacy filter types and never will. - Many provided examples are theoretical and misleading since PMDs do not implement them. Others are obvious. - Upcoming work on the flow API will alter the behavior of several pattern items, actions and in some cases, flow rules, which will in turn cause existing examples to be wrong. Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Acked-by: Andrew Rybchenko <arybchenko@solarflare.com> --- doc/guides/prog_guide/rte_flow.rst | 298 -------------------------------- 1 file changed, 298 deletions(-) diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index a11ebd617..51826d04c 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -55,9 +55,6 @@ encompasses and supersedes (including all functions and filter types) in order to expose a single interface with an unambiguous behavior that is common to all poll-mode drivers (PMDs). -Several methods to migrate existing applications are described in `API -migration`_. - Flow rule --------- @@ -2068,298 +2065,3 @@ Future evolutions - Optional software fallback when PMDs are unable to handle requested flow rules so applications do not have to implement their own. - -API migration -------------- - -Exhaustive list of deprecated filter types (normally prefixed with -*RTE_ETH_FILTER_*) found in ``rte_eth_ctrl.h`` and methods to convert them -to *rte_flow* rules. - -``MACVLAN`` to ``ETH`` → ``VF``, ``PF`` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -*MACVLAN* can be translated to a basic `Item: ETH`_ flow rule with a -terminating `Action: VF`_ or `Action: PF`_. - -.. _table_rte_flow_migration_macvlan: - -.. table:: MACVLAN conversion - - +--------------------------+---------+ - | Pattern | Actions | - +===+=====+==========+=====+=========+ - | 0 | ETH | ``spec`` | any | VF, | - | | +----------+-----+ PF | - | | | ``last`` | N/A | | - | | +----------+-----+ | - | | | ``mask`` | any | | - +---+-----+----------+-----+---------+ - | 1 | END | END | - +---+----------------------+---------+ - -``ETHERTYPE`` to ``ETH`` → ``QUEUE``, ``DROP`` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -*ETHERTYPE* is basically an `Item: ETH`_ flow rule with a terminating -`Action: QUEUE`_ or `Action: DROP`_. - -.. _table_rte_flow_migration_ethertype: - -.. table:: ETHERTYPE conversion - - +--------------------------+---------+ - | Pattern | Actions | - +===+=====+==========+=====+=========+ - | 0 | ETH | ``spec`` | any | QUEUE, | - | | +----------+-----+ DROP | - | | | ``last`` | N/A | | - | | +----------+-----+ | - | | | ``mask`` | any | | - +---+-----+----------+-----+---------+ - | 1 | END | END | - +---+----------------------+---------+ - -``FLEXIBLE`` to ``RAW`` → ``QUEUE`` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -*FLEXIBLE* can be translated to one `Item: RAW`_ pattern with a terminating -`Action: QUEUE`_ and a defined priority level. - -.. _table_rte_flow_migration_flexible: - -.. table:: FLEXIBLE conversion - - +--------------------------+---------+ - | Pattern | Actions | - +===+=====+==========+=====+=========+ - | 0 | RAW | ``spec`` | any | QUEUE | - | | +----------+-----+ | - | | | ``last`` | N/A | | - | | +----------+-----+ | - | | | ``mask`` | any | | - +---+-----+----------+-----+---------+ - | 1 | END | END | - +---+----------------------+---------+ - -``SYN`` to ``TCP`` → ``QUEUE`` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -*SYN* is a `Item: TCP`_ rule with only the ``syn`` bit enabled and masked, -and a terminating `Action: QUEUE`_. - -Priority level can be set to simulate the high priority bit. - -.. _table_rte_flow_migration_syn: - -.. table:: SYN conversion - - +-----------------------------------+---------+ - | Pattern | Actions | - +===+======+==========+=============+=========+ - | 0 | ETH | ``spec`` | unset | QUEUE | - | | +----------+-------------+ | - | | | ``last`` | unset | | - | | +----------+-------------+ | - | | | ``mask`` | unset | | - +---+------+----------+-------------+---------+ - | 1 | IPV4 | ``spec`` | unset | END | - | | +----------+-------------+ | - | | | ``mask`` | unset | | - | | +----------+-------------+ | - | | | ``mask`` | unset | | - +---+------+----------+---------+---+ | - | 2 | TCP | ``spec`` | ``syn`` | 1 | | - | | +----------+---------+---+ | - | | | ``mask`` | ``syn`` | 1 | | - +---+------+----------+---------+---+ | - | 3 | END | | - +---+-------------------------------+---------+ - -``NTUPLE`` to ``IPV4``, ``TCP``, ``UDP`` → ``QUEUE`` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -*NTUPLE* is similar to specifying an empty L2, `Item: IPV4`_ as L3 with -`Item: TCP`_ or `Item: UDP`_ as L4 and a terminating `Action: QUEUE`_. - -A priority level can be specified as well. - -.. _table_rte_flow_migration_ntuple: - -.. table:: NTUPLE conversion - - +-----------------------------+---------+ - | Pattern | Actions | - +===+======+==========+=======+=========+ - | 0 | ETH | ``spec`` | unset | QUEUE | - | | +----------+-------+ | - | | | ``last`` | unset | | - | | +----------+-------+ | - | | | ``mask`` | unset | | - +---+------+----------+-------+---------+ - | 1 | IPV4 | ``spec`` | any | END | - | | +----------+-------+ | - | | | ``last`` | unset | | - | | +----------+-------+ | - | | | ``mask`` | any | | - +---+------+----------+-------+ | - | 2 | TCP, | ``spec`` | any | | - | | UDP +----------+-------+ | - | | | ``last`` | unset | | - | | +----------+-------+ | - | | | ``mask`` | any | | - +---+------+----------+-------+ | - | 3 | END | | - +---+-------------------------+---------+ - -``TUNNEL`` to ``ETH``, ``IPV4``, ``IPV6``, ``VXLAN`` (or other) → ``QUEUE`` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -*TUNNEL* matches common IPv4 and IPv6 L3/L4-based tunnel types. - -In the following table, `Item: ANY`_ is used to cover the optional L4. - -.. _table_rte_flow_migration_tunnel: - -.. table:: TUNNEL conversion - - +-------------------------------------------------------+---------+ - | Pattern | Actions | - +===+==========================+==========+=============+=========+ - | 0 | ETH | ``spec`` | any | QUEUE | - | | +----------+-------------+ | - | | | ``last`` | unset | | - | | +----------+-------------+ | - | | | ``mask`` | any | | - +---+--------------------------+----------+-------------+---------+ - | 1 | IPV4, IPV6 | ``spec`` | any | END | - | | +----------+-------------+ | - | | | ``last`` | unset | | - | | +----------+-------------+ | - | | | ``mask`` | any | | - +---+--------------------------+----------+-------------+ | - | 2 | ANY | ``spec`` | any | | - | | +----------+-------------+ | - | | | ``last`` | unset | | - | | +----------+---------+---+ | - | | | ``mask`` | ``num`` | 0 | | - +---+--------------------------+----------+---------+---+ | - | 3 | VXLAN, GENEVE, TEREDO, | ``spec`` | any | | - | | NVGRE, GRE, ... +----------+-------------+ | - | | | ``last`` | unset | | - | | +----------+-------------+ | - | | | ``mask`` | any | | - +---+--------------------------+----------+-------------+ | - | 4 | END | | - +---+---------------------------------------------------+---------+ - -``FDIR`` to most item types → ``QUEUE``, ``DROP``, ``PASSTHRU`` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -*FDIR* is more complex than any other type, there are several methods to -emulate its functionality. It is summarized for the most part in the table -below. - -A few features are intentionally not supported: - -- The ability to configure the matching input set and masks for the entire - device, PMDs should take care of it automatically according to the - requested flow rules. - - For example if a device supports only one bit-mask per protocol type, - source/address IPv4 bit-masks can be made immutable by the first created - rule. Subsequent IPv4 or TCPv4 rules can only be created if they are - compatible. - - Note that only protocol bit-masks affected by existing flow rules are - immutable, others can be changed later. They become mutable again after - the related flow rules are destroyed. - -- Returning four or eight bytes of matched data when using flex bytes - filtering. Although a specific action could implement it, it conflicts - with the much more useful 32 bits tagging on devices that support it. - -- Side effects on RSS processing of the entire device. Flow rules that - conflict with the current device configuration should not be - allowed. Similarly, device configuration should not be allowed when it - affects existing flow rules. - -- Device modes of operation. "none" is unsupported since filtering cannot be - disabled as long as a flow rule is present. - -- "MAC VLAN" or "tunnel" perfect matching modes should be automatically set - according to the created flow rules. - -- Signature mode of operation is not defined but could be handled through - "FUZZY" item. - -.. _table_rte_flow_migration_fdir: - -.. table:: FDIR conversion - - +----------------------------------------+-----------------------+ - | Pattern | Actions | - +===+===================+==========+=====+=======================+ - | 0 | ETH, RAW | ``spec`` | any | QUEUE, DROP, PASSTHRU | - | | +----------+-----+ | - | | | ``last`` | N/A | | - | | +----------+-----+ | - | | | ``mask`` | any | | - +---+-------------------+----------+-----+-----------------------+ - | 1 | IPV4, IPv6 | ``spec`` | any | MARK | - | | +----------+-----+ | - | | | ``last`` | N/A | | - | | +----------+-----+ | - | | | ``mask`` | any | | - +---+-------------------+----------+-----+-----------------------+ - | 2 | TCP, UDP, SCTP | ``spec`` | any | END | - | | +----------+-----+ | - | | | ``last`` | N/A | | - | | +----------+-----+ | - | | | ``mask`` | any | | - +---+-------------------+----------+-----+ | - | 3 | VF, PF, FUZZY | ``spec`` | any | | - | | (optional) +----------+-----+ | - | | | ``last`` | N/A | | - | | +----------+-----+ | - | | | ``mask`` | any | | - +---+-------------------+----------+-----+ | - | 4 | END | | - +---+------------------------------------+-----------------------+ - -``HASH`` -~~~~~~~~ - -There is no counterpart to this filter type because it translates to a -global device setting instead of a pattern item. Device settings are -automatically set according to the created flow rules. - -``L2_TUNNEL`` to ``VOID`` → ``VXLAN`` (or others) -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -All packets are matched. This type alters incoming packets to encapsulate -them in a chosen tunnel type, optionally redirect them to a VF as well. - -The destination pool for tag based forwarding can be emulated with other -flow rules using `Action: DUP`_. - -.. _table_rte_flow_migration_l2tunnel: - -.. table:: L2_TUNNEL conversion - - +---------------------------+--------------------+ - | Pattern | Actions | - +===+======+==========+=====+====================+ - | 0 | VOID | ``spec`` | N/A | VXLAN, GENEVE, ... | - | | | | | | - | | | | | | - | | +----------+-----+ | - | | | ``last`` | N/A | | - | | +----------+-----+ | - | | | ``mask`` | N/A | | - | | | | | | - +---+------+----------+-----+--------------------+ - | 1 | END | VF (optional) | - +---+ +--------------------+ - | 2 | | END | - +---+-----------------------+--------------------+ -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v5 04/16] ethdev: remove DUP action from flow API 2018-04-19 10:16 ` [dpdk-dev] [PATCH v5 00/16] Flow API overhaul for switch offloads Adrien Mazarguil ` (2 preceding siblings ...) 2018-04-19 10:16 ` [dpdk-dev] [PATCH v5 03/16] doc: remove flow API migration section Adrien Mazarguil @ 2018-04-19 10:16 ` Adrien Mazarguil 2018-04-19 10:16 ` [dpdk-dev] [PATCH v5 05/16] ethdev: alter behavior of flow API actions Adrien Mazarguil ` (12 subsequent siblings) 16 siblings, 0 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-19 10:16 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev Upcoming changes in relation to the handling of actions list will make the DUP action redundant as specifying several QUEUE actions will achieve the same behavior. Besides, no PMD implements this action. By removing an entry from enum rte_flow_action_type, this patch breaks ABI compatibility for the following public functions: - rte_flow_copy() - rte_flow_create() - rte_flow_query() - rte_flow_validate() Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Acked-by: Andrew Rybchenko <arybchenko@solarflare.com> --- app/test-pmd/cmdline_flow.c | 23 ----------------------- app/test-pmd/config.c | 1 - doc/guides/prog_guide/rte_flow.rst | 23 ----------------------- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 8 -------- lib/librte_ether/rte_ethdev_version.map | 2 +- lib/librte_ether/rte_flow.c | 1 - lib/librte_ether/rte_flow.h | 24 ------------------------ 7 files changed, 1 insertion(+), 81 deletions(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index f0b4b7bc4..2ddb08feb 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -164,8 +164,6 @@ enum index { ACTION_QUEUE_INDEX, ACTION_DROP, ACTION_COUNT, - ACTION_DUP, - ACTION_DUP_INDEX, ACTION_RSS, ACTION_RSS_TYPES, ACTION_RSS_TYPE, @@ -625,7 +623,6 @@ static const enum index next_action[] = { ACTION_QUEUE, ACTION_DROP, ACTION_COUNT, - ACTION_DUP, ACTION_RSS, ACTION_PF, ACTION_VF, @@ -645,12 +642,6 @@ static const enum index action_queue[] = { ZERO, }; -static const enum index action_dup[] = { - ACTION_DUP_INDEX, - ACTION_NEXT, - ZERO, -}; - static const enum index action_rss[] = { ACTION_RSS_TYPES, ACTION_RSS_KEY, @@ -1597,20 +1588,6 @@ static const struct token token_list[] = { .next = NEXT(NEXT_ENTRY(ACTION_NEXT)), .call = parse_vc, }, - [ACTION_DUP] = { - .name = "dup", - .help = "duplicate packets to a given queue index", - .priv = PRIV_ACTION(DUP, sizeof(struct rte_flow_action_dup)), - .next = NEXT(action_dup), - .call = parse_vc, - }, - [ACTION_DUP_INDEX] = { - .name = "index", - .help = "queue index to duplicate packets to", - .next = NEXT(action_dup, NEXT_ENTRY(UNSIGNED)), - .args = ARGS(ARGS_ENTRY(struct rte_flow_action_dup, index)), - .call = parse_vc_conf, - }, [ACTION_RSS] = { .name = "rss", .help = "spread packets among several queues", diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index a7645adb8..d0d372797 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -1065,7 +1065,6 @@ static const struct { MK_FLOW_ACTION(QUEUE, sizeof(struct rte_flow_action_queue)), MK_FLOW_ACTION(DROP, 0), MK_FLOW_ACTION(COUNT, 0), - MK_FLOW_ACTION(DUP, sizeof(struct rte_flow_action_dup)), MK_FLOW_ACTION(RSS, sizeof(struct rte_flow_action_rss)), /* +queue[] */ MK_FLOW_ACTION(PF, 0), MK_FLOW_ACTION(VF, sizeof(struct rte_flow_action_vf)), diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 51826d04c..a237e4fd2 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -1299,26 +1299,6 @@ Query structure to retrieve and reset flow rule counters: | ``bytes`` | out | number of bytes through this rule | +---------------+-----+-----------------------------------+ -Action: ``DUP`` -^^^^^^^^^^^^^^^ - -Duplicates packets to a given queue index. - -This is normally combined with QUEUE, however when used alone, it is -actually similar to QUEUE + PASSTHRU. - -- Non-terminating by default. - -.. _table_rte_flow_action_dup: - -.. table:: DUP - - +-----------+------------------------------------+ - | Field | Value | - +===========+====================================+ - | ``index`` | queue index to duplicate packet to | - +-----------+------------------------------------+ - Action: ``RSS`` ^^^^^^^^^^^^^^^ @@ -2010,9 +1990,6 @@ Unsupported actions and tagging (`Action: MARK`_ or `Action: FLAG`_) may be implemented in software as long as the target queue is used by a single rule. -- A rule specifying both `Action: DUP`_ + `Action: QUEUE`_ may be translated - to two hidden rules combining `Action: QUEUE`_ and `Action: PASSTHRU`_. - - When a single target queue is provided, `Action: RSS`_ can also be implemented through `Action: QUEUE`_. diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index cb6f201e1..a015d02a4 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3363,10 +3363,6 @@ actions can sometimes be combined when the end result is unambiguous:: :: - drop / dup index 6 / end # same as above - -:: - queue index 6 / rss queues 6 7 8 / end # queue has no effect :: @@ -3400,10 +3396,6 @@ This section lists supported actions and their attributes, if any. - ``count``: enable counters for this rule. -- ``dup``: duplicate packets to a given queue index. - - - ``index {unsigned}``: queue index to duplicate packets to. - - ``rss``: spread packets among several queues. - ``types [{RSS hash type} [...]] end``: RSS hash types, allowed tokens diff --git a/lib/librte_ether/rte_ethdev_version.map b/lib/librte_ether/rte_ethdev_version.map index e915e7929..8f1ae5ed2 100644 --- a/lib/librte_ether/rte_ethdev_version.map +++ b/lib/librte_ether/rte_ethdev_version.map @@ -147,7 +147,6 @@ DPDK_17.08 { _rte_eth_dev_callback_process; rte_eth_dev_adjust_nb_rx_tx_desc; - rte_flow_copy; rte_tm_capabilities_get; rte_tm_hierarchy_commit; rte_tm_level_capabilities_get; @@ -199,6 +198,7 @@ DPDK_18.02 { DPDK_18.05 { global: + rte_flow_copy; rte_flow_create; rte_flow_destroy; rte_flow_error_set; diff --git a/lib/librte_ether/rte_flow.c b/lib/librte_ether/rte_flow.c index ada280810..80f9cb6cb 100644 --- a/lib/librte_ether/rte_flow.c +++ b/lib/librte_ether/rte_flow.c @@ -73,7 +73,6 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = { MK_FLOW_ACTION(QUEUE, sizeof(struct rte_flow_action_queue)), MK_FLOW_ACTION(DROP, 0), MK_FLOW_ACTION(COUNT, 0), - MK_FLOW_ACTION(DUP, sizeof(struct rte_flow_action_dup)), MK_FLOW_ACTION(RSS, sizeof(struct rte_flow_action_rss)), /* +queue[] */ MK_FLOW_ACTION(PF, 0), MK_FLOW_ACTION(VF, sizeof(struct rte_flow_action_vf)), diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index d28a2a473..6ace24ff4 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -961,16 +961,6 @@ enum rte_flow_action_type { RTE_FLOW_ACTION_TYPE_COUNT, /** - * Duplicates packets to a given queue index. - * - * This is normally combined with QUEUE, however when used alone, it - * is actually similar to QUEUE + PASSTHRU. - * - * See struct rte_flow_action_dup. - */ - RTE_FLOW_ACTION_TYPE_DUP, - - /** * Similar to QUEUE, except RSS is additionally performed on packets * to spread them among several queues according to the provided * parameters. @@ -1052,20 +1042,6 @@ struct rte_flow_query_count { }; /** - * RTE_FLOW_ACTION_TYPE_DUP - * - * Duplicates packets to a given queue index. - * - * This is normally combined with QUEUE, however when used alone, it is - * actually similar to QUEUE + PASSTHRU. - * - * Non-terminating by default. - */ -struct rte_flow_action_dup { - uint16_t index; /**< Queue index to duplicate packets to. */ -}; - -/** * RTE_FLOW_ACTION_TYPE_RSS * * Similar to QUEUE, except RSS is additionally performed on packets to -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v5 05/16] ethdev: alter behavior of flow API actions 2018-04-19 10:16 ` [dpdk-dev] [PATCH v5 00/16] Flow API overhaul for switch offloads Adrien Mazarguil ` (3 preceding siblings ...) 2018-04-19 10:16 ` [dpdk-dev] [PATCH v5 04/16] ethdev: remove DUP action from flow API Adrien Mazarguil @ 2018-04-19 10:16 ` Adrien Mazarguil 2018-04-19 10:16 ` [dpdk-dev] [PATCH v5 06/16] ethdev: remove C99 flexible arrays from flow API Adrien Mazarguil ` (11 subsequent siblings) 16 siblings, 0 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-19 10:16 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev Cc: Ajit Khaparde, Wenzhuo Lu, John Daley, Gaetan Rivet, Beilei Xing, Konstantin Ananyev, Nelio Laranjeiro, Andrew Rybchenko, Pascal Mazon This patch makes the following changes to flow rule actions: - List order now matters, they are redefined as performed first to last instead of "all simultaneously". - Repeated actions are now supported (e.g. specifying QUEUE multiple times now duplicates traffic among them). Previously only the last action of any given kind was taken into account. - No more distinction between terminating/non-terminating/meta actions. Flow rules themselves are now defined as always terminating unless a PASSTHRU action is specified. These changes alter the behavior of flow rules in corner cases in order to prepare the flow API for actions that modify traffic contents or properties (e.g. encapsulation, compression) and for which order matter when combined. Previously one would have to do so through multiple flow rules by combining PASSTRHU with priority levels, however this proved overly complex to implement at the PMD level, hence this simpler approach. This breaks ABI compatibility for the following public functions: - rte_flow_create() - rte_flow_validate() PMDs with rte_flow support are modified accordingly: - bnxt: no change, implementation already forbids multiple actions and does not support PASSTHRU. - e1000: no change, same as bnxt. - enic: modified to forbid redundant actions, no support for default drop. - failsafe: no change needed. - i40e: no change, implementation already forbids multiple actions. - ixgbe: same as i40e. - mlx4: modified to forbid multiple fate-deciding actions and drop when unspecified. - mlx5: same as mlx4, with other redundant actions also forbidden. - sfc: same as mlx4. - tap: implementation already complies with the new behavior except for the default pass-through modified as a default drop. Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Reviewed-by: Andrew Rybchenko <arybchenko@oktetlabs.ru> Cc: Ajit Khaparde <ajit.khaparde@broadcom.com> Cc: Wenzhuo Lu <wenzhuo.lu@intel.com> Cc: John Daley <johndale@cisco.com> Cc: Gaetan Rivet <gaetan.rivet@6wind.com> Cc: Beilei Xing <beilei.xing@intel.com> Cc: Konstantin Ananyev <konstantin.ananyev@intel.com> Cc: Nelio Laranjeiro <nelio.laranjeiro@6wind.com> Cc: Andrew Rybchenko <arybchenko@solarflare.com> Cc: Pascal Mazon <pascal.mazon@6wind.com> -- v5 changes: Fixed issues raised by GCC and Clang with overlap checks in both enic and mlx5, as reported by Andrew [1]. [1] http://dpdk.org/ml/archives/dev/2018-April/097864.html --- doc/guides/prog_guide/rte_flow.rst | 67 +++++++++++++------------------- drivers/net/enic/enic_flow.c | 25 ++++++++++++ drivers/net/mlx4/mlx4_flow.c | 21 +++++++--- drivers/net/mlx5/mlx5_flow.c | 69 ++++++++++++++------------------- drivers/net/sfc/sfc_flow.c | 22 +++++++---- drivers/net/tap/tap_flow.c | 11 ++++++ lib/librte_ether/rte_flow.h | 54 +++++++------------------- 7 files changed, 138 insertions(+), 131 deletions(-) diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index a237e4fd2..80360d068 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -995,28 +995,27 @@ Actions Each possible action is represented by a type. Some have associated configuration structures. Several actions combined in a list can be assigned -to a flow rule. That list is not ordered. +to a flow rule and are performed in order. They fall in three categories: -- Terminating actions that prevent processing matched packets by subsequent - flow rules, unless overridden with PASSTHRU. +- Actions that modify the fate of matching traffic, for instance by dropping + or assigning it a specific destination. -- Non-terminating actions that leave matched packets up for additional - processing by subsequent flow rules. +- Actions that modify matching traffic contents or its properties. This + includes adding/removing encapsulation, encryption, compression and marks. -- Other non-terminating meta actions that do not affect the fate of packets. +- Actions related to the flow rule itself, such as updating counters or + making it non-terminating. -When several actions are combined in a flow rule, they should all have -different types (e.g. dropping a packet twice is not possible). +Flow rules being terminating by default, not specifying any action of the +fate kind results in undefined behavior. This applies to both ingress and +egress. -Only the last action of a given type is taken into account. PMDs still -perform error checking on the entire list. +PASSTHRU, when supported, makes a flow rule non-terminating. Like matching patterns, action lists are terminated by END items. -*Note that PASSTHRU is the only action able to override a terminating rule.* - Example of action that redirects packets to queue index 10: .. _table_rte_flow_action_example: @@ -1029,12 +1028,11 @@ Example of action that redirects packets to queue index 10: | ``index`` | 10 | +-----------+-------+ -Action lists examples, their order is not significant, applications must -consider all actions to be performed simultaneously: +Actions are performed in list order: -.. _table_rte_flow_count_and_drop: +.. _table_rte_flow_count_then_drop: -.. table:: Count and drop +.. table:: Count then drop +-------+--------+ | Index | Action | @@ -1050,7 +1048,7 @@ consider all actions to be performed simultaneously: .. _table_rte_flow_mark_count_redirect: -.. table:: Mark, count and redirect +.. table:: Mark, count then redirect +-------+--------+-----------+-------+ | Index | Action | Field | Value | @@ -1080,12 +1078,15 @@ consider all actions to be performed simultaneously: | 2 | END | +-------+----------------------------+ -In the above example, considering both actions are performed simultaneously, -the end result is that only QUEUE has any effect. +In the above example, while DROP and QUEUE must be performed in order, both +have to happen before reaching END. Only QUEUE has a visible effect. + +Note that such a list may be thought as ambiguous and rejected on that +basis. -.. _table_rte_flow_redirect_queue_3: +.. _table_rte_flow_redirect_queue_5_3: -.. table:: Redirect to queue 3 +.. table:: Redirect to queues 5 and 3 +-------+--------+-----------+-------+ | Index | Action | Field | Value | @@ -1099,9 +1100,9 @@ the end result is that only QUEUE has any effect. | 3 | END | +-------+----------------------------+ -As previously described, only the last action of a given type found in the -list is taken into account. The above example also shows that VOID is -ignored. +As previously described, all actions must be taken into account. This +effectively duplicates traffic to both queues. The above example also shows +that VOID is ignored. Action types ~~~~~~~~~~~~ @@ -1151,9 +1152,8 @@ PMDs. Action: ``PASSTHRU`` ^^^^^^^^^^^^^^^^^^^^ -Leaves packets up for additional processing by subsequent flow rules. This -is the default when a rule does not contain a terminating action, but can be -specified to force a rule to become non-terminating. +Leaves traffic up for additional processing by subsequent flow rules; makes +a flow rule non-terminating. - No configurable properties. @@ -1227,8 +1227,6 @@ Action: ``QUEUE`` Assigns packets to a given queue index. -- Terminating by default. - .. _table_rte_flow_action_queue: .. table:: QUEUE @@ -1245,8 +1243,6 @@ Action: ``DROP`` Drop packets. - No configurable properties. -- Terminating by default. -- PASSTHRU overrides this action if both are specified. .. _table_rte_flow_action_drop: @@ -1309,8 +1305,6 @@ Note: RSS hash result is stored in the ``hash.rss`` mbuf field which overlaps ``hash.fdir.lo``. Since `Action: MARK`_ sets the ``hash.fdir.hi`` field only, both can be requested simultaneously. -- Terminating by default. - .. _table_rte_flow_action_rss: .. table:: RSS @@ -1331,7 +1325,6 @@ Action: ``PF`` Redirects packets to the physical function (PF) of the current device. - No configurable properties. -- Terminating by default. .. _table_rte_flow_action_pf: @@ -1353,8 +1346,6 @@ ID instead of the specified one. This parameter may not be available and is not guaranteed to work properly if the VF part is matched by a prior flow rule or if packets are not addressed to a VF in the first place. -- Terminating by default. - .. _table_rte_flow_action_vf: .. table:: VF @@ -1378,8 +1369,6 @@ action parameter. More than one flow can use the same MTR object through the meter action. The MTR object can be further updated or queried using the rte_mtr* API. -- Non-terminating by default. - .. _table_rte_flow_action_meter: .. table:: METER @@ -1415,8 +1404,6 @@ direction. Multiple flows can be configured to use the same security session. -- Non-terminating by default. - .. _table_rte_flow_action_security: .. table:: SECURITY diff --git a/drivers/net/enic/enic_flow.c b/drivers/net/enic/enic_flow.c index b9f36587c..c34ae84d1 100644 --- a/drivers/net/enic/enic_flow.c +++ b/drivers/net/enic/enic_flow.c @@ -3,6 +3,7 @@ */ #include <errno.h> +#include <stdint.h> #include <rte_log.h> #include <rte_ethdev_driver.h> #include <rte_flow_driver.h> @@ -964,6 +965,9 @@ static int enic_copy_action_v1(const struct rte_flow_action actions[], struct filter_action_v2 *enic_action) { + enum { FATE = 1, }; + uint32_t overlap = 0; + FLOW_TRACE(); for (; actions->type != RTE_FLOW_ACTION_TYPE_END; actions++) { @@ -975,6 +979,10 @@ enic_copy_action_v1(const struct rte_flow_action actions[], const struct rte_flow_action_queue *queue = (const struct rte_flow_action_queue *) actions->conf; + + if (overlap & FATE) + return ENOTSUP; + overlap |= FATE; enic_action->rq_idx = enic_rte_rq_idx_to_sop_idx(queue->index); break; @@ -984,6 +992,8 @@ enic_copy_action_v1(const struct rte_flow_action actions[], break; } } + if (!(overlap & FATE)) + return ENOTSUP; enic_action->type = FILTER_ACTION_RQ_STEERING; return 0; } @@ -1001,6 +1011,9 @@ static int enic_copy_action_v2(const struct rte_flow_action actions[], struct filter_action_v2 *enic_action) { + enum { FATE = 1, MARK = 2, }; + uint32_t overlap = 0; + FLOW_TRACE(); for (; actions->type != RTE_FLOW_ACTION_TYPE_END; actions++) { @@ -1009,6 +1022,10 @@ enic_copy_action_v2(const struct rte_flow_action actions[], const struct rte_flow_action_queue *queue = (const struct rte_flow_action_queue *) actions->conf; + + if (overlap & FATE) + return ENOTSUP; + overlap |= FATE; enic_action->rq_idx = enic_rte_rq_idx_to_sop_idx(queue->index); enic_action->flags |= FILTER_ACTION_RQ_STEERING_FLAG; @@ -1019,6 +1036,9 @@ enic_copy_action_v2(const struct rte_flow_action actions[], (const struct rte_flow_action_mark *) actions->conf; + if (overlap & MARK) + return ENOTSUP; + overlap |= MARK; /* ENIC_MAGIC_FILTER_ID is reserved and is the highest * in the range of allows mark ids. */ @@ -1029,6 +1049,9 @@ enic_copy_action_v2(const struct rte_flow_action actions[], break; } case RTE_FLOW_ACTION_TYPE_FLAG: { + if (overlap & MARK) + return ENOTSUP; + overlap |= MARK; enic_action->filter_id = ENIC_MAGIC_FILTER_ID; enic_action->flags |= FILTER_ACTION_FILTER_ID_FLAG; break; @@ -1044,6 +1067,8 @@ enic_copy_action_v2(const struct rte_flow_action actions[], break; } } + if (!(overlap & FATE)) + return ENOTSUP; enic_action->type = FILTER_ACTION_V2; return 0; } diff --git a/drivers/net/mlx4/mlx4_flow.c b/drivers/net/mlx4/mlx4_flow.c index 67fd568bc..15cdf07b7 100644 --- a/drivers/net/mlx4/mlx4_flow.c +++ b/drivers/net/mlx4/mlx4_flow.c @@ -637,6 +637,7 @@ mlx4_flow_prepare(struct priv *priv, struct rte_flow temp = { .ibv_attr_size = sizeof(*temp.ibv_attr) }; struct rte_flow *flow = &temp; const char *msg = NULL; + int overlap; if (attr->group) return rte_flow_error_set @@ -656,6 +657,7 @@ mlx4_flow_prepare(struct priv *priv, (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, NULL, "only ingress is supported"); fill: + overlap = 0; proc = mlx4_flow_proc_item_list; /* Go over pattern. */ for (item = pattern; item->type; ++item) { @@ -702,6 +704,16 @@ mlx4_flow_prepare(struct priv *priv, } /* Go over actions list. */ for (action = actions; action->type; ++action) { + /* This one may appear anywhere multiple times. */ + if (action->type == RTE_FLOW_ACTION_TYPE_VOID) + continue; + /* Fate-deciding actions may appear exactly once. */ + if (overlap) { + msg = "cannot combine several fate-deciding actions," + " choose between DROP, QUEUE or RSS"; + goto exit_action_not_supported; + } + overlap = 1; switch (action->type) { const struct rte_flow_action_queue *queue; const struct rte_flow_action_rss *rss; @@ -709,8 +721,6 @@ mlx4_flow_prepare(struct priv *priv, uint64_t fields; unsigned int i; - case RTE_FLOW_ACTION_TYPE_VOID: - continue; case RTE_FLOW_ACTION_TYPE_DROP: flow->drop = 1; break; @@ -801,10 +811,9 @@ mlx4_flow_prepare(struct priv *priv, goto exit_action_not_supported; } } - if (!flow->rss && !flow->drop) - return rte_flow_error_set - (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, - NULL, "no valid action"); + /* When fate is unknown, drop traffic. */ + if (!overlap) + flow->drop = 1; /* Validation ends here. */ if (!addr) { if (flow->rss) diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 1ca413e32..8b156667c 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -4,6 +4,7 @@ */ #include <sys/queue.h> +#include <stdint.h> #include <string.h> /* Verbs header. */ @@ -638,6 +639,8 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, struct rte_flow_error *error, struct mlx5_flow_parse *parser) { + enum { FATE = 1, MARK = 2, COUNT = 4, }; + uint32_t overlap = 0; struct priv *priv = dev->data->dev_private; int ret; @@ -654,39 +657,31 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, if (actions->type == RTE_FLOW_ACTION_TYPE_VOID) { continue; } else if (actions->type == RTE_FLOW_ACTION_TYPE_DROP) { + if (overlap & FATE) + goto exit_action_overlap; + overlap |= FATE; parser->drop = 1; } else if (actions->type == RTE_FLOW_ACTION_TYPE_QUEUE) { const struct rte_flow_action_queue *queue = (const struct rte_flow_action_queue *) actions->conf; - uint16_t n; - uint16_t found = 0; + if (overlap & FATE) + goto exit_action_overlap; + overlap |= FATE; if (!queue || (queue->index > (priv->rxqs_n - 1))) goto exit_action_not_supported; - for (n = 0; n < parser->queues_n; ++n) { - if (parser->queues[n] == queue->index) { - found = 1; - break; - } - } - if (parser->queues_n > 1 && !found) { - rte_flow_error_set(error, ENOTSUP, - RTE_FLOW_ERROR_TYPE_ACTION, - actions, - "queue action not in RSS queues"); - return -rte_errno; - } - if (!found) { - parser->queues_n = 1; - parser->queues[0] = queue->index; - } + parser->queues_n = 1; + parser->queues[0] = queue->index; } else if (actions->type == RTE_FLOW_ACTION_TYPE_RSS) { const struct rte_flow_action_rss *rss = (const struct rte_flow_action_rss *) actions->conf; uint16_t n; + if (overlap & FATE) + goto exit_action_overlap; + overlap |= FATE; if (!rss || !rss->num) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, @@ -694,26 +689,6 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, "no valid queues"); return -rte_errno; } - if (parser->queues_n == 1) { - uint16_t found = 0; - - assert(parser->queues_n); - for (n = 0; n < rss->num; ++n) { - if (parser->queues[0] == - rss->queue[n]) { - found = 1; - break; - } - } - if (!found) { - rte_flow_error_set(error, ENOTSUP, - RTE_FLOW_ERROR_TYPE_ACTION, - actions, - "queue action not in RSS" - " queues"); - return -rte_errno; - } - } if (rss->num > RTE_DIM(parser->queues)) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, @@ -747,6 +722,9 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, (const struct rte_flow_action_mark *) actions->conf; + if (overlap & MARK) + goto exit_action_overlap; + overlap |= MARK; if (!mark) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, @@ -764,14 +742,23 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, parser->mark = 1; parser->mark_id = mark->id; } else if (actions->type == RTE_FLOW_ACTION_TYPE_FLAG) { + if (overlap & MARK) + goto exit_action_overlap; + overlap |= MARK; parser->mark = 1; } else if (actions->type == RTE_FLOW_ACTION_TYPE_COUNT && priv->config.flow_counter_en) { + if (overlap & COUNT) + goto exit_action_overlap; + overlap |= COUNT; parser->count = 1; } else { goto exit_action_not_supported; } } + /* When fate is unknown, drop traffic. */ + if (!(overlap & FATE)) + parser->drop = 1; if (parser->drop && parser->mark) parser->mark = 0; if (!parser->queues_n && !parser->drop) { @@ -784,6 +771,10 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, actions, "action not supported"); return -rte_errno; +exit_action_overlap: + rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, + actions, "overlapping actions are not supported"); + return -rte_errno; } /** diff --git a/drivers/net/sfc/sfc_flow.c b/drivers/net/sfc/sfc_flow.c index fe4c0b0c5..056405515 100644 --- a/drivers/net/sfc/sfc_flow.c +++ b/drivers/net/sfc/sfc_flow.c @@ -1467,10 +1467,19 @@ sfc_flow_parse_actions(struct sfc_adapter *sa, } for (; actions->type != RTE_FLOW_ACTION_TYPE_END; actions++) { + /* This one may appear anywhere multiple times. */ + if (actions->type == RTE_FLOW_ACTION_TYPE_VOID) + continue; + /* Fate-deciding actions may appear exactly once. */ + if (is_specified) { + rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, + actions, + "Cannot combine several fate-deciding actions," + "choose between QUEUE, RSS or DROP"); + return -rte_errno; + } switch (actions->type) { - case RTE_FLOW_ACTION_TYPE_VOID: - break; - case RTE_FLOW_ACTION_TYPE_QUEUE: rc = sfc_flow_parse_queue(sa, actions->conf, flow); if (rc != 0) { @@ -1512,11 +1521,10 @@ sfc_flow_parse_actions(struct sfc_adapter *sa, } } + /* When fate is unknown, drop traffic. */ if (!is_specified) { - rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ACTION_NUM, actions, - "Action is unspecified"); - return -rte_errno; + flow->spec.template.efs_dmaq_id = + EFX_FILTER_SPEC_RX_DMAQ_ID_DROP; } return 0; diff --git a/drivers/net/tap/tap_flow.c b/drivers/net/tap/tap_flow.c index 3b7a960b0..fe2f94010 100644 --- a/drivers/net/tap/tap_flow.c +++ b/drivers/net/tap/tap_flow.c @@ -1140,6 +1140,7 @@ priv_flow_process(struct pmd_internals *pmd, else goto end; } +actions: for (; actions->type != RTE_FLOW_ACTION_TYPE_END; ++actions) { int err = 0; @@ -1222,6 +1223,16 @@ priv_flow_process(struct pmd_internals *pmd, if (err) goto exit_action_not_supported; } + /* When fate is unknown, drop traffic. */ + if (!action) { + static const struct rte_flow_action drop[] = { + { .type = RTE_FLOW_ACTION_TYPE_DROP, }, + { .type = RTE_FLOW_ACTION_TYPE_END, }, + }; + + actions = drop; + goto actions; + } end: if (flow) tap_nlattr_nested_finish(&flow->msg); /* nested TCA_OPTIONS */ diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index 6ace24ff4..96184f030 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -859,32 +859,28 @@ struct rte_flow_item { * * Each possible action is represented by a type. Some have associated * configuration structures. Several actions combined in a list can be - * affected to a flow rule. That list is not ordered. + * assigned to a flow rule and are performed in order. * * They fall in three categories: * - * - Terminating actions that prevent processing matched packets by - * subsequent flow rules, unless overridden with PASSTHRU. + * - Actions that modify the fate of matching traffic, for instance by + * dropping or assigning it a specific destination. * - * - Non terminating actions that leave matched packets up for additional - * processing by subsequent flow rules. + * - Actions that modify matching traffic contents or its properties. This + * includes adding/removing encapsulation, encryption, compression and + * marks. * - * - Other non terminating meta actions that do not affect the fate of - * packets. + * - Actions related to the flow rule itself, such as updating counters or + * making it non-terminating. * - * When several actions are combined in a flow rule, they should all have - * different types (e.g. dropping a packet twice is not possible). + * Flow rules being terminating by default, not specifying any action of the + * fate kind results in undefined behavior. This applies to both ingress and + * egress. * - * Only the last action of a given type is taken into account. PMDs still - * perform error checking on the entire list. - * - * Note that PASSTHRU is the only action able to override a terminating - * rule. + * PASSTHRU, when supported, makes a flow rule non-terminating. */ enum rte_flow_action_type { /** - * [META] - * * End marker for action lists. Prevents further processing of * actions, thereby ending the list. * @@ -893,8 +889,6 @@ enum rte_flow_action_type { RTE_FLOW_ACTION_TYPE_END, /** - * [META] - * * Used as a placeholder for convenience. It is ignored and simply * discarded by PMDs. * @@ -903,18 +897,14 @@ enum rte_flow_action_type { RTE_FLOW_ACTION_TYPE_VOID, /** - * Leaves packets up for additional processing by subsequent flow - * rules. This is the default when a rule does not contain a - * terminating action, but can be specified to force a rule to - * become non-terminating. + * Leaves traffic up for additional processing by subsequent flow + * rules; makes a flow rule non-terminating. * * No associated configuration structure. */ RTE_FLOW_ACTION_TYPE_PASSTHRU, /** - * [META] - * * Attaches an integer value to packets and sets PKT_RX_FDIR and * PKT_RX_FDIR_ID mbuf flags. * @@ -923,8 +913,6 @@ enum rte_flow_action_type { RTE_FLOW_ACTION_TYPE_MARK, /** - * [META] - * * Flags packets. Similar to MARK without a specific value; only * sets the PKT_RX_FDIR mbuf flag. * @@ -949,9 +937,7 @@ enum rte_flow_action_type { RTE_FLOW_ACTION_TYPE_DROP, /** - * [META] - * - * Enables counters for this rule. + * Enables counters for this flow rule. * * These counters can be retrieved and reset through rte_flow_query(), * see struct rte_flow_query_count. @@ -1020,8 +1006,6 @@ struct rte_flow_action_mark { * RTE_FLOW_ACTION_TYPE_QUEUE * * Assign packets to a given queue index. - * - * Terminating by default. */ struct rte_flow_action_queue { uint16_t index; /**< Queue index to use. */ @@ -1050,8 +1034,6 @@ struct rte_flow_query_count { * Note: RSS hash result is stored in the hash.rss mbuf field which overlaps * hash.fdir.lo. Since the MARK action sets the hash.fdir.hi field only, * both can be requested simultaneously. - * - * Terminating by default. */ struct rte_flow_action_rss { const struct rte_eth_rss_conf *rss_conf; /**< RSS parameters. */ @@ -1069,8 +1051,6 @@ struct rte_flow_action_rss { * and is not guaranteed to work properly if the VF part is matched by a * prior flow rule or if packets are not addressed to a VF in the first * place. - * - * Terminating by default. */ struct rte_flow_action_vf { uint32_t original:1; /**< Use original VF ID if possible. */ @@ -1085,8 +1065,6 @@ struct rte_flow_action_vf { * * Packets matched by items of this type can be either dropped or passed to the * next item with their color set by the MTR object. - * - * Non-terminating by default. */ struct rte_flow_action_meter { uint32_t mtr_id; /**< MTR object ID created with rte_mtr_create(). */ @@ -1116,8 +1094,6 @@ struct rte_flow_action_meter { * direction. * * Multiple flows can be configured to use the same security session. - * - * Non-terminating by default. */ struct rte_flow_action_security { void *security_session; /**< Pointer to security session structure. */ -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v5 06/16] ethdev: remove C99 flexible arrays from flow API 2018-04-19 10:16 ` [dpdk-dev] [PATCH v5 00/16] Flow API overhaul for switch offloads Adrien Mazarguil ` (4 preceding siblings ...) 2018-04-19 10:16 ` [dpdk-dev] [PATCH v5 05/16] ethdev: alter behavior of flow API actions Adrien Mazarguil @ 2018-04-19 10:16 ` Adrien Mazarguil 2018-04-19 10:16 ` [dpdk-dev] [PATCH v5 07/16] ethdev: flatten RSS configuration in " Adrien Mazarguil ` (10 subsequent siblings) 16 siblings, 0 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-19 10:16 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev This patch replaces C99-style flexible arrays in struct rte_flow_action_rss and struct rte_flow_item_raw with standard pointers to the same data. They proved difficult to use in the field (e.g. no possibility of static initialization) and unsuitable for C++ applications. Affected PMDs and examples are updated accordingly. This breaks ABI compatibility for the following public functions: - rte_flow_copy() - rte_flow_create() - rte_flow_query() - rte_flow_validate() Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Acked-by: Thomas Monjalon <thomas@monjalon.net> Acked-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com> --- app/test-pmd/cmdline_flow.c | 117 +++++++++++++++++--------------- app/test-pmd/config.c | 25 ++++--- doc/guides/prog_guide/rte_flow.rst | 18 ++--- drivers/net/mlx4/mlx4_flow.c | 22 +++--- drivers/net/mlx5/mlx5_flow.c | 20 +++--- examples/ipsec-secgw/ipsec.c | 17 ++--- lib/librte_ether/rte_flow.c | 25 ++++--- lib/librte_ether/rte_flow.h | 8 ++- 8 files changed, 135 insertions(+), 117 deletions(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 2ddb08feb..798b7948d 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -179,25 +179,22 @@ enum index { ACTION_METER_ID, }; -/** Size of pattern[] field in struct rte_flow_item_raw. */ -#define ITEM_RAW_PATTERN_SIZE 36 +/** Maximum size for pattern in struct rte_flow_item_raw. */ +#define ITEM_RAW_PATTERN_SIZE 40 /** Storage size for struct rte_flow_item_raw including pattern. */ #define ITEM_RAW_SIZE \ - (offsetof(struct rte_flow_item_raw, pattern) + ITEM_RAW_PATTERN_SIZE) + (sizeof(struct rte_flow_item_raw) + ITEM_RAW_PATTERN_SIZE) /** Maximum number of queue indices in struct rte_flow_action_rss. */ #define ACTION_RSS_QUEUE_NUM 32 /** Storage for struct rte_flow_action_rss including external data. */ -union action_rss_data { +struct action_rss_data { struct rte_flow_action_rss conf; - struct { - uint8_t conf_data[offsetof(struct rte_flow_action_rss, queue)]; - uint16_t queue[ACTION_RSS_QUEUE_NUM]; - struct rte_eth_rss_conf rss_conf; - uint8_t rss_key[RSS_HASH_KEY_LENGTH]; - } s; + uint16_t queue[ACTION_RSS_QUEUE_NUM]; + struct rte_eth_rss_conf rss_conf; + uint8_t rss_key[RSS_HASH_KEY_LENGTH]; }; /** Maximum number of subsequent tokens and arguments on the stack. */ @@ -320,13 +317,6 @@ struct token { .size = sizeof(*((s *)0)->f), \ }) -/** Static initializer for ARGS() with arbitrary size. */ -#define ARGS_ENTRY_USZ(s, f, sz) \ - (&(const struct arg){ \ - .offset = offsetof(s, f), \ - .size = (sz), \ - }) - /** Static initializer for ARGS() with arbitrary offset and size. */ #define ARGS_ENTRY_ARB(o, s) \ (&(const struct arg){ \ @@ -1105,9 +1095,9 @@ static const struct token token_list[] = { NEXT_ENTRY(ITEM_PARAM_IS, ITEM_PARAM_SPEC, ITEM_PARAM_MASK)), - .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, length), - ARGS_ENTRY_USZ(struct rte_flow_item_raw, - pattern, + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, pattern), + ARGS_ENTRY(struct rte_flow_item_raw, length), + ARGS_ENTRY_ARB(sizeof(struct rte_flow_item_raw), ITEM_RAW_PATTERN_SIZE)), }, [ITEM_ETH] = { @@ -1591,7 +1581,7 @@ static const struct token token_list[] = { [ACTION_RSS] = { .name = "rss", .help = "spread packets among several queues", - .priv = PRIV_ACTION(RSS, sizeof(union action_rss_data)), + .priv = PRIV_ACTION(RSS, sizeof(struct action_rss_data)), .next = NEXT(action_rss), .call = parse_vc_action_rss, }, @@ -1610,23 +1600,21 @@ static const struct token token_list[] = { .name = "key", .help = "RSS hash key", .next = NEXT(action_rss, NEXT_ENTRY(STRING)), - .args = ARGS(ARGS_ENTRY_ARB - (((uintptr_t)&((union action_rss_data *)0)-> - s.rss_conf.rss_key_len), + .args = ARGS(ARGS_ENTRY_ARB(0, 0), + ARGS_ENTRY_ARB + (offsetof(struct action_rss_data, rss_conf) + + offsetof(struct rte_eth_rss_conf, rss_key_len), sizeof(((struct rte_eth_rss_conf *)0)-> rss_key_len)), - ARGS_ENTRY_ARB - (((uintptr_t)((union action_rss_data *)0)-> - s.rss_key), - RSS_HASH_KEY_LENGTH)), + ARGS_ENTRY(struct action_rss_data, rss_key)), }, [ACTION_RSS_KEY_LEN] = { .name = "key_len", .help = "RSS hash key length in bytes", .next = NEXT(action_rss, NEXT_ENTRY(UNSIGNED)), .args = ARGS(ARGS_ENTRY_ARB_BOUNDED - (((uintptr_t)&((union action_rss_data *)0)-> - s.rss_conf.rss_key_len), + (offsetof(struct action_rss_data, rss_conf) + + offsetof(struct rte_eth_rss_conf, rss_key_len), sizeof(((struct rte_eth_rss_conf *)0)-> rss_key_len), 0, @@ -2067,7 +2055,7 @@ parse_vc_action_rss(struct context *ctx, const struct token *token, { struct buffer *out = buf; struct rte_flow_action *action; - union action_rss_data *action_rss_data; + struct action_rss_data *action_rss_data; unsigned int i; int ret; @@ -2085,29 +2073,29 @@ parse_vc_action_rss(struct context *ctx, const struct token *token, ctx->objmask = NULL; /* Set up default configuration. */ action_rss_data = ctx->object; - *action_rss_data = (union action_rss_data){ + *action_rss_data = (struct action_rss_data){ .conf = (struct rte_flow_action_rss){ - .rss_conf = &action_rss_data->s.rss_conf, + .rss_conf = &action_rss_data->rss_conf, .num = RTE_MIN(nb_rxq, ACTION_RSS_QUEUE_NUM), + .queue = action_rss_data->queue, }, + .queue = { 0 }, + .rss_conf = (struct rte_eth_rss_conf){ + .rss_key = action_rss_data->rss_key, + .rss_key_len = sizeof(action_rss_data->rss_key), + .rss_hf = rss_hf, + }, + .rss_key = "testpmd's default RSS hash key", }; - action_rss_data->s.rss_conf = (struct rte_eth_rss_conf){ - .rss_key = action_rss_data->s.rss_key, - .rss_key_len = sizeof(action_rss_data->s.rss_key), - .rss_hf = rss_hf, - }; - strncpy((void *)action_rss_data->s.rss_key, - "testpmd's default RSS hash key", - sizeof(action_rss_data->s.rss_key)); for (i = 0; i < action_rss_data->conf.num; ++i) - action_rss_data->conf.queue[i] = i; + action_rss_data->queue[i] = i; if (!port_id_is_invalid(ctx->port, DISABLED_WARN) && ctx->port != (portid_t)RTE_PORT_ALL) { struct rte_eth_dev_info info; rte_eth_dev_info_get(ctx->port, &info); - action_rss_data->s.rss_conf.rss_key_len = - RTE_MIN(sizeof(action_rss_data->s.rss_key), + action_rss_data->rss_conf.rss_key_len = + RTE_MIN(sizeof(action_rss_data->rss_key), info.hash_key_size); } action->conf = &action_rss_data->conf; @@ -2125,7 +2113,7 @@ parse_vc_action_rss_type(struct context *ctx, const struct token *token, void *buf, unsigned int size) { static const enum index next[] = NEXT_ENTRY(ACTION_RSS_TYPE); - union action_rss_data *action_rss_data; + struct action_rss_data *action_rss_data; unsigned int i; (void)token; @@ -2135,7 +2123,7 @@ parse_vc_action_rss_type(struct context *ctx, const struct token *token, return -1; if (!(ctx->objdata >> 16) && ctx->object) { action_rss_data = ctx->object; - action_rss_data->s.rss_conf.rss_hf = 0; + action_rss_data->rss_conf.rss_hf = 0; } if (!strcmp_partial("end", str, len)) { ctx->objdata &= 0xffff; @@ -2154,7 +2142,7 @@ parse_vc_action_rss_type(struct context *ctx, const struct token *token, if (!ctx->object) return len; action_rss_data = ctx->object; - action_rss_data->s.rss_conf.rss_hf |= rss_type_table[i].rss_type; + action_rss_data->rss_conf.rss_hf |= rss_type_table[i].rss_type; return len; } @@ -2169,7 +2157,7 @@ parse_vc_action_rss_queue(struct context *ctx, const struct token *token, void *buf, unsigned int size) { static const enum index next[] = NEXT_ENTRY(ACTION_RSS_QUEUE); - union action_rss_data *action_rss_data; + struct action_rss_data *action_rss_data; int ret; int i; @@ -2186,10 +2174,9 @@ parse_vc_action_rss_queue(struct context *ctx, const struct token *token, if (i >= ACTION_RSS_QUEUE_NUM) return -1; if (push_args(ctx, - ARGS_ENTRY_ARB(offsetof(struct rte_flow_action_rss, - queue) + - i * sizeof(action_rss_data->s.queue[i]), - sizeof(action_rss_data->s.queue[i])))) + ARGS_ENTRY_ARB(offsetof(struct action_rss_data, queue) + + i * sizeof(action_rss_data->queue[i]), + sizeof(action_rss_data->queue[i])))) return -1; ret = parse_int(ctx, token, str, len, NULL, 0); if (ret < 0) { @@ -2206,6 +2193,7 @@ parse_vc_action_rss_queue(struct context *ctx, const struct token *token, return len; action_rss_data = ctx->object; action_rss_data->conf.num = i; + action_rss_data->conf.queue = i ? action_rss_data->queue : NULL; return len; } @@ -2483,8 +2471,8 @@ parse_int(struct context *ctx, const struct token *token, /** * Parse a string. * - * Two arguments (ctx->args) are retrieved from the stack to store data and - * its length (in that order). + * Three arguments (ctx->args) are retrieved from the stack to store data, + * its actual length and address (in that order). */ static int parse_string(struct context *ctx, const struct token *token, @@ -2493,6 +2481,7 @@ parse_string(struct context *ctx, const struct token *token, { const struct arg *arg_data = pop_args(ctx); const struct arg *arg_len = pop_args(ctx); + const struct arg *arg_addr = pop_args(ctx); char tmp[16]; /* Ought to be enough. */ int ret; @@ -2503,6 +2492,11 @@ parse_string(struct context *ctx, const struct token *token, push_args(ctx, arg_data); return -1; } + if (!arg_addr) { + push_args(ctx, arg_len); + push_args(ctx, arg_data); + return -1; + } size = arg_data->size; /* Bit-mask fill is not supported. */ if (arg_data->mask || size < len) @@ -2525,8 +2519,23 @@ parse_string(struct context *ctx, const struct token *token, memset((uint8_t *)buf + len, 0x00, size - len); if (ctx->objmask) memset((uint8_t *)ctx->objmask + arg_data->offset, 0xff, len); + /* Save address if requested. */ + if (arg_addr->size) { + memcpy((uint8_t *)ctx->object + arg_addr->offset, + (void *[]){ + (uint8_t *)ctx->object + arg_data->offset + }, + arg_addr->size); + if (ctx->objmask) + memcpy((uint8_t *)ctx->objmask + arg_addr->offset, + (void *[]){ + (uint8_t *)ctx->objmask + arg_data->offset + }, + arg_addr->size); + } return len; error: + push_args(ctx, arg_addr); push_args(ctx, arg_len); push_args(ctx, arg_data); return -1; diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index d0d372797..95618e4eb 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -977,7 +977,7 @@ static const struct { MK_FLOW_ITEM(PF, 0), MK_FLOW_ITEM(VF, sizeof(struct rte_flow_item_vf)), MK_FLOW_ITEM(PORT, sizeof(struct rte_flow_item_port)), - MK_FLOW_ITEM(RAW, sizeof(struct rte_flow_item_raw)), /* +pattern[] */ + MK_FLOW_ITEM(RAW, sizeof(struct rte_flow_item_raw)), MK_FLOW_ITEM(ETH, sizeof(struct rte_flow_item_eth)), MK_FLOW_ITEM(VLAN, sizeof(struct rte_flow_item_vlan)), MK_FLOW_ITEM(IPV4, sizeof(struct rte_flow_item_ipv4)), @@ -1026,14 +1026,20 @@ flow_item_spec_copy(void *buf, const struct rte_flow_item *item, union { struct rte_flow_item_raw *raw; } dst; + size_t off; case RTE_FLOW_ITEM_TYPE_RAW: src.raw = item_spec; dst.raw = buf; - size = offsetof(struct rte_flow_item_raw, pattern) + - src.raw->length * sizeof(*src.raw->pattern); - if (dst.raw) - memcpy(dst.raw, src.raw, size); + off = RTE_ALIGN_CEIL(sizeof(struct rte_flow_item_raw), + sizeof(*src.raw->pattern)); + size = off + src.raw->length * sizeof(*src.raw->pattern); + if (dst.raw) { + memcpy(dst.raw, src.raw, sizeof(*src.raw)); + dst.raw->pattern = memcpy((uint8_t *)dst.raw + off, + src.raw->pattern, + size - off); + } break; default: size = flow_item[item->type].size; @@ -1065,7 +1071,7 @@ static const struct { MK_FLOW_ACTION(QUEUE, sizeof(struct rte_flow_action_queue)), MK_FLOW_ACTION(DROP, 0), MK_FLOW_ACTION(COUNT, 0), - MK_FLOW_ACTION(RSS, sizeof(struct rte_flow_action_rss)), /* +queue[] */ + MK_FLOW_ACTION(RSS, sizeof(struct rte_flow_action_rss)), MK_FLOW_ACTION(PF, 0), MK_FLOW_ACTION(VF, sizeof(struct rte_flow_action_vf)), MK_FLOW_ACTION(METER, sizeof(struct rte_flow_action_meter)), @@ -1096,11 +1102,14 @@ flow_action_conf_copy(void *buf, const struct rte_flow_action *action) *dst.rss = (struct rte_flow_action_rss){ .num = src.rss->num, }; - off += offsetof(struct rte_flow_action_rss, queue); + off += sizeof(*src.rss); if (src.rss->num) { + off = RTE_ALIGN_CEIL(off, sizeof(double)); size = sizeof(*src.rss->queue) * src.rss->num; if (dst.rss) - memcpy(dst.rss->queue, src.rss->queue, size); + dst.rss->queue = memcpy + ((void *)((uintptr_t)dst.rss + off), + src.rss->queue, size); off += size; } off = RTE_ALIGN_CEIL(off, sizeof(double)); diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 80360d068..acbeaacbd 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -1309,15 +1309,15 @@ field only, both can be requested simultaneously. .. table:: RSS - +--------------+------------------------------+ - | Field | Value | - +==============+==============================+ - | ``rss_conf`` | RSS parameters | - +--------------+------------------------------+ - | ``num`` | number of entries in queue[] | - +--------------+------------------------------+ - | ``queue[]`` | queue indices to use | - +--------------+------------------------------+ + +--------------+--------------------------------+ + | Field | Value | + +==============+================================+ + | ``rss_conf`` | RSS parameters | + +--------------+--------------------------------+ + | ``num`` | number of entries in ``queue`` | + +--------------+--------------------------------+ + | ``queue`` | queue indices to use | + +--------------+--------------------------------+ Action: ``PF`` ^^^^^^^^^^^^^^ diff --git a/drivers/net/mlx4/mlx4_flow.c b/drivers/net/mlx4/mlx4_flow.c index 15cdf07b7..8feb6ae31 100644 --- a/drivers/net/mlx4/mlx4_flow.c +++ b/drivers/net/mlx4/mlx4_flow.c @@ -1282,14 +1282,16 @@ mlx4_flow_internal(struct priv *priv, struct rte_flow_error *error) */ uint32_t queues = rte_align32pow2(priv->dev->data->nb_rx_queues + 1) >> 1; - alignas(struct rte_flow_action_rss) uint8_t rss_conf_data - [offsetof(struct rte_flow_action_rss, queue) + - sizeof(((struct rte_flow_action_rss *)0)->queue[0]) * queues]; - struct rte_flow_action_rss *rss_conf = (void *)rss_conf_data; + uint16_t queue[queues]; + struct rte_flow_action_rss action_rss = { + .rss_conf = NULL, /* Rely on default fallback settings. */ + .num = queues, + .queue = queue, + }; struct rte_flow_action actions[] = { { .type = RTE_FLOW_ACTION_TYPE_RSS, - .conf = rss_conf, + .conf = &action_rss, }, { .type = RTE_FLOW_ACTION_TYPE_END, @@ -1311,12 +1313,8 @@ mlx4_flow_internal(struct priv *priv, struct rte_flow_error *error) if (!queues) goto error; /* Prepare default RSS configuration. */ - *rss_conf = (struct rte_flow_action_rss){ - .rss_conf = NULL, /* Rely on default fallback settings. */ - .num = queues, - }; for (i = 0; i != queues; ++i) - rss_conf->queue[i] = i; + queue[i] = i; /* * Set up VLAN item if filtering is enabled and at least one VLAN * filter is configured. @@ -1375,7 +1373,7 @@ mlx4_flow_internal(struct priv *priv, struct rte_flow_error *error) if (j != sizeof(mac->addr_bytes)) continue; if (flow->rss->queues != queues || - memcmp(flow->rss->queue_id, rss_conf->queue, + memcmp(flow->rss->queue_id, action_rss.queue, queues * sizeof(flow->rss->queue_id[0]))) continue; break; @@ -1415,7 +1413,7 @@ mlx4_flow_internal(struct priv *priv, struct rte_flow_error *error) if (flow && flow->internal) { assert(flow->rss); if (flow->rss->queues != queues || - memcmp(flow->rss->queue_id, rss_conf->queue, + memcmp(flow->rss->queue_id, action_rss.queue, queues * sizeof(flow->rss->queue_id[0]))) flow = NULL; } diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 8b156667c..679fdf318 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -2446,9 +2446,16 @@ mlx5_ctrl_flow_vlan(struct rte_eth_dev *dev, .type = RTE_FLOW_ITEM_TYPE_END, }, }; + uint16_t queue[priv->reta_idx_n]; + struct rte_flow_action_rss action_rss = { + .rss_conf = &priv->rss_conf, + .num = priv->reta_idx_n, + .queue = queue, + }; struct rte_flow_action actions[] = { { .type = RTE_FLOW_ACTION_TYPE_RSS, + .conf = &action_rss, }, { .type = RTE_FLOW_ACTION_TYPE_END, @@ -2457,24 +2464,13 @@ mlx5_ctrl_flow_vlan(struct rte_eth_dev *dev, struct rte_flow *flow; struct rte_flow_error error; unsigned int i; - union { - struct rte_flow_action_rss rss; - struct { - const struct rte_eth_rss_conf *rss_conf; - uint16_t num; - uint16_t queue[RTE_MAX_QUEUES_PER_PORT]; - } local; - } action_rss; if (!priv->reta_idx_n) { rte_errno = EINVAL; return -rte_errno; } for (i = 0; i != priv->reta_idx_n; ++i) - action_rss.local.queue[i] = (*priv->reta_idx)[i]; - action_rss.local.rss_conf = &priv->rss_conf; - action_rss.local.num = priv->reta_idx_n; - actions[0].conf = (const void *)&action_rss.rss; + queue[i] = (*priv->reta_idx)[i]; flow = mlx5_flow_list_create(dev, &priv->ctrl_flows, &attr, items, actions, &error); if (!flow) diff --git a/examples/ipsec-secgw/ipsec.c b/examples/ipsec-secgw/ipsec.c index 5fb5bc16e..8b2047adb 100644 --- a/examples/ipsec-secgw/ipsec.c +++ b/examples/ipsec-secgw/ipsec.c @@ -186,14 +186,8 @@ create_session(struct ipsec_ctx *ipsec_ctx, struct ipsec_sa *sa) .rss_key_len = 40, }; struct rte_eth_dev *eth_dev; - union { - struct rte_flow_action_rss rss; - struct { - const struct rte_eth_rss_conf *rss_conf; - uint16_t num; - uint16_t queue[RTE_MAX_QUEUES_PER_PORT]; - } local; - } action_rss; + uint16_t queue[RTE_MAX_QUEUES_PER_PORT]; + struct rte_flow_action_rss action_rss; unsigned int i; unsigned int j; @@ -207,9 +201,10 @@ create_session(struct ipsec_ctx *ipsec_ctx, struct ipsec_sa *sa) for (i = 0, j = 0; i < eth_dev->data->nb_rx_queues; ++i) if (eth_dev->data->rx_queues[i]) - action_rss.local.queue[j++] = i; - action_rss.local.num = j; - action_rss.local.rss_conf = &rss_conf; + queue[j++] = i; + action_rss.rss_conf = &rss_conf; + action_rss.num = j; + action_rss.queue = queue; ret = rte_flow_validate(sa->portid, &sa->attr, sa->pattern, sa->action, &err); diff --git a/lib/librte_ether/rte_flow.c b/lib/librte_ether/rte_flow.c index 80f9cb6cb..bb19e28c6 100644 --- a/lib/librte_ether/rte_flow.c +++ b/lib/librte_ether/rte_flow.c @@ -39,7 +39,7 @@ static const struct rte_flow_desc_data rte_flow_desc_item[] = { MK_FLOW_ITEM(PF, 0), MK_FLOW_ITEM(VF, sizeof(struct rte_flow_item_vf)), MK_FLOW_ITEM(PORT, sizeof(struct rte_flow_item_port)), - MK_FLOW_ITEM(RAW, sizeof(struct rte_flow_item_raw)), /* +pattern[] */ + MK_FLOW_ITEM(RAW, sizeof(struct rte_flow_item_raw)), MK_FLOW_ITEM(ETH, sizeof(struct rte_flow_item_eth)), MK_FLOW_ITEM(VLAN, sizeof(struct rte_flow_item_vlan)), MK_FLOW_ITEM(IPV4, sizeof(struct rte_flow_item_ipv4)), @@ -73,7 +73,7 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = { MK_FLOW_ACTION(QUEUE, sizeof(struct rte_flow_action_queue)), MK_FLOW_ACTION(DROP, 0), MK_FLOW_ACTION(COUNT, 0), - MK_FLOW_ACTION(RSS, sizeof(struct rte_flow_action_rss)), /* +queue[] */ + MK_FLOW_ACTION(RSS, sizeof(struct rte_flow_action_rss)), MK_FLOW_ACTION(PF, 0), MK_FLOW_ACTION(VF, sizeof(struct rte_flow_action_vf)), }; @@ -282,14 +282,20 @@ flow_item_spec_copy(void *buf, const struct rte_flow_item *item, union { struct rte_flow_item_raw *raw; } dst; + size_t off; case RTE_FLOW_ITEM_TYPE_RAW: src.raw = item_spec; dst.raw = buf; - size = offsetof(struct rte_flow_item_raw, pattern) + - src.raw->length * sizeof(*src.raw->pattern); - if (dst.raw) - memcpy(dst.raw, src.raw, size); + off = RTE_ALIGN_CEIL(sizeof(struct rte_flow_item_raw), + sizeof(*src.raw->pattern)); + size = off + src.raw->length * sizeof(*src.raw->pattern); + if (dst.raw) { + memcpy(dst.raw, src.raw, sizeof(*src.raw)); + dst.raw->pattern = memcpy((uint8_t *)dst.raw + off, + src.raw->pattern, + size - off); + } break; default: size = rte_flow_desc_item[item->type].size; @@ -326,11 +332,14 @@ flow_action_conf_copy(void *buf, const struct rte_flow_action *action) *dst.rss = (struct rte_flow_action_rss){ .num = src.rss->num, }; - off += offsetof(struct rte_flow_action_rss, queue); + off += sizeof(*src.rss); if (src.rss->num) { + off = RTE_ALIGN_CEIL(off, sizeof(double)); size = sizeof(*src.rss->queue) * src.rss->num; if (dst.rss) - memcpy(dst.rss->queue, src.rss->queue, size); + dst.rss->queue = memcpy + ((void *)((uintptr_t)dst.rss + off), + src.rss->queue, size); off += size; } off = RTE_ALIGN_CEIL(off, sizeof(double)); diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index 96184f030..ad2e55b8e 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -14,6 +14,7 @@ * associated actions in hardware through flow rules. */ +#include <stddef.h> #include <stdint.h> #include <rte_arp.h> @@ -432,7 +433,7 @@ struct rte_flow_item_raw { int32_t offset; /**< Absolute or relative offset for pattern. */ uint16_t limit; /**< Search area limit for start of pattern. */ uint16_t length; /**< Pattern length. */ - uint8_t pattern[]; /**< Byte string to look for. */ + const uint8_t *pattern; /**< Byte string to look for. */ }; /** Default mask for RTE_FLOW_ITEM_TYPE_RAW. */ @@ -444,6 +445,7 @@ static const struct rte_flow_item_raw rte_flow_item_raw_mask = { .offset = 0xffffffff, .limit = 0xffff, .length = 0xffff, + .pattern = NULL, }; #endif @@ -1037,8 +1039,8 @@ struct rte_flow_query_count { */ struct rte_flow_action_rss { const struct rte_eth_rss_conf *rss_conf; /**< RSS parameters. */ - uint16_t num; /**< Number of entries in queue[]. */ - uint16_t queue[]; /**< Queues indices to use. */ + uint16_t num; /**< Number of entries in @p queue. */ + const uint16_t *queue; /**< Queue indices to use. */ }; /** -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v5 07/16] ethdev: flatten RSS configuration in flow API 2018-04-19 10:16 ` [dpdk-dev] [PATCH v5 00/16] Flow API overhaul for switch offloads Adrien Mazarguil ` (5 preceding siblings ...) 2018-04-19 10:16 ` [dpdk-dev] [PATCH v5 06/16] ethdev: remove C99 flexible arrays from flow API Adrien Mazarguil @ 2018-04-19 10:16 ` Adrien Mazarguil 2018-04-23 15:05 ` Nélio Laranjeiro 2018-04-19 10:16 ` [dpdk-dev] [PATCH v5 08/16] ethdev: add hash function to RSS flow API action Adrien Mazarguil ` (9 subsequent siblings) 16 siblings, 1 reply; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-19 10:16 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev Cc: Xueming Li, Wenzhuo Lu, Jingjing Wu, Beilei Xing, Qi Zhang, Konstantin Ananyev, Nelio Laranjeiro, Yongseok Koh, Andrew Rybchenko, Pascal Mazon, Radu Nicolau, Akhil Goyal Since its inception, the rte_flow RSS action has been relying in part on external struct rte_eth_rss_conf for compatibility with the legacy RSS API. This structure lacks parameters such as the hash algorithm to use, and more recently, a method to tell which layer RSS should be performed on [1]. Given struct rte_eth_rss_conf will never be flexible enough to represent a complete RSS configuration (e.g. RETA table), this patch supersedes it by extending the rte_flow RSS action directly. A subsequent patch will add a field to use a non-default RSS hash algorithm. To that end, a field named "types" replaces the field formerly known as "rss_hf" and standing for "RSS hash functions" as it was confusing. Actual RSS hash function types are defined by enum rte_eth_hash_function. This patch updates all PMDs and example applications accordingly. It breaks ABI compatibility for the following public functions: - rte_flow_copy() - rte_flow_create() - rte_flow_query() - rte_flow_validate() [1] commit 676b605182a5 ("doc: announce ethdev API change for RSS configuration") Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Acked-by: Andrew Rybchenko <arybchenko@solarflare.com> Cc: Xueming Li <xuemingl@mellanox.com> Cc: Ferruh Yigit <ferruh.yigit@intel.com> Cc: Thomas Monjalon <thomas@monjalon.net> Cc: Wenzhuo Lu <wenzhuo.lu@intel.com> Cc: Jingjing Wu <jingjing.wu@intel.com> Cc: Beilei Xing <beilei.xing@intel.com> Cc: Qi Zhang <qi.z.zhang@intel.com> Cc: Konstantin Ananyev <konstantin.ananyev@intel.com> Cc: Nelio Laranjeiro <nelio.laranjeiro@6wind.com> Cc: Yongseok Koh <yskoh@mellanox.com> Cc: Andrew Rybchenko <arybchenko@solarflare.com> Cc: Pascal Mazon <pascal.mazon@6wind.com> Cc: Radu Nicolau <radu.nicolau@intel.com> Cc: Akhil Goyal <akhil.goyal@nxp.com> --- v3 changes: Documentation update regarding the meaning of a 0 value for RSS types in flow rules. It used to implicitly mean "no RSS" but is redefined as requesting a kind of "best-effort" mode from PMDs, i.e. anything ranging from empty to all-inclusive RSS; what matters is it provides safe defaults that will work regardless of PMD capabilities. --- app/test-pmd/cmdline_flow.c | 48 +++--- app/test-pmd/config.c | 39 ++--- doc/guides/prog_guide/rte_flow.rst | 28 ++-- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 6 +- drivers/net/e1000/e1000_ethdev.h | 13 +- drivers/net/e1000/igb_ethdev.c | 4 +- drivers/net/e1000/igb_flow.c | 31 ++-- drivers/net/e1000/igb_rxtx.c | 51 +++++- drivers/net/i40e/i40e_ethdev.c | 53 +++++-- drivers/net/i40e/i40e_ethdev.h | 15 +- drivers/net/i40e/i40e_flow.c | 47 +++--- drivers/net/ixgbe/ixgbe_ethdev.c | 4 +- drivers/net/ixgbe/ixgbe_ethdev.h | 13 +- drivers/net/ixgbe/ixgbe_flow.c | 30 ++-- drivers/net/ixgbe/ixgbe_rxtx.c | 51 +++++- drivers/net/mlx4/mlx4.c | 2 +- drivers/net/mlx4/mlx4_flow.c | 61 +++---- drivers/net/mlx4/mlx4_flow.h | 2 +- drivers/net/mlx4/mlx4_rxq.c | 2 +- drivers/net/mlx4/mlx4_rxtx.h | 2 +- drivers/net/mlx5/mlx5_flow.c | 193 +++++++++++------------ drivers/net/mlx5/mlx5_rxq.c | 22 +-- drivers/net/mlx5/mlx5_rxtx.h | 26 +-- drivers/net/sfc/sfc_flow.c | 21 ++- drivers/net/tap/tap_flow.c | 8 +- examples/ipsec-secgw/ipsec.c | 10 +- lib/librte_ether/rte_flow.c | 39 ++--- lib/librte_ether/rte_flow.h | 12 +- 28 files changed, 478 insertions(+), 355 deletions(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 798b7948d..c9c2c3ad9 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -192,9 +192,8 @@ enum index { /** Storage for struct rte_flow_action_rss including external data. */ struct action_rss_data { struct rte_flow_action_rss conf; + uint8_t key[RSS_HASH_KEY_LENGTH]; uint16_t queue[ACTION_RSS_QUEUE_NUM]; - struct rte_eth_rss_conf rss_conf; - uint8_t rss_key[RSS_HASH_KEY_LENGTH]; }; /** Maximum number of subsequent tokens and arguments on the stack. */ @@ -1587,7 +1586,7 @@ static const struct token token_list[] = { }, [ACTION_RSS_TYPES] = { .name = "types", - .help = "RSS hash types", + .help = "specific RSS hash types", .next = NEXT(action_rss, NEXT_ENTRY(ACTION_RSS_TYPE)), }, [ACTION_RSS_TYPE] = { @@ -1602,21 +1601,21 @@ static const struct token token_list[] = { .next = NEXT(action_rss, NEXT_ENTRY(STRING)), .args = ARGS(ARGS_ENTRY_ARB(0, 0), ARGS_ENTRY_ARB - (offsetof(struct action_rss_data, rss_conf) + - offsetof(struct rte_eth_rss_conf, rss_key_len), - sizeof(((struct rte_eth_rss_conf *)0)-> - rss_key_len)), - ARGS_ENTRY(struct action_rss_data, rss_key)), + (offsetof(struct action_rss_data, conf) + + offsetof(struct rte_flow_action_rss, key_len), + sizeof(((struct rte_flow_action_rss *)0)-> + key_len)), + ARGS_ENTRY(struct action_rss_data, key)), }, [ACTION_RSS_KEY_LEN] = { .name = "key_len", .help = "RSS hash key length in bytes", .next = NEXT(action_rss, NEXT_ENTRY(UNSIGNED)), .args = ARGS(ARGS_ENTRY_ARB_BOUNDED - (offsetof(struct action_rss_data, rss_conf) + - offsetof(struct rte_eth_rss_conf, rss_key_len), - sizeof(((struct rte_eth_rss_conf *)0)-> - rss_key_len), + (offsetof(struct action_rss_data, conf) + + offsetof(struct rte_flow_action_rss, key_len), + sizeof(((struct rte_flow_action_rss *)0)-> + key_len), 0, RSS_HASH_KEY_LENGTH)), }, @@ -2075,27 +2074,24 @@ parse_vc_action_rss(struct context *ctx, const struct token *token, action_rss_data = ctx->object; *action_rss_data = (struct action_rss_data){ .conf = (struct rte_flow_action_rss){ - .rss_conf = &action_rss_data->rss_conf, - .num = RTE_MIN(nb_rxq, ACTION_RSS_QUEUE_NUM), + .types = rss_hf, + .key_len = sizeof(action_rss_data->key), + .queue_num = RTE_MIN(nb_rxq, ACTION_RSS_QUEUE_NUM), + .key = action_rss_data->key, .queue = action_rss_data->queue, }, + .key = "testpmd's default RSS hash key", .queue = { 0 }, - .rss_conf = (struct rte_eth_rss_conf){ - .rss_key = action_rss_data->rss_key, - .rss_key_len = sizeof(action_rss_data->rss_key), - .rss_hf = rss_hf, - }, - .rss_key = "testpmd's default RSS hash key", }; - for (i = 0; i < action_rss_data->conf.num; ++i) + for (i = 0; i < action_rss_data->conf.queue_num; ++i) action_rss_data->queue[i] = i; if (!port_id_is_invalid(ctx->port, DISABLED_WARN) && ctx->port != (portid_t)RTE_PORT_ALL) { struct rte_eth_dev_info info; rte_eth_dev_info_get(ctx->port, &info); - action_rss_data->rss_conf.rss_key_len = - RTE_MIN(sizeof(action_rss_data->rss_key), + action_rss_data->conf.key_len = + RTE_MIN(sizeof(action_rss_data->key), info.hash_key_size); } action->conf = &action_rss_data->conf; @@ -2123,7 +2119,7 @@ parse_vc_action_rss_type(struct context *ctx, const struct token *token, return -1; if (!(ctx->objdata >> 16) && ctx->object) { action_rss_data = ctx->object; - action_rss_data->rss_conf.rss_hf = 0; + action_rss_data->conf.types = 0; } if (!strcmp_partial("end", str, len)) { ctx->objdata &= 0xffff; @@ -2142,7 +2138,7 @@ parse_vc_action_rss_type(struct context *ctx, const struct token *token, if (!ctx->object) return len; action_rss_data = ctx->object; - action_rss_data->rss_conf.rss_hf |= rss_type_table[i].rss_type; + action_rss_data->conf.types |= rss_type_table[i].rss_type; return len; } @@ -2192,7 +2188,7 @@ parse_vc_action_rss_queue(struct context *ctx, const struct token *token, if (!ctx->object) return len; action_rss_data = ctx->object; - action_rss_data->conf.num = i; + action_rss_data->conf.queue_num = i; action_rss_data->conf.queue = i ? action_rss_data->queue : NULL; return len; } diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 95618e4eb..3da09536a 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -1100,40 +1100,27 @@ flow_action_conf_copy(void *buf, const struct rte_flow_action *action) off = 0; if (dst.rss) *dst.rss = (struct rte_flow_action_rss){ - .num = src.rss->num, + .types = src.rss->types, + .key_len = src.rss->key_len, + .queue_num = src.rss->queue_num, }; off += sizeof(*src.rss); - if (src.rss->num) { + if (src.rss->key_len) { off = RTE_ALIGN_CEIL(off, sizeof(double)); - size = sizeof(*src.rss->queue) * src.rss->num; + size = sizeof(*src.rss->key) * src.rss->key_len; if (dst.rss) - dst.rss->queue = memcpy + dst.rss->key = memcpy ((void *)((uintptr_t)dst.rss + off), - src.rss->queue, size); + src.rss->key, size); off += size; } - off = RTE_ALIGN_CEIL(off, sizeof(double)); - if (dst.rss) { - dst.rss->rss_conf = (void *)((uintptr_t)dst.rss + off); - *(struct rte_eth_rss_conf *)(uintptr_t) - dst.rss->rss_conf = (struct rte_eth_rss_conf){ - .rss_key_len = src.rss->rss_conf->rss_key_len, - .rss_hf = src.rss->rss_conf->rss_hf, - }; - } - off += sizeof(*src.rss->rss_conf); - if (src.rss->rss_conf->rss_key_len) { + if (src.rss->queue_num) { off = RTE_ALIGN_CEIL(off, sizeof(double)); - size = sizeof(*src.rss->rss_conf->rss_key) * - src.rss->rss_conf->rss_key_len; - if (dst.rss) { - ((struct rte_eth_rss_conf *)(uintptr_t) - dst.rss->rss_conf)->rss_key = - (void *)((uintptr_t)dst.rss + off); - memcpy(dst.rss->rss_conf->rss_key, - src.rss->rss_conf->rss_key, - size); - } + size = sizeof(*src.rss->queue) * src.rss->queue_num; + if (dst.rss) + dst.rss->queue = memcpy + ((void *)((uintptr_t)dst.rss + off), + src.rss->queue, size); off += size; } size = off; diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index acbeaacbd..cf252eeba 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -1301,6 +1301,12 @@ Action: ``RSS`` Similar to QUEUE, except RSS is additionally performed on packets to spread them among several queues according to the provided parameters. +Unlike global RSS settings used by other DPDK APIs, unsetting the ``types`` +field does not disable RSS in a flow rule. Doing so instead requests safe +unspecified "best-effort" settings from the underlying PMD, which depending +on the flow rule, may result in anything ranging from empty (single queue) +to all-inclusive RSS. + Note: RSS hash result is stored in the ``hash.rss`` mbuf field which overlaps ``hash.fdir.lo``. Since `Action: MARK`_ sets the ``hash.fdir.hi`` field only, both can be requested simultaneously. @@ -1309,15 +1315,19 @@ field only, both can be requested simultaneously. .. table:: RSS - +--------------+--------------------------------+ - | Field | Value | - +==============+================================+ - | ``rss_conf`` | RSS parameters | - +--------------+--------------------------------+ - | ``num`` | number of entries in ``queue`` | - +--------------+--------------------------------+ - | ``queue`` | queue indices to use | - +--------------+--------------------------------+ + +---------------+---------------------------------------------+ + | Field | Value | + +===============+=============================================+ + | ``types`` | specific RSS hash types (see ``ETH_RSS_*``) | + +---------------+---------------------------------------------+ + | ``key_len`` | hash key length in bytes | + +---------------+---------------------------------------------+ + | ``queue_num`` | number of entries in ``queue`` | + +---------------+---------------------------------------------+ + | ``key`` | hash key | + +---------------+---------------------------------------------+ + | ``queue`` | queue indices to use | + +---------------+---------------------------------------------+ Action: ``PF`` ^^^^^^^^^^^^^^ diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index a015d02a4..17336d163 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3398,8 +3398,10 @@ This section lists supported actions and their attributes, if any. - ``rss``: spread packets among several queues. - - ``types [{RSS hash type} [...]] end``: RSS hash types, allowed tokens - are the same as `set_hash_input_set`_, an empty list means none (0). + - ``types [{RSS hash type} [...]] end``: specific RSS hash types, allowed + tokens are the same as `set_hash_input_set`_, except that an empty list + does not disable RSS but instead requests unspecified "best-effort" + settings. - ``key {string}``: RSS hash key, overrides ``key_len``. diff --git a/drivers/net/e1000/e1000_ethdev.h b/drivers/net/e1000/e1000_ethdev.h index 6354b894a..902001f36 100644 --- a/drivers/net/e1000/e1000_ethdev.h +++ b/drivers/net/e1000/e1000_ethdev.h @@ -4,6 +4,10 @@ #ifndef _E1000_ETHDEV_H_ #define _E1000_ETHDEV_H_ + +#include <stdint.h> + +#include <rte_flow.h> #include <rte_time.h> #include <rte_pci.h> @@ -27,6 +31,7 @@ #define E1000_CTRL_EXT_EXTEND_VLAN (1<<26) /* EXTENDED VLAN */ #define IGB_VFTA_SIZE 128 +#define IGB_HKEY_MAX_INDEX 10 #define IGB_MAX_RX_QUEUE_NUM 8 #define IGB_MAX_RX_QUEUE_NUM_82576 16 @@ -229,8 +234,8 @@ struct igb_ethertype_filter { }; struct igb_rte_flow_rss_conf { - struct rte_eth_rss_conf rss_conf; /**< RSS parameters. */ - uint16_t num; /**< Number of entries in queue[]. */ + struct rte_flow_action_rss conf; /**< RSS parameters. */ + uint8_t key[IGB_HKEY_MAX_INDEX * sizeof(uint32_t)]; /* Hash key. */ uint16_t queue[IGB_MAX_RX_QUEUE_NUM]; /**< Queues indices to use. */ }; @@ -501,6 +506,10 @@ int eth_igb_syn_filter_set(struct rte_eth_dev *dev, int eth_igb_add_del_flex_filter(struct rte_eth_dev *dev, struct rte_eth_flex_filter *filter, bool add); +int igb_rss_conf_init(struct igb_rte_flow_rss_conf *out, + const struct rte_flow_action_rss *in); +int igb_action_rss_same(const struct rte_flow_action_rss *comp, + const struct rte_flow_action_rss *with); int igb_config_rss_filter(struct rte_eth_dev *dev, struct igb_rte_flow_rss_conf *conf, bool add); diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c index 9b808a982..7e9935b7e 100644 --- a/drivers/net/e1000/igb_ethdev.c +++ b/drivers/net/e1000/igb_ethdev.c @@ -41,8 +41,6 @@ #define IGB_DEFAULT_TX_HTHRESH 1 #define IGB_DEFAULT_TX_WTHRESH ((hw->mac.type == e1000_82576) ? 1 : 16) -#define IGB_HKEY_MAX_INDEX 10 - /* Bit shift and mask */ #define IGB_4_BIT_WIDTH (CHAR_BIT / 2) #define IGB_4_BIT_MASK RTE_LEN2MASK(IGB_4_BIT_WIDTH, uint8_t) @@ -5576,7 +5574,7 @@ igb_rss_filter_restore(struct rte_eth_dev *dev) struct e1000_filter_info *filter_info = E1000_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private); - if (filter_info->rss_info.num) + if (filter_info->rss_info.conf.queue_num) igb_config_rss_filter(dev, &filter_info->rss_info, TRUE); } diff --git a/drivers/net/e1000/igb_flow.c b/drivers/net/e1000/igb_flow.c index c0f5b5190..8dc5f75f2 100644 --- a/drivers/net/e1000/igb_flow.c +++ b/drivers/net/e1000/igb_flow.c @@ -1292,7 +1292,7 @@ igb_parse_rss_filter(struct rte_eth_dev *dev, rss = (const struct rte_flow_action_rss *)act->conf; - if (!rss || !rss->num) { + if (!rss || !rss->queue_num) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, act, @@ -1300,7 +1300,7 @@ igb_parse_rss_filter(struct rte_eth_dev *dev, return -rte_errno; } - for (n = 0; n < rss->num; n++) { + for (n = 0; n < rss->queue_num; n++) { if (rss->queue[n] >= dev->data->nb_rx_queues) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, @@ -1310,14 +1310,18 @@ igb_parse_rss_filter(struct rte_eth_dev *dev, } } - if (rss->rss_conf) - rss_conf->rss_conf = *rss->rss_conf; - else - rss_conf->rss_conf.rss_hf = IGB_RSS_OFFLOAD_ALL; - - for (n = 0; n < rss->num; ++n) - rss_conf->queue[n] = rss->queue[n]; - rss_conf->num = rss->num; + if (rss->key_len && rss->key_len != RTE_DIM(rss_conf->key)) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, + "RSS hash key must be exactly 40 bytes"); + if (rss->queue_num > RTE_DIM(rss_conf->queue)) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, + "too many queues for RSS context"); + if (igb_rss_conf_init(rss_conf, rss)) + return rte_flow_error_set + (error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, act, + "RSS context initialization failure"); /* check if the next not void item is END */ index++; @@ -1518,9 +1522,8 @@ igb_flow_create(struct rte_eth_dev *dev, PMD_DRV_LOG(ERR, "failed to allocate memory"); goto out; } - rte_memcpy(&rss_filter_ptr->filter_info, - &rss_conf, - sizeof(struct igb_rte_flow_rss_conf)); + igb_rss_conf_init(&rss_filter_ptr->filter_info, + &rss_conf.conf); TAILQ_INSERT_TAIL(&igb_filter_rss_list, rss_filter_ptr, entries); flow->rule = rss_filter_ptr; @@ -1757,7 +1760,7 @@ igb_clear_rss_filter(struct rte_eth_dev *dev) struct e1000_filter_info *filter = E1000_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private); - if (filter->rss_info.num) + if (filter->rss_info.conf.queue_num) igb_config_rss_filter(dev, &filter->rss_info, FALSE); } diff --git a/drivers/net/e1000/igb_rxtx.c b/drivers/net/e1000/igb_rxtx.c index 323913f0d..45bb3455c 100644 --- a/drivers/net/e1000/igb_rxtx.c +++ b/drivers/net/e1000/igb_rxtx.c @@ -2898,12 +2898,47 @@ igb_txq_info_get(struct rte_eth_dev *dev, uint16_t queue_id, } int +igb_rss_conf_init(struct igb_rte_flow_rss_conf *out, + const struct rte_flow_action_rss *in) +{ + if (in->key_len > RTE_DIM(out->key) || + in->queue_num > RTE_DIM(out->queue)) + return -EINVAL; + out->conf = (struct rte_flow_action_rss){ + .types = in->types, + .key_len = in->key_len, + .queue_num = in->queue_num, + .key = memcpy(out->key, in->key, in->key_len), + .queue = memcpy(out->queue, in->queue, + sizeof(*in->queue) * in->queue_num), + }; + return 0; +} + +int +igb_action_rss_same(const struct rte_flow_action_rss *comp, + const struct rte_flow_action_rss *with) +{ + return (comp->types == with->types && + comp->key_len == with->key_len && + comp->queue_num == with->queue_num && + !memcmp(comp->key, with->key, with->key_len) && + !memcmp(comp->queue, with->queue, + sizeof(*with->queue) * with->queue_num)); +} + +int igb_config_rss_filter(struct rte_eth_dev *dev, struct igb_rte_flow_rss_conf *conf, bool add) { uint32_t shift; uint16_t i, j; - struct rte_eth_rss_conf rss_conf = conf->rss_conf; + struct rte_eth_rss_conf rss_conf = { + .rss_key = conf->conf.key_len ? + (void *)(uintptr_t)conf->conf.key : NULL, + .rss_key_len = conf->conf.key_len, + .rss_hf = conf->conf.types, + }; struct e1000_filter_info *filter_info = E1000_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private); struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private); @@ -2911,8 +2946,8 @@ igb_config_rss_filter(struct rte_eth_dev *dev, hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private); if (!add) { - if (memcmp(conf, &filter_info->rss_info, - sizeof(struct igb_rte_flow_rss_conf)) == 0) { + if (igb_action_rss_same(&filter_info->rss_info.conf, + &conf->conf)) { igb_rss_disable(dev); memset(&filter_info->rss_info, 0, sizeof(struct igb_rte_flow_rss_conf)); @@ -2921,7 +2956,7 @@ igb_config_rss_filter(struct rte_eth_dev *dev, return -EINVAL; } - if (filter_info->rss_info.num) + if (filter_info->rss_info.conf.queue_num) return -EINVAL; /* Fill in redirection table. */ @@ -2933,9 +2968,9 @@ igb_config_rss_filter(struct rte_eth_dev *dev, } reta; uint8_t q_idx; - if (j == conf->num) + if (j == conf->conf.queue_num) j = 0; - q_idx = conf->queue[j]; + q_idx = conf->conf.queue[j]; reta.bytes[i & 3] = (uint8_t)(q_idx << shift); if ((i & 3) == 3) E1000_WRITE_REG(hw, E1000_RETA(i >> 2), reta.dword); @@ -2952,8 +2987,8 @@ igb_config_rss_filter(struct rte_eth_dev *dev, rss_conf.rss_key = rss_intel_key; /* Default hash key */ igb_hw_rss_hash_set(hw, &rss_conf); - rte_memcpy(&filter_info->rss_info, - conf, sizeof(struct igb_rte_flow_rss_conf)); + if (igb_rss_conf_init(&filter_info->rss_info, &conf->conf)) + return -EINVAL; return 0; } diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index 180ac7449..e65235fc3 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c @@ -11,6 +11,7 @@ #include <inttypes.h> #include <assert.h> +#include <rte_common.h> #include <rte_eal.h> #include <rte_string_fns.h> #include <rte_pci.h> @@ -11499,7 +11500,7 @@ i40e_rss_filter_restore(struct i40e_pf *pf) { struct i40e_rte_flow_rss_conf *conf = &pf->rss_info; - if (conf->num) + if (conf->conf.queue_num) i40e_config_rss_filter(pf, conf, TRUE); } @@ -12031,18 +12032,52 @@ i40e_cloud_filter_qinq_create(struct i40e_pf *pf) } int +i40e_rss_conf_init(struct i40e_rte_flow_rss_conf *out, + const struct rte_flow_action_rss *in) +{ + if (in->key_len > RTE_DIM(out->key) || + in->queue_num > RTE_DIM(out->queue)) + return -EINVAL; + out->conf = (struct rte_flow_action_rss){ + .types = in->types, + .key_len = in->key_len, + .queue_num = in->queue_num, + .key = memcpy(out->key, in->key, in->key_len), + .queue = memcpy(out->queue, in->queue, + sizeof(*in->queue) * in->queue_num), + }; + return 0; +} + +int +i40e_action_rss_same(const struct rte_flow_action_rss *comp, + const struct rte_flow_action_rss *with) +{ + return (comp->types == with->types && + comp->key_len == with->key_len && + comp->queue_num == with->queue_num && + !memcmp(comp->key, with->key, with->key_len) && + !memcmp(comp->queue, with->queue, + sizeof(*with->queue) * with->queue_num)); +} + +int i40e_config_rss_filter(struct i40e_pf *pf, struct i40e_rte_flow_rss_conf *conf, bool add) { struct i40e_hw *hw = I40E_PF_TO_HW(pf); uint32_t i, lut = 0; uint16_t j, num; - struct rte_eth_rss_conf rss_conf = conf->rss_conf; + struct rte_eth_rss_conf rss_conf = { + .rss_key = conf->conf.key_len ? + (void *)(uintptr_t)conf->conf.key : NULL, + .rss_key_len = conf->conf.key_len, + .rss_hf = conf->conf.types, + }; struct i40e_rte_flow_rss_conf *rss_info = &pf->rss_info; if (!add) { - if (memcmp(conf, rss_info, - sizeof(struct i40e_rte_flow_rss_conf)) == 0) { + if (i40e_action_rss_same(&rss_info->conf, &conf->conf)) { i40e_pf_disable_rss(pf); memset(rss_info, 0, sizeof(struct i40e_rte_flow_rss_conf)); @@ -12051,7 +12086,7 @@ i40e_config_rss_filter(struct i40e_pf *pf, return -EINVAL; } - if (rss_info->num) + if (rss_info->conf.queue_num) return -EINVAL; /* If both VMDQ and RSS enabled, not all of PF queues are configured. @@ -12062,7 +12097,7 @@ i40e_config_rss_filter(struct i40e_pf *pf, else num = pf->dev_data->nb_rx_queues; - num = RTE_MIN(num, conf->num); + num = RTE_MIN(num, conf->conf.queue_num); PMD_DRV_LOG(INFO, "Max of contiguous %u PF queues are configured", num); @@ -12075,7 +12110,7 @@ i40e_config_rss_filter(struct i40e_pf *pf, for (i = 0, j = 0; i < hw->func_caps.rss_table_size; i++, j++) { if (j == num) j = 0; - lut = (lut << 8) | (conf->queue[j] & ((0x1 << + lut = (lut << 8) | (conf->conf.queue[j] & ((0x1 << hw->func_caps.rss_table_entry_width) - 1)); if ((i & 3) == 3) I40E_WRITE_REG(hw, I40E_PFQF_HLUT(i >> 2), lut); @@ -12100,8 +12135,8 @@ i40e_config_rss_filter(struct i40e_pf *pf, i40e_hw_rss_hash_set(pf, &rss_conf); - rte_memcpy(rss_info, - conf, sizeof(struct i40e_rte_flow_rss_conf)); + if (i40e_rss_conf_init(rss_info, &conf->conf)) + return -EINVAL; return 0; } diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h index d33b255e7..a0569d4ae 100644 --- a/drivers/net/i40e/i40e_ethdev.h +++ b/drivers/net/i40e/i40e_ethdev.h @@ -5,14 +5,19 @@ #ifndef _I40E_ETHDEV_H_ #define _I40E_ETHDEV_H_ +#include <stdint.h> + #include <rte_eth_ctrl.h> #include <rte_time.h> #include <rte_kvargs.h> #include <rte_hash.h> +#include <rte_flow.h> #include <rte_flow_driver.h> #include <rte_tm_driver.h> #include "rte_pmd_i40e.h" +#include "base/i40e_register.h" + #define I40E_VLAN_TAG_SIZE 4 #define I40E_AQ_LEN 32 @@ -878,9 +883,11 @@ struct i40e_customized_pctype { }; struct i40e_rte_flow_rss_conf { - struct rte_eth_rss_conf rss_conf; /**< RSS parameters. */ + struct rte_flow_action_rss conf; /**< RSS parameters. */ uint16_t queue_region_conf; /**< Queue region config flag */ - uint16_t num; /**< Number of entries in queue[]. */ + uint8_t key[(I40E_VFQF_HKEY_MAX_INDEX > I40E_PFQF_HKEY_MAX_INDEX ? + I40E_VFQF_HKEY_MAX_INDEX : I40E_PFQF_HKEY_MAX_INDEX) + 1 * + sizeof(uint32_t)]; /* Hash key. */ uint16_t queue[I40E_MAX_Q_PER_TC]; /**< Queues indices to use. */ }; @@ -1219,6 +1226,10 @@ void i40e_init_queue_region_conf(struct rte_eth_dev *dev); void i40e_flex_payload_reg_set_default(struct i40e_hw *hw); int i40e_set_rss_key(struct i40e_vsi *vsi, uint8_t *key, uint8_t key_len); int i40e_set_rss_lut(struct i40e_vsi *vsi, uint8_t *lut, uint16_t lut_size); +int i40e_rss_conf_init(struct i40e_rte_flow_rss_conf *out, + const struct rte_flow_action_rss *in); +int i40e_action_rss_same(const struct rte_flow_action_rss *comp, + const struct rte_flow_action_rss *with); int i40e_config_rss_filter(struct i40e_pf *pf, struct i40e_rte_flow_rss_conf *conf, bool add); diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c index d6f5e9923..ec6231003 100644 --- a/drivers/net/i40e/i40e_flow.c +++ b/drivers/net/i40e/i40e_flow.c @@ -4220,7 +4220,7 @@ i40e_flow_parse_rss_action(struct rte_eth_dev *dev, if (action_flag) { for (n = 0; n < 64; n++) { - if (rss->rss_conf->rss_hf & (hf_bit << n)) { + if (rss->types & (hf_bit << n)) { conf_info->region[0].hw_flowtype[0] = n; conf_info->region[0].flowtype_num = 1; conf_info->queue_region_number = 1; @@ -4236,12 +4236,12 @@ i40e_flow_parse_rss_action(struct rte_eth_dev *dev, * queue index for this port. */ if (conf_info->queue_region_number) { - for (i = 0; i < rss->num; i++) { - for (j = 0; j < rss_info->num; j++) { - if (rss->queue[i] == rss_info->queue[j]) + for (i = 0; i < rss->queue_num; i++) { + for (j = 0; j < rss_info->conf.queue_num; j++) { + if (rss->queue[i] == rss_info->conf.queue[j]) break; } - if (j == rss_info->num) { + if (j == rss_info->conf.queue_num) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, act, @@ -4250,7 +4250,7 @@ i40e_flow_parse_rss_action(struct rte_eth_dev *dev, } } - for (i = 0; i < rss->num - 1; i++) { + for (i = 0; i < rss->queue_num - 1; i++) { if (rss->queue[i + 1] != rss->queue[i] + 1) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, @@ -4265,8 +4265,8 @@ i40e_flow_parse_rss_action(struct rte_eth_dev *dev, for (n = 0; n < conf_info->queue_region_number; n++) { if (conf_info->region[n].user_priority_num || conf_info->region[n].flowtype_num) { - if (!((rte_is_power_of_2(rss->num)) && - rss->num <= 64)) { + if (!((rte_is_power_of_2(rss->queue_num)) && + rss->queue_num <= 64)) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, act, @@ -4294,7 +4294,8 @@ i40e_flow_parse_rss_action(struct rte_eth_dev *dev, } for (i = 0; i < info->queue_region_number; i++) { - if (info->region[i].queue_num == rss->num && + if (info->region[i].queue_num == + rss->queue_num && info->region[i].queue_start_index == rss->queue[0]) break; @@ -4310,7 +4311,7 @@ i40e_flow_parse_rss_action(struct rte_eth_dev *dev, } info->region[i].queue_num = - rss->num; + rss->queue_num; info->region[i].queue_start_index = rss->queue[0]; info->region[i].region_id = @@ -4356,7 +4357,7 @@ i40e_flow_parse_rss_action(struct rte_eth_dev *dev, if (rss_config->queue_region_conf) return 0; - if (!rss || !rss->num) { + if (!rss || !rss->queue_num) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, act, @@ -4364,7 +4365,7 @@ i40e_flow_parse_rss_action(struct rte_eth_dev *dev, return -rte_errno; } - for (n = 0; n < rss->num; n++) { + for (n = 0; n < rss->queue_num; n++) { if (rss->queue[n] >= dev->data->nb_rx_queues) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, @@ -4375,15 +4376,19 @@ i40e_flow_parse_rss_action(struct rte_eth_dev *dev, } /* Parse RSS related parameters from configuration */ - if (rss->rss_conf) - rss_config->rss_conf = *rss->rss_conf; - else - rss_config->rss_conf.rss_hf = - pf->adapter->flow_types_mask; + if (rss->key_len && rss->key_len > RTE_DIM(rss_config->key)) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, + "RSS hash key too large"); + if (rss->queue_num > RTE_DIM(rss_config->queue)) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, + "too many queues for RSS context"); + if (i40e_rss_conf_init(rss_config, rss)) + return rte_flow_error_set + (error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, act, + "RSS context initialization failure"); - for (n = 0; n < rss->num; ++n) - rss_config->queue[n] = rss->queue[n]; - rss_config->num = rss->num; index++; /* check if the next not void action is END */ @@ -4903,7 +4908,7 @@ i40e_flow_flush_rss_filter(struct rte_eth_dev *dev) ret = i40e_flush_queue_region_all_conf(dev, hw, pf, 0); - if (rss_info->num) + if (rss_info->conf.queue_num) ret = i40e_config_rss_filter(pf, rss_info, FALSE); return ret; } diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c index 33ee52e45..eaf1aadef 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.c +++ b/drivers/net/ixgbe/ixgbe_ethdev.c @@ -100,8 +100,6 @@ #define IXGBE_QUEUE_STAT_COUNTERS (sizeof(hw_stats->qprc) / sizeof(hw_stats->qprc[0])) -#define IXGBE_HKEY_MAX_INDEX 10 - /* Additional timesync values. */ #define NSEC_PER_SEC 1000000000L #define IXGBE_INCVAL_10GB 0x66666666 @@ -8292,7 +8290,7 @@ ixgbe_rss_filter_restore(struct rte_eth_dev *dev) struct ixgbe_filter_info *filter_info = IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private); - if (filter_info->rss_info.num) + if (filter_info->rss_info.conf.queue_num) ixgbe_config_rss_filter(dev, &filter_info->rss_info, TRUE); } diff --git a/drivers/net/ixgbe/ixgbe_ethdev.h b/drivers/net/ixgbe/ixgbe_ethdev.h index 655077700..9491b03f4 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.h +++ b/drivers/net/ixgbe/ixgbe_ethdev.h @@ -4,6 +4,9 @@ #ifndef _IXGBE_ETHDEV_H_ #define _IXGBE_ETHDEV_H_ + +#include <stdint.h> + #include "base/ixgbe_type.h" #include "base/ixgbe_dcb.h" #include "base/ixgbe_dcb_82599.h" @@ -12,6 +15,7 @@ #ifdef RTE_LIBRTE_SECURITY #include "ixgbe_ipsec.h" #endif +#include <rte_flow.h> #include <rte_time.h> #include <rte_hash.h> #include <rte_pci.h> @@ -39,6 +43,7 @@ #define IXGBE_EXTENDED_VLAN (uint32_t)(1 << 26) /* EXTENDED VLAN ENABLE */ #define IXGBE_VFTA_SIZE 128 #define IXGBE_VLAN_TAG_SIZE 4 +#define IXGBE_HKEY_MAX_INDEX 10 #define IXGBE_MAX_RX_QUEUE_NUM 128 #define IXGBE_MAX_INTR_QUEUE_NUM 15 #define IXGBE_VMDQ_DCB_NB_QUEUES IXGBE_MAX_RX_QUEUE_NUM @@ -196,8 +201,8 @@ struct ixgbe_hw_fdir_info { }; struct ixgbe_rte_flow_rss_conf { - struct rte_eth_rss_conf rss_conf; /**< RSS parameters. */ - uint16_t num; /**< Number of entries in queue[]. */ + struct rte_flow_action_rss conf; /**< RSS parameters. */ + uint8_t key[IXGBE_HKEY_MAX_INDEX * sizeof(uint32_t)]; /* Hash key. */ uint16_t queue[IXGBE_MAX_RX_QUEUE_NUM]; /**< Queues indices to use. */ }; @@ -696,6 +701,10 @@ void ixgbe_tm_conf_init(struct rte_eth_dev *dev); void ixgbe_tm_conf_uninit(struct rte_eth_dev *dev); int ixgbe_set_queue_rate_limit(struct rte_eth_dev *dev, uint16_t queue_idx, uint16_t tx_rate); +int ixgbe_rss_conf_init(struct ixgbe_rte_flow_rss_conf *out, + const struct rte_flow_action_rss *in); +int ixgbe_action_rss_same(const struct rte_flow_action_rss *comp, + const struct rte_flow_action_rss *with); int ixgbe_config_rss_filter(struct rte_eth_dev *dev, struct ixgbe_rte_flow_rss_conf *conf, bool add); diff --git a/drivers/net/ixgbe/ixgbe_flow.c b/drivers/net/ixgbe/ixgbe_flow.c index abdeac28b..4e31c7c56 100644 --- a/drivers/net/ixgbe/ixgbe_flow.c +++ b/drivers/net/ixgbe/ixgbe_flow.c @@ -2761,7 +2761,7 @@ ixgbe_parse_rss_filter(struct rte_eth_dev *dev, rss = (const struct rte_flow_action_rss *)act->conf; - if (!rss || !rss->num) { + if (!rss || !rss->queue_num) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, act, @@ -2769,7 +2769,7 @@ ixgbe_parse_rss_filter(struct rte_eth_dev *dev, return -rte_errno; } - for (n = 0; n < rss->num; n++) { + for (n = 0; n < rss->queue_num; n++) { if (rss->queue[n] >= dev->data->nb_rx_queues) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, @@ -2778,14 +2778,19 @@ ixgbe_parse_rss_filter(struct rte_eth_dev *dev, return -rte_errno; } } - if (rss->rss_conf) - rss_conf->rss_conf = *rss->rss_conf; - else - rss_conf->rss_conf.rss_hf = IXGBE_RSS_OFFLOAD_ALL; - for (n = 0; n < rss->num; ++n) - rss_conf->queue[n] = rss->queue[n]; - rss_conf->num = rss->num; + if (rss->key_len && rss->key_len != RTE_DIM(rss_conf->key)) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, + "RSS hash key must be exactly 40 bytes"); + if (rss->queue_num > RTE_DIM(rss_conf->queue)) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, + "too many queues for RSS context"); + if (ixgbe_rss_conf_init(rss_conf, rss)) + return rte_flow_error_set + (error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, act, + "RSS context initialization failure"); /* check if the next not void item is END */ act = next_no_void_action(actions, act); @@ -2834,7 +2839,7 @@ ixgbe_clear_rss_filter(struct rte_eth_dev *dev) struct ixgbe_filter_info *filter_info = IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private); - if (filter_info->rss_info.num) + if (filter_info->rss_info.conf.queue_num) ixgbe_config_rss_filter(dev, &filter_info->rss_info, FALSE); } @@ -3153,9 +3158,8 @@ ixgbe_flow_create(struct rte_eth_dev *dev, PMD_DRV_LOG(ERR, "failed to allocate memory"); goto out; } - rte_memcpy(&rss_filter_ptr->filter_info, - &rss_conf, - sizeof(struct ixgbe_rte_flow_rss_conf)); + ixgbe_rss_conf_init(&rss_filter_ptr->filter_info, + &rss_conf.conf); TAILQ_INSERT_TAIL(&filter_rss_list, rss_filter_ptr, entries); flow->rule = rss_filter_ptr; diff --git a/drivers/net/ixgbe/ixgbe_rxtx.c b/drivers/net/ixgbe/ixgbe_rxtx.c index aed3f5a9a..9fbd7dbd7 100644 --- a/drivers/net/ixgbe/ixgbe_rxtx.c +++ b/drivers/net/ixgbe/ixgbe_rxtx.c @@ -5676,6 +5676,36 @@ ixgbevf_dev_rxtx_start(struct rte_eth_dev *dev) } int +ixgbe_rss_conf_init(struct ixgbe_rte_flow_rss_conf *out, + const struct rte_flow_action_rss *in) +{ + if (in->key_len > RTE_DIM(out->key) || + in->queue_num > RTE_DIM(out->queue)) + return -EINVAL; + out->conf = (struct rte_flow_action_rss){ + .types = in->types, + .key_len = in->key_len, + .queue_num = in->queue_num, + .key = memcpy(out->key, in->key, in->key_len), + .queue = memcpy(out->queue, in->queue, + sizeof(*in->queue) * in->queue_num), + }; + return 0; +} + +int +ixgbe_action_rss_same(const struct rte_flow_action_rss *comp, + const struct rte_flow_action_rss *with) +{ + return (comp->types == with->types && + comp->key_len == with->key_len && + comp->queue_num == with->queue_num && + !memcmp(comp->key, with->key, with->key_len) && + !memcmp(comp->queue, with->queue, + sizeof(*with->queue) * with->queue_num)); +} + +int ixgbe_config_rss_filter(struct rte_eth_dev *dev, struct ixgbe_rte_flow_rss_conf *conf, bool add) { @@ -5685,7 +5715,12 @@ ixgbe_config_rss_filter(struct rte_eth_dev *dev, uint16_t j; uint16_t sp_reta_size; uint32_t reta_reg; - struct rte_eth_rss_conf rss_conf = conf->rss_conf; + struct rte_eth_rss_conf rss_conf = { + .rss_key = conf->conf.key_len ? + (void *)(uintptr_t)conf->conf.key : NULL, + .rss_key_len = conf->conf.key_len, + .rss_hf = conf->conf.types, + }; struct ixgbe_filter_info *filter_info = IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private); @@ -5695,8 +5730,8 @@ ixgbe_config_rss_filter(struct rte_eth_dev *dev, sp_reta_size = ixgbe_reta_size_get(hw->mac.type); if (!add) { - if (memcmp(conf, &filter_info->rss_info, - sizeof(struct ixgbe_rte_flow_rss_conf)) == 0) { + if (ixgbe_action_rss_same(&filter_info->rss_info.conf, + &conf->conf)) { ixgbe_rss_disable(dev); memset(&filter_info->rss_info, 0, sizeof(struct ixgbe_rte_flow_rss_conf)); @@ -5705,7 +5740,7 @@ ixgbe_config_rss_filter(struct rte_eth_dev *dev, return -EINVAL; } - if (filter_info->rss_info.num) + if (filter_info->rss_info.conf.queue_num) return -EINVAL; /* Fill in redirection table * The byte-swap is needed because NIC registers are in @@ -5715,9 +5750,9 @@ ixgbe_config_rss_filter(struct rte_eth_dev *dev, for (i = 0, j = 0; i < sp_reta_size; i++, j++) { reta_reg = ixgbe_reta_reg_get(hw->mac.type, i); - if (j == conf->num) + if (j == conf->conf.queue_num) j = 0; - reta = (reta << 8) | conf->queue[j]; + reta = (reta << 8) | conf->conf.queue[j]; if ((i & 3) == 3) IXGBE_WRITE_REG(hw, reta_reg, rte_bswap32(reta)); @@ -5734,8 +5769,8 @@ ixgbe_config_rss_filter(struct rte_eth_dev *dev, rss_conf.rss_key = rss_intel_key; /* Default hash key */ ixgbe_hw_rss_hash_set(hw, &rss_conf); - rte_memcpy(&filter_info->rss_info, - conf, sizeof(struct ixgbe_rte_flow_rss_conf)); + if (ixgbe_rss_conf_init(&filter_info->rss_info, &conf->conf)) + return -EINVAL; return 0; } diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c index 06f17703b..970d20dd1 100644 --- a/drivers/net/mlx4/mlx4.c +++ b/drivers/net/mlx4/mlx4.c @@ -569,7 +569,7 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev) " for UDP RSS and inner VXLAN RSS"); /* Fake support for all possible RSS hash fields. */ priv->hw_rss_sup = ~UINT64_C(0); - priv->hw_rss_sup = mlx4_conv_rss_hf(priv, -1); + priv->hw_rss_sup = mlx4_conv_rss_types(priv, -1); /* Filter out known unsupported fields. */ priv->hw_rss_sup &= ~(uint64_t)(IBV_RX_HASH_SRC_PORT_UDP | diff --git a/drivers/net/mlx4/mlx4_flow.c b/drivers/net/mlx4/mlx4_flow.c index 8feb6ae31..dd86e4ce7 100644 --- a/drivers/net/mlx4/mlx4_flow.c +++ b/drivers/net/mlx4/mlx4_flow.c @@ -76,22 +76,22 @@ struct mlx4_drop { }; /** - * Convert DPDK RSS hash fields to their Verbs equivalent. + * Convert DPDK RSS hash types to their Verbs equivalent. * - * This function returns the supported (default) set when @p rss_hf has + * This function returns the supported (default) set when @p types has * special value (uint64_t)-1. * * @param priv * Pointer to private structure. - * @param rss_hf - * Hash fields in DPDK format (see struct rte_eth_rss_conf). + * @param types + * Hash types in DPDK format (see struct rte_eth_rss_conf). * * @return * A valid Verbs RSS hash fields mask for mlx4 on success, (uint64_t)-1 * otherwise and rte_errno is set. */ uint64_t -mlx4_conv_rss_hf(struct priv *priv, uint64_t rss_hf) +mlx4_conv_rss_types(struct priv *priv, uint64_t types) { enum { IPV4, IPV6, TCP, UDP, }; const uint64_t in[] = { @@ -126,17 +126,17 @@ mlx4_conv_rss_hf(struct priv *priv, uint64_t rss_hf) unsigned int i; for (i = 0; i != RTE_DIM(in); ++i) - if (rss_hf & in[i]) { - seen |= rss_hf & in[i]; + if (types & in[i]) { + seen |= types & in[i]; conv |= out[i]; } if ((conv & priv->hw_rss_sup) == conv) { - if (rss_hf == (uint64_t)-1) { + if (types == (uint64_t)-1) { /* Include inner RSS by default if supported. */ conv |= priv->hw_rss_sup & IBV_RX_HASH_INNER; return conv; } - if (!(rss_hf & ~seen)) + if (!(types & ~seen)) return conv; } rte_errno = ENOTSUP; @@ -717,7 +717,8 @@ mlx4_flow_prepare(struct priv *priv, switch (action->type) { const struct rte_flow_action_queue *queue; const struct rte_flow_action_rss *rss; - const struct rte_eth_rss_conf *rss_conf; + const uint8_t *rss_key; + uint32_t rss_key_len; uint64_t fields; unsigned int i; @@ -747,58 +748,56 @@ mlx4_flow_prepare(struct priv *priv, break; rss = action->conf; /* Default RSS configuration if none is provided. */ - rss_conf = - rss->rss_conf ? - rss->rss_conf : - &(struct rte_eth_rss_conf){ - .rss_key = mlx4_rss_hash_key_default, - .rss_key_len = MLX4_RSS_HASH_KEY_SIZE, - .rss_hf = -1, - }; + if (rss->key_len) { + rss_key = rss->key; + rss_key_len = rss->key_len; + } else { + rss_key = mlx4_rss_hash_key_default; + rss_key_len = MLX4_RSS_HASH_KEY_SIZE; + } /* Sanity checks. */ - for (i = 0; i < rss->num; ++i) + for (i = 0; i < rss->queue_num; ++i) if (rss->queue[i] >= priv->dev->data->nb_rx_queues) break; - if (i != rss->num) { + if (i != rss->queue_num) { msg = "queue index target beyond number of" " configured Rx queues"; goto exit_action_not_supported; } - if (!rte_is_power_of_2(rss->num)) { + if (!rte_is_power_of_2(rss->queue_num)) { msg = "for RSS, mlx4 requires the number of" " queues to be a power of two"; goto exit_action_not_supported; } - if (rss_conf->rss_key_len != - sizeof(flow->rss->key)) { + if (rss_key_len != sizeof(flow->rss->key)) { msg = "mlx4 supports exactly one RSS hash key" " length: " MLX4_STR_EXPAND(MLX4_RSS_HASH_KEY_SIZE); goto exit_action_not_supported; } - for (i = 1; i < rss->num; ++i) + for (i = 1; i < rss->queue_num; ++i) if (rss->queue[i] - rss->queue[i - 1] != 1) break; - if (i != rss->num) { + if (i != rss->queue_num) { msg = "mlx4 requires RSS contexts to use" " consecutive queue indices only"; goto exit_action_not_supported; } - if (rss->queue[0] % rss->num) { + if (rss->queue[0] % rss->queue_num) { msg = "mlx4 requires the first queue of a RSS" " context to be aligned on a multiple" " of the context size"; goto exit_action_not_supported; } rte_errno = 0; - fields = mlx4_conv_rss_hf(priv, rss_conf->rss_hf); + fields = mlx4_conv_rss_types(priv, rss->types); if (fields == (uint64_t)-1 && rte_errno) { msg = "unsupported RSS hash type requested"; goto exit_action_not_supported; } flow->rss = mlx4_rss_get - (priv, fields, rss_conf->rss_key, rss->num, + (priv, fields, rss_key, rss->queue_num, rss->queue); if (!flow->rss) { msg = "either invalid parameters or not enough" @@ -1284,8 +1283,10 @@ mlx4_flow_internal(struct priv *priv, struct rte_flow_error *error) rte_align32pow2(priv->dev->data->nb_rx_queues + 1) >> 1; uint16_t queue[queues]; struct rte_flow_action_rss action_rss = { - .rss_conf = NULL, /* Rely on default fallback settings. */ - .num = queues, + .types = -1, + .key_len = MLX4_RSS_HASH_KEY_SIZE, + .queue_num = queues, + .key = mlx4_rss_hash_key_default, .queue = queue, }; struct rte_flow_action actions[] = { diff --git a/drivers/net/mlx4/mlx4_flow.h b/drivers/net/mlx4/mlx4_flow.h index 4e3889e67..7b83d74b0 100644 --- a/drivers/net/mlx4/mlx4_flow.h +++ b/drivers/net/mlx4/mlx4_flow.h @@ -47,7 +47,7 @@ struct rte_flow { /* mlx4_flow.c */ -uint64_t mlx4_conv_rss_hf(struct priv *priv, uint64_t rss_hf); +uint64_t mlx4_conv_rss_types(struct priv *priv, uint64_t rss_hf); int mlx4_flow_sync(struct priv *priv, struct rte_flow_error *error); void mlx4_flow_clean(struct priv *priv); int mlx4_filter_ctrl(struct rte_eth_dev *dev, diff --git a/drivers/net/mlx4/mlx4_rxq.c b/drivers/net/mlx4/mlx4_rxq.c index 6be6a0b9a..b430678c7 100644 --- a/drivers/net/mlx4/mlx4_rxq.c +++ b/drivers/net/mlx4/mlx4_rxq.c @@ -88,7 +88,7 @@ mlx4_rss_hash_key_default[MLX4_RSS_HASH_KEY_SIZE] = { */ struct mlx4_rss * mlx4_rss_get(struct priv *priv, uint64_t fields, - uint8_t key[MLX4_RSS_HASH_KEY_SIZE], + const uint8_t key[MLX4_RSS_HASH_KEY_SIZE], uint16_t queues, const uint16_t queue_id[]) { struct mlx4_rss *rss; diff --git a/drivers/net/mlx4/mlx4_rxtx.h b/drivers/net/mlx4/mlx4_rxtx.h index b1af86110..2dfee957f 100644 --- a/drivers/net/mlx4/mlx4_rxtx.h +++ b/drivers/net/mlx4/mlx4_rxtx.h @@ -127,7 +127,7 @@ uint8_t mlx4_rss_hash_key_default[MLX4_RSS_HASH_KEY_SIZE]; int mlx4_rss_init(struct priv *priv); void mlx4_rss_deinit(struct priv *priv); struct mlx4_rss *mlx4_rss_get(struct priv *priv, uint64_t fields, - uint8_t key[MLX4_RSS_HASH_KEY_SIZE], + const uint8_t key[MLX4_RSS_HASH_KEY_SIZE], uint16_t queues, const uint16_t queue_id[]); void mlx4_rss_put(struct mlx4_rss *rss); int mlx4_rss_attach(struct mlx4_rss *rss); diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 679fdf318..a289dff73 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -214,9 +214,8 @@ struct rte_flow { TAILQ_ENTRY(rte_flow) next; /**< Pointer to the next flow structure. */ uint32_t mark:1; /**< Set if the flow is marked. */ uint32_t drop:1; /**< Drop queue. */ - uint16_t queues_n; /**< Number of entries in queue[]. */ + struct rte_flow_action_rss rss_conf; /**< RSS configuration */ uint16_t (*queues)[]; /**< Queues indexes to use. */ - struct rte_eth_rss_conf rss_conf; /**< RSS configuration */ uint8_t rss_key[40]; /**< copy of the RSS key. */ struct ibv_counter_set *cs; /**< Holds the counters for the rule. */ struct mlx5_flow_counter_stats counter_stats;/**<The counter stats. */ @@ -406,9 +405,8 @@ struct mlx5_flow_parse { uint32_t mark:1; /**< Mark is present in the flow. */ uint32_t count:1; /**< Count is present in the flow. */ uint32_t mark_id; /**< Mark identifier. */ + struct rte_flow_action_rss rss_conf; /**< RSS configuration */ uint16_t queues[RTE_MAX_QUEUES_PER_PORT]; /**< Queues indexes to use. */ - uint16_t queues_n; /**< Number of entries in queue[]. */ - struct rte_eth_rss_conf rss_conf; /**< RSS configuration */ uint8_t rss_key[40]; /**< copy of the RSS key. */ enum hash_rxq_type layer; /**< Last pattern layer detected. */ struct ibv_counter_set *cs; /**< Holds the counter set for the rule */ @@ -532,47 +530,6 @@ mlx5_flow_item_validate(const struct rte_flow_item *item, } /** - * Copy the RSS configuration from the user ones, of the rss_conf is null, - * uses the driver one. - * - * @param parser - * Internal parser structure. - * @param rss_conf - * User RSS configuration to save. - * - * @return - * 0 on success, a negative errno value otherwise and rte_errno is set. - */ -static int -mlx5_flow_convert_rss_conf(struct mlx5_flow_parse *parser, - const struct rte_eth_rss_conf *rss_conf) -{ - /* - * This function is also called at the beginning of - * mlx5_flow_convert_actions() to initialize the parser with the - * device default RSS configuration. - */ - if (rss_conf) { - if (rss_conf->rss_hf & MLX5_RSS_HF_MASK) { - rte_errno = EINVAL; - return -rte_errno; - } - if (rss_conf->rss_key_len != 40) { - rte_errno = EINVAL; - return -rte_errno; - } - if (rss_conf->rss_key_len && rss_conf->rss_key) { - parser->rss_conf.rss_key_len = rss_conf->rss_key_len; - memcpy(parser->rss_key, rss_conf->rss_key, - rss_conf->rss_key_len); - parser->rss_conf.rss_key = parser->rss_key; - } - parser->rss_conf.rss_hf = rss_conf->rss_hf; - } - return 0; -} - -/** * Extract attribute to the parser. * * @param[in] attr @@ -642,17 +599,7 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, enum { FATE = 1, MARK = 2, COUNT = 4, }; uint32_t overlap = 0; struct priv *priv = dev->data->dev_private; - int ret; - /* - * Add default RSS configuration necessary for Verbs to create QP even - * if no RSS is necessary. - */ - ret = mlx5_flow_convert_rss_conf(parser, - (const struct rte_eth_rss_conf *) - &priv->rss_conf); - if (ret) - return ret; for (; actions->type != RTE_FLOW_ACTION_TYPE_END; ++actions) { if (actions->type == RTE_FLOW_ACTION_TYPE_VOID) { continue; @@ -671,25 +618,53 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, overlap |= FATE; if (!queue || (queue->index > (priv->rxqs_n - 1))) goto exit_action_not_supported; - parser->queues_n = 1; parser->queues[0] = queue->index; + parser->rss_conf = (struct rte_flow_action_rss){ + .queue_num = 1, + .queue = parser->queues, + }; } else if (actions->type == RTE_FLOW_ACTION_TYPE_RSS) { const struct rte_flow_action_rss *rss = (const struct rte_flow_action_rss *) actions->conf; + const uint8_t *rss_key; + uint32_t rss_key_len; uint16_t n; if (overlap & FATE) goto exit_action_overlap; overlap |= FATE; - if (!rss || !rss->num) { + if (rss->types & MLX5_RSS_HF_MASK) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION, + actions, + "unsupported RSS type" + " requested"); + return -rte_errno; + } + if (rss->key_len) { + rss_key_len = rss->key_len; + rss_key = rss->key; + } else { + rss_key_len = rss_hash_default_key_len; + rss_key = rss_hash_default_key; + } + if (rss_key_len != RTE_DIM(parser->rss_key)) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION, + actions, + "RSS hash key must be" + " exactly 40 bytes long"); + return -rte_errno; + } + if (!rss->queue_num) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, actions, "no valid queues"); return -rte_errno; } - if (rss->num > RTE_DIM(parser->queues)) { + if (rss->queue_num > RTE_DIM(parser->queues)) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, actions, @@ -697,7 +672,7 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, " context"); return -rte_errno; } - for (n = 0; n < rss->num; ++n) { + for (n = 0; n < rss->queue_num; ++n) { if (rss->queue[n] >= priv->rxqs_n) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, @@ -707,16 +682,16 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, return -rte_errno; } } - for (n = 0; n < rss->num; ++n) - parser->queues[n] = rss->queue[n]; - parser->queues_n = rss->num; - if (mlx5_flow_convert_rss_conf(parser, rss->rss_conf)) { - rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ACTION, - actions, - "wrong RSS configuration"); - return -rte_errno; - } + parser->rss_conf = (struct rte_flow_action_rss){ + .types = rss->types, + .key_len = rss_key_len, + .queue_num = rss->queue_num, + .key = memcpy(parser->rss_key, rss_key, + sizeof(*rss_key) * rss_key_len), + .queue = memcpy(parser->queues, rss->queue, + sizeof(*rss->queue) * + rss->queue_num), + }; } else if (actions->type == RTE_FLOW_ACTION_TYPE_MARK) { const struct rte_flow_action_mark *mark = (const struct rte_flow_action_mark *) @@ -761,7 +736,7 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, parser->drop = 1; if (parser->drop && parser->mark) parser->mark = 0; - if (!parser->queues_n && !parser->drop) { + if (!parser->rss_conf.queue_num && !parser->drop) { rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_HANDLE, NULL, "no valid action"); return -rte_errno; @@ -941,7 +916,7 @@ mlx5_flow_convert_finalise(struct mlx5_flow_parse *parser) unsigned int i; /* Remove any other flow not matching the pattern. */ - if (parser->queues_n == 1 && !parser->rss_conf.rss_hf) { + if (parser->rss_conf.queue_num == 1 && !parser->rss_conf.types) { for (i = 0; i != hash_rxq_init_n; ++i) { if (i == HASH_RXQ_ETH) continue; @@ -969,7 +944,7 @@ mlx5_flow_convert_finalise(struct mlx5_flow_parse *parser) } /* Remove impossible flow according to the RSS configuration. */ if (hash_rxq_init[parser->layer].dpdk_rss_hf & - parser->rss_conf.rss_hf) { + parser->rss_conf.types) { /* Remove any other flow. */ for (i = hmin; i != (hmax + 1); ++i) { if ((i == parser->layer) || @@ -980,7 +955,7 @@ mlx5_flow_convert_finalise(struct mlx5_flow_parse *parser) } } else if (!parser->queue[ip].ibv_attr) { /* no RSS possible with the current configuration. */ - parser->queues_n = 1; + parser->rss_conf.queue_num = 1; return; } fill: @@ -1109,7 +1084,7 @@ mlx5_flow_convert(struct rte_eth_dev *dev, for (i = 0; i != hash_rxq_init_n; ++i) { unsigned int offset; - if (!(parser->rss_conf.rss_hf & + if (!(parser->rss_conf.types & hash_rxq_init[i].dpdk_rss_hf) && (i != HASH_RXQ_ETH)) continue; @@ -1777,20 +1752,20 @@ mlx5_flow_create_action_queue_rss(struct rte_eth_dev *dev, continue; flow->frxq[i].hrxq = mlx5_hrxq_get(dev, - parser->rss_conf.rss_key, - parser->rss_conf.rss_key_len, + parser->rss_conf.key, + parser->rss_conf.key_len, hash_fields, - parser->queues, - parser->queues_n); + parser->rss_conf.queue, + parser->rss_conf.queue_num); if (flow->frxq[i].hrxq) continue; flow->frxq[i].hrxq = mlx5_hrxq_new(dev, - parser->rss_conf.rss_key, - parser->rss_conf.rss_key_len, + parser->rss_conf.key, + parser->rss_conf.key_len, hash_fields, - parser->queues, - parser->queues_n); + parser->rss_conf.queue, + parser->rss_conf.queue_num); if (!flow->frxq[i].hrxq) { return rte_flow_error_set(error, ENOMEM, RTE_FLOW_ERROR_TYPE_HANDLE, @@ -1861,9 +1836,9 @@ mlx5_flow_create_action_queue(struct rte_eth_dev *dev, NULL, "internal error in flow creation"); goto error; } - for (i = 0; i != parser->queues_n; ++i) { + for (i = 0; i != parser->rss_conf.queue_num; ++i) { struct mlx5_rxq_data *q = - (*priv->rxqs)[parser->queues[i]]; + (*priv->rxqs)[parser->rss_conf.queue[i]]; q->mark |= parser->mark; } @@ -1927,7 +1902,8 @@ mlx5_flow_list_create(struct rte_eth_dev *dev, if (ret) goto exit; flow = rte_calloc(__func__, 1, - sizeof(*flow) + parser.queues_n * sizeof(uint16_t), + sizeof(*flow) + + parser.rss_conf.queue_num * sizeof(uint16_t), 0); if (!flow) { rte_flow_error_set(error, ENOMEM, @@ -1936,15 +1912,20 @@ mlx5_flow_list_create(struct rte_eth_dev *dev, "cannot allocate flow memory"); return NULL; } - /* Copy queues configuration. */ + /* Copy configuration. */ flow->queues = (uint16_t (*)[])(flow + 1); - memcpy(flow->queues, parser.queues, parser.queues_n * sizeof(uint16_t)); - flow->queues_n = parser.queues_n; + flow->rss_conf = (struct rte_flow_action_rss){ + .types = parser.rss_conf.types, + .key_len = parser.rss_conf.key_len, + .queue_num = parser.rss_conf.queue_num, + .key = memcpy(flow->rss_key, parser.rss_conf.key, + sizeof(*parser.rss_conf.key) * + parser.rss_conf.key_len), + .queue = memcpy(flow->queues, parser.rss_conf.queue, + sizeof(*parser.rss_conf.queue) * + parser.rss_conf.queue_num), + }; flow->mark = parser.mark; - /* Copy RSS configuration. */ - flow->rss_conf = parser.rss_conf; - flow->rss_conf.rss_key = flow->rss_key; - memcpy(flow->rss_key, parser.rss_key, parser.rss_conf.rss_key_len); /* finalise the flow. */ if (parser.drop) ret = mlx5_flow_create_action_queue_drop(dev, &parser, flow, @@ -2024,7 +2005,7 @@ mlx5_flow_list_destroy(struct rte_eth_dev *dev, struct mlx5_flows *list, if (flow->drop || !flow->mark) goto free; - for (i = 0; i != flow->queues_n; ++i) { + for (i = 0; i != flow->rss_conf.queue_num; ++i) { struct rte_flow *tmp; int mark = 0; @@ -2334,19 +2315,19 @@ mlx5_flow_start(struct rte_eth_dev *dev, struct mlx5_flows *list) if (!flow->frxq[i].ibv_attr) continue; flow->frxq[i].hrxq = - mlx5_hrxq_get(dev, flow->rss_conf.rss_key, - flow->rss_conf.rss_key_len, + mlx5_hrxq_get(dev, flow->rss_conf.key, + flow->rss_conf.key_len, hash_rxq_init[i].hash_fields, - (*flow->queues), - flow->queues_n); + flow->rss_conf.queue, + flow->rss_conf.queue_num); if (flow->frxq[i].hrxq) goto flow_create; flow->frxq[i].hrxq = - mlx5_hrxq_new(dev, flow->rss_conf.rss_key, - flow->rss_conf.rss_key_len, + mlx5_hrxq_new(dev, flow->rss_conf.key, + flow->rss_conf.key_len, hash_rxq_init[i].hash_fields, - (*flow->queues), - flow->queues_n); + flow->rss_conf.queue, + flow->rss_conf.queue_num); if (!flow->frxq[i].hrxq) { DRV_LOG(DEBUG, "port %u flow %p cannot be applied", @@ -2370,8 +2351,8 @@ mlx5_flow_start(struct rte_eth_dev *dev, struct mlx5_flows *list) } if (!flow->mark) continue; - for (i = 0; i != flow->queues_n; ++i) - (*priv->rxqs)[(*flow->queues)[i]]->mark = 1; + for (i = 0; i != flow->rss_conf.queue_num; ++i) + (*priv->rxqs)[flow->rss_conf.queue[i]]->mark = 1; } return 0; } @@ -2448,8 +2429,10 @@ mlx5_ctrl_flow_vlan(struct rte_eth_dev *dev, }; uint16_t queue[priv->reta_idx_n]; struct rte_flow_action_rss action_rss = { - .rss_conf = &priv->rss_conf, - .num = priv->reta_idx_n, + .types = priv->rss_conf.rss_hf, + .key_len = priv->rss_conf.rss_key_len, + .queue_num = priv->reta_idx_n, + .key = priv->rss_conf.rss_key, .queue = queue, }; struct rte_flow_action actions[] = { diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c index eda3ba3d5..18ad40813 100644 --- a/drivers/net/mlx5/mlx5_rxq.c +++ b/drivers/net/mlx5/mlx5_rxq.c @@ -1218,8 +1218,8 @@ mlx5_rxq_verify(struct rte_eth_dev *dev) * The Verbs object initialised, NULL otherwise and rte_errno is set. */ struct mlx5_ind_table_ibv * -mlx5_ind_table_ibv_new(struct rte_eth_dev *dev, uint16_t queues[], - uint16_t queues_n) +mlx5_ind_table_ibv_new(struct rte_eth_dev *dev, const uint16_t *queues, + uint32_t queues_n) { struct priv *priv = dev->data->dev_private; struct mlx5_ind_table_ibv *ind_tbl; @@ -1286,8 +1286,8 @@ mlx5_ind_table_ibv_new(struct rte_eth_dev *dev, uint16_t queues[], * An indirection table if found. */ struct mlx5_ind_table_ibv * -mlx5_ind_table_ibv_get(struct rte_eth_dev *dev, uint16_t queues[], - uint16_t queues_n) +mlx5_ind_table_ibv_get(struct rte_eth_dev *dev, const uint16_t *queues, + uint32_t queues_n) { struct priv *priv = dev->data->dev_private; struct mlx5_ind_table_ibv *ind_tbl; @@ -1391,8 +1391,10 @@ mlx5_ind_table_ibv_verify(struct rte_eth_dev *dev) * The Verbs object initialised, NULL otherwise and rte_errno is set. */ struct mlx5_hrxq * -mlx5_hrxq_new(struct rte_eth_dev *dev, uint8_t *rss_key, uint8_t rss_key_len, - uint64_t hash_fields, uint16_t queues[], uint16_t queues_n) +mlx5_hrxq_new(struct rte_eth_dev *dev, + const uint8_t *rss_key, uint32_t rss_key_len, + uint64_t hash_fields, + const uint16_t *queues, uint32_t queues_n) { struct priv *priv = dev->data->dev_private; struct mlx5_hrxq *hrxq; @@ -1419,7 +1421,7 @@ mlx5_hrxq_new(struct rte_eth_dev *dev, uint8_t *rss_key, uint8_t rss_key_len, .rx_hash_conf = (struct ibv_rx_hash_conf){ .rx_hash_function = IBV_RX_HASH_FUNC_TOEPLITZ, .rx_hash_key_len = rss_key_len, - .rx_hash_key = rss_key, + .rx_hash_key = (void *)(uintptr_t)rss_key, .rx_hash_fields_mask = hash_fields, }, .rwq_ind_tbl = ind_tbl->ind_table, @@ -1469,8 +1471,10 @@ mlx5_hrxq_new(struct rte_eth_dev *dev, uint8_t *rss_key, uint8_t rss_key_len, * An hash Rx queue on success. */ struct mlx5_hrxq * -mlx5_hrxq_get(struct rte_eth_dev *dev, uint8_t *rss_key, uint8_t rss_key_len, - uint64_t hash_fields, uint16_t queues[], uint16_t queues_n) +mlx5_hrxq_get(struct rte_eth_dev *dev, + const uint8_t *rss_key, uint32_t rss_key_len, + uint64_t hash_fields, + const uint16_t *queues, uint32_t queues_n) { struct priv *priv = dev->data->dev_private; struct mlx5_hrxq *hrxq; diff --git a/drivers/net/mlx5/mlx5_rxtx.h b/drivers/net/mlx5/mlx5_rxtx.h index 2309aa4f3..ee534c340 100644 --- a/drivers/net/mlx5/mlx5_rxtx.h +++ b/drivers/net/mlx5/mlx5_rxtx.h @@ -134,7 +134,7 @@ struct mlx5_ind_table_ibv { LIST_ENTRY(mlx5_ind_table_ibv) next; /* Pointer to the next element. */ rte_atomic32_t refcnt; /* Reference counter. */ struct ibv_rwq_ind_table *ind_table; /**< Indirection table. */ - uint16_t queues_n; /**< Number of queues in the list. */ + uint32_t queues_n; /**< Number of queues in the list. */ uint16_t queues[]; /**< Queue list. */ }; @@ -145,7 +145,7 @@ struct mlx5_hrxq { struct mlx5_ind_table_ibv *ind_table; /* Indirection table. */ struct ibv_qp *qp; /* Verbs queue pair. */ uint64_t hash_fields; /* Verbs Hash fields. */ - uint8_t rss_key_len; /* Hash key length in bytes. */ + uint32_t rss_key_len; /* Hash key length in bytes. */ uint8_t rss_key[]; /* Hash key. */ }; @@ -237,20 +237,22 @@ int mlx5_rxq_releasable(struct rte_eth_dev *dev, uint16_t idx); int mlx5_rxq_verify(struct rte_eth_dev *dev); int rxq_alloc_elts(struct mlx5_rxq_ctrl *rxq_ctrl); struct mlx5_ind_table_ibv *mlx5_ind_table_ibv_new(struct rte_eth_dev *dev, - uint16_t queues[], - uint16_t queues_n); + const uint16_t *queues, + uint32_t queues_n); struct mlx5_ind_table_ibv *mlx5_ind_table_ibv_get(struct rte_eth_dev *dev, - uint16_t queues[], - uint16_t queues_n); + const uint16_t *queues, + uint32_t queues_n); int mlx5_ind_table_ibv_release(struct rte_eth_dev *dev, struct mlx5_ind_table_ibv *ind_tbl); int mlx5_ind_table_ibv_verify(struct rte_eth_dev *dev); -struct mlx5_hrxq *mlx5_hrxq_new(struct rte_eth_dev *dev, uint8_t *rss_key, - uint8_t rss_key_len, uint64_t hash_fields, - uint16_t queues[], uint16_t queues_n); -struct mlx5_hrxq *mlx5_hrxq_get(struct rte_eth_dev *dev, uint8_t *rss_key, - uint8_t rss_key_len, uint64_t hash_fields, - uint16_t queues[], uint16_t queues_n); +struct mlx5_hrxq *mlx5_hrxq_new(struct rte_eth_dev *dev, + const uint8_t *rss_key, uint32_t rss_key_len, + uint64_t hash_fields, + const uint16_t *queues, uint32_t queues_n); +struct mlx5_hrxq *mlx5_hrxq_get(struct rte_eth_dev *dev, + const uint8_t *rss_key, uint32_t rss_key_len, + uint64_t hash_fields, + const uint16_t *queues, uint32_t queues_n); int mlx5_hrxq_release(struct rte_eth_dev *dev, struct mlx5_hrxq *hxrq); int mlx5_hrxq_ibv_verify(struct rte_eth_dev *dev); uint64_t mlx5_get_rx_port_offloads(void); diff --git a/drivers/net/sfc/sfc_flow.c b/drivers/net/sfc/sfc_flow.c index 056405515..1a2c0299c 100644 --- a/drivers/net/sfc/sfc_flow.c +++ b/drivers/net/sfc/sfc_flow.c @@ -1234,13 +1234,11 @@ sfc_flow_parse_rss(struct sfc_adapter *sa, struct sfc_rxq *rxq; unsigned int rxq_hw_index_min; unsigned int rxq_hw_index_max; - const struct rte_eth_rss_conf *rss_conf = rss->rss_conf; - uint64_t rss_hf; - uint8_t *rss_key = NULL; + const uint8_t *rss_key; struct sfc_flow_rss *sfc_rss_conf = &flow->rss_conf; unsigned int i; - if (rss->num == 0) + if (rss->queue_num == 0) return -EINVAL; rxq_sw_index = sa->rxq_count - 1; @@ -1248,7 +1246,7 @@ sfc_flow_parse_rss(struct sfc_adapter *sa, rxq_hw_index_min = rxq->hw_index; rxq_hw_index_max = 0; - for (i = 0; i < rss->num; ++i) { + for (i = 0; i < rss->queue_num; ++i) { rxq_sw_index = rss->queue[i]; if (rxq_sw_index >= sa->rxq_count) @@ -1263,15 +1261,14 @@ sfc_flow_parse_rss(struct sfc_adapter *sa, rxq_hw_index_max = rxq->hw_index; } - rss_hf = (rss_conf != NULL) ? rss_conf->rss_hf : SFC_RSS_OFFLOADS; - if ((rss_hf & ~SFC_RSS_OFFLOADS) != 0) + if ((rss->types & ~SFC_RSS_OFFLOADS) != 0) return -EINVAL; - if (rss_conf != NULL) { - if (rss_conf->rss_key_len != sizeof(sa->rss_key)) + if (rss->key_len) { + if (rss->key_len != sizeof(sa->rss_key)) return -EINVAL; - rss_key = rss_conf->rss_key; + rss_key = rss->key; } else { rss_key = sa->rss_key; } @@ -1280,11 +1277,11 @@ sfc_flow_parse_rss(struct sfc_adapter *sa, sfc_rss_conf->rxq_hw_index_min = rxq_hw_index_min; sfc_rss_conf->rxq_hw_index_max = rxq_hw_index_max; - sfc_rss_conf->rss_hash_types = sfc_rte_to_efx_hash_type(rss_hf); + sfc_rss_conf->rss_hash_types = sfc_rte_to_efx_hash_type(rss->types); rte_memcpy(sfc_rss_conf->rss_key, rss_key, sizeof(sa->rss_key)); for (i = 0; i < RTE_DIM(sfc_rss_conf->rss_tbl); ++i) { - unsigned int rxq_sw_index = rss->queue[i % rss->num]; + unsigned int rxq_sw_index = rss->queue[i % rss->queue_num]; struct sfc_rxq *rxq = sa->rxq_info[rxq_sw_index].rxq; sfc_rss_conf->rss_tbl[i] = rxq->hw_index - rxq_hw_index_min; diff --git a/drivers/net/tap/tap_flow.c b/drivers/net/tap/tap_flow.c index fe2f94010..67146aaba 100644 --- a/drivers/net/tap/tap_flow.c +++ b/drivers/net/tap/tap_flow.c @@ -1215,7 +1215,7 @@ priv_flow_process(struct pmd_internals *pmd, if (err) goto exit_action_not_supported; } - if (flow && rss) + if (flow) err = rss_add_actions(flow, pmd, rss, error); } else { goto exit_action_not_supported; @@ -2050,7 +2050,7 @@ static int rss_add_actions(struct rte_flow *flow, struct pmd_internals *pmd, struct rte_flow_error *error) { /* 4096 is the maximum number of instructions for a BPF program */ - int i; + unsigned int i; int err; struct rss_key rss_entry = { .hash_fields = 0, .key_size = 0 }; @@ -2066,8 +2066,8 @@ static int rss_add_actions(struct rte_flow *flow, struct pmd_internals *pmd, } /* Update RSS map entry with queues */ - rss_entry.nb_queues = rss->num; - for (i = 0; i < rss->num; i++) + rss_entry.nb_queues = rss->queue_num; + for (i = 0; i < rss->queue_num; i++) rss_entry.queues[i] = rss->queue[i]; rss_entry.hash_fields = (1 << HASH_FIELD_IPV4_L3_L4) | (1 << HASH_FIELD_IPV6_L3_L4); diff --git a/examples/ipsec-secgw/ipsec.c b/examples/ipsec-secgw/ipsec.c index 8b2047adb..3ce76c413 100644 --- a/examples/ipsec-secgw/ipsec.c +++ b/examples/ipsec-secgw/ipsec.c @@ -202,9 +202,13 @@ create_session(struct ipsec_ctx *ipsec_ctx, struct ipsec_sa *sa) i < eth_dev->data->nb_rx_queues; ++i) if (eth_dev->data->rx_queues[i]) queue[j++] = i; - action_rss.rss_conf = &rss_conf; - action_rss.num = j; - action_rss.queue = queue; + action_rss = (struct rte_flow_action_rss){ + .types = rss_conf.rss_hf, + .key_len = rss_conf.rss_key_len, + .queue_num = j, + .key = rss_key, + .queue = queue, + }; ret = rte_flow_validate(sa->portid, &sa->attr, sa->pattern, sa->action, &err); diff --git a/lib/librte_ether/rte_flow.c b/lib/librte_ether/rte_flow.c index bb19e28c6..cc7819b6a 100644 --- a/lib/librte_ether/rte_flow.c +++ b/lib/librte_ether/rte_flow.c @@ -330,40 +330,27 @@ flow_action_conf_copy(void *buf, const struct rte_flow_action *action) off = 0; if (dst.rss) *dst.rss = (struct rte_flow_action_rss){ - .num = src.rss->num, + .types = src.rss->types, + .key_len = src.rss->key_len, + .queue_num = src.rss->queue_num, }; off += sizeof(*src.rss); - if (src.rss->num) { + if (src.rss->key_len) { off = RTE_ALIGN_CEIL(off, sizeof(double)); - size = sizeof(*src.rss->queue) * src.rss->num; + size = sizeof(*src.rss->key) * src.rss->key_len; if (dst.rss) - dst.rss->queue = memcpy + dst.rss->key = memcpy ((void *)((uintptr_t)dst.rss + off), - src.rss->queue, size); + src.rss->key, size); off += size; } - off = RTE_ALIGN_CEIL(off, sizeof(double)); - if (dst.rss) { - dst.rss->rss_conf = (void *)((uintptr_t)dst.rss + off); - *(struct rte_eth_rss_conf *)(uintptr_t) - dst.rss->rss_conf = (struct rte_eth_rss_conf){ - .rss_key_len = src.rss->rss_conf->rss_key_len, - .rss_hf = src.rss->rss_conf->rss_hf, - }; - } - off += sizeof(*src.rss->rss_conf); - if (src.rss->rss_conf->rss_key_len) { + if (src.rss->queue_num) { off = RTE_ALIGN_CEIL(off, sizeof(double)); - size = sizeof(*src.rss->rss_conf->rss_key) * - src.rss->rss_conf->rss_key_len; - if (dst.rss) { - ((struct rte_eth_rss_conf *)(uintptr_t) - dst.rss->rss_conf)->rss_key = - (void *)((uintptr_t)dst.rss + off); - memcpy(dst.rss->rss_conf->rss_key, - src.rss->rss_conf->rss_key, - size); - } + size = sizeof(*src.rss->queue) * src.rss->queue_num; + if (dst.rss) + dst.rss->queue = memcpy + ((void *)((uintptr_t)dst.rss + off), + src.rss->queue, size); off += size; } size = off; diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index ad2e55b8e..bbc408fa6 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -1033,13 +1033,21 @@ struct rte_flow_query_count { * Similar to QUEUE, except RSS is additionally performed on packets to * spread them among several queues according to the provided parameters. * + * Unlike global RSS settings used by other DPDK APIs, unsetting the + * @p types field does not disable RSS in a flow rule. Doing so instead + * requests safe unspecified "best-effort" settings from the underlying PMD, + * which depending on the flow rule, may result in anything ranging from + * empty (single queue) to all-inclusive RSS. + * * Note: RSS hash result is stored in the hash.rss mbuf field which overlaps * hash.fdir.lo. Since the MARK action sets the hash.fdir.hi field only, * both can be requested simultaneously. */ struct rte_flow_action_rss { - const struct rte_eth_rss_conf *rss_conf; /**< RSS parameters. */ - uint16_t num; /**< Number of entries in @p queue. */ + uint64_t types; /**< Specific RSS hash types (see ETH_RSS_*). */ + uint32_t key_len; /**< Hash key length in bytes. */ + uint32_t queue_num; /**< Number of entries in @p queue. */ + const uint8_t *key; /**< Hash key. */ const uint16_t *queue; /**< Queue indices to use. */ }; -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [dpdk-dev] [PATCH v5 07/16] ethdev: flatten RSS configuration in flow API 2018-04-19 10:16 ` [dpdk-dev] [PATCH v5 07/16] ethdev: flatten RSS configuration in " Adrien Mazarguil @ 2018-04-23 15:05 ` Nélio Laranjeiro 0 siblings, 0 replies; 157+ messages in thread From: Nélio Laranjeiro @ 2018-04-23 15:05 UTC (permalink / raw) To: Adrien Mazarguil Cc: Thomas Monjalon, Ferruh Yigit, dev, Xueming Li, Wenzhuo Lu, Jingjing Wu, Beilei Xing, Qi Zhang, Konstantin Ananyev, Yongseok Koh, Andrew Rybchenko, Pascal Mazon, Radu Nicolau, Akhil Goyal On Thu, Apr 19, 2018 at 12:16:39PM +0200, Adrien Mazarguil wrote: > Since its inception, the rte_flow RSS action has been relying in part on > external struct rte_eth_rss_conf for compatibility with the legacy RSS API. > This structure lacks parameters such as the hash algorithm to use, and more > recently, a method to tell which layer RSS should be performed on [1]. > > Given struct rte_eth_rss_conf will never be flexible enough to represent a > complete RSS configuration (e.g. RETA table), this patch supersedes it by > extending the rte_flow RSS action directly. > > A subsequent patch will add a field to use a non-default RSS hash > algorithm. To that end, a field named "types" replaces the field formerly > known as "rss_hf" and standing for "RSS hash functions" as it was > confusing. Actual RSS hash function types are defined by enum > rte_eth_hash_function. > > This patch updates all PMDs and example applications accordingly. > > It breaks ABI compatibility for the following public functions: > > - rte_flow_copy() > - rte_flow_create() > - rte_flow_query() > - rte_flow_validate() > > [1] commit 676b605182a5 ("doc: announce ethdev API change for RSS > configuration") > > Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> > Acked-by: Andrew Rybchenko <arybchenko@solarflare.com> > Cc: Xueming Li <xuemingl@mellanox.com> > Cc: Ferruh Yigit <ferruh.yigit@intel.com> > Cc: Thomas Monjalon <thomas@monjalon.net> > Cc: Wenzhuo Lu <wenzhuo.lu@intel.com> > Cc: Jingjing Wu <jingjing.wu@intel.com> > Cc: Beilei Xing <beilei.xing@intel.com> > Cc: Qi Zhang <qi.z.zhang@intel.com> > Cc: Konstantin Ananyev <konstantin.ananyev@intel.com> > Cc: Nelio Laranjeiro <nelio.laranjeiro@6wind.com> > Cc: Yongseok Koh <yskoh@mellanox.com> > Cc: Andrew Rybchenko <arybchenko@solarflare.com> > Cc: Pascal Mazon <pascal.mazon@6wind.com> > Cc: Radu Nicolau <radu.nicolau@intel.com> > Cc: Akhil Goyal <akhil.goyal@nxp.com> > > --- > > v3 changes: > > Documentation update regarding the meaning of a 0 value for RSS types in > flow rules. > > It used to implicitly mean "no RSS" but is redefined as requesting a kind > of "best-effort" mode from PMDs, i.e. anything ranging from empty to > all-inclusive RSS; what matters is it provides safe defaults that will work > regardless of PMD capabilities. > --- >[...] > diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c > @@ -642,17 +599,7 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, > enum { FATE = 1, MARK = 2, COUNT = 4, }; > uint32_t overlap = 0; > struct priv *priv = dev->data->dev_private; > - int ret; > > - /* > - * Add default RSS configuration necessary for Verbs to create QP even > - * if no RSS is necessary. > - */ > - ret = mlx5_flow_convert_rss_conf(parser, > - (const struct rte_eth_rss_conf *) > - &priv->rss_conf); This is still needed for QUEUE action, Verbs refuses to create an hash Rx queue if no RSS key is provided even if the hash field is 0. This can be fully moved to mlx5_hrxq_new() who can use the default key when the rss_key is not provided. Regards, -- Nélio Laranjeiro 6WIND ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v5 08/16] ethdev: add hash function to RSS flow API action 2018-04-19 10:16 ` [dpdk-dev] [PATCH v5 00/16] Flow API overhaul for switch offloads Adrien Mazarguil ` (6 preceding siblings ...) 2018-04-19 10:16 ` [dpdk-dev] [PATCH v5 07/16] ethdev: flatten RSS configuration in " Adrien Mazarguil @ 2018-04-19 10:16 ` Adrien Mazarguil 2018-04-19 10:16 ` [dpdk-dev] [PATCH v5 09/16] ethdev: add encap level " Adrien Mazarguil ` (8 subsequent siblings) 16 siblings, 0 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-19 10:16 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev Cc: Wenzhuo Lu, Jingjing Wu, Beilei Xing, Qi Zhang, Konstantin Ananyev, Nelio Laranjeiro, Yongseok Koh, Andrew Rybchenko, Pascal Mazon By definition, RSS involves some kind of hash algorithm, usually Toeplitz. Until now it could not be modified on a flow rule basis and PMDs had to always assume RTE_ETH_HASH_FUNCTION_DEFAULT, which remains the default behavior when unspecified (0). This breaks ABI compatibility for the following public functions: - rte_flow_copy() - rte_flow_create() - rte_flow_query() - rte_flow_validate() Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Acked-by: Andrew Rybchenko <arybchenko@solarflare.com> Cc: Ferruh Yigit <ferruh.yigit@intel.com> Cc: Thomas Monjalon <thomas@monjalon.net> Cc: Wenzhuo Lu <wenzhuo.lu@intel.com> Cc: Jingjing Wu <jingjing.wu@intel.com> Cc: Beilei Xing <beilei.xing@intel.com> Cc: Qi Zhang <qi.z.zhang@intel.com> Cc: Konstantin Ananyev <konstantin.ananyev@intel.com> Cc: Nelio Laranjeiro <nelio.laranjeiro@6wind.com> Cc: Yongseok Koh <yskoh@mellanox.com> Cc: Andrew Rybchenko <arybchenko@solarflare.com> Cc: Pascal Mazon <pascal.mazon@6wind.com> --- v3 changes: - Although RTE_ETH_HASH_FUNCTION_DEFAULT is defined as 0, made comparisons more explicit where doing so would clarify the code. - Updated sfc to include Toeplitz as the other allowed value. Both according to Andrew's suggestions [1]. [1] http://dpdk.org/ml/archives/dev/2018-April/095840.html --- app/test-pmd/cmdline_flow.c | 72 ++++++++++++++++++++++++ app/test-pmd/config.c | 1 + doc/guides/prog_guide/rte_flow.rst | 2 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 3 + drivers/net/e1000/igb_flow.c | 4 ++ drivers/net/e1000/igb_rxtx.c | 4 +- drivers/net/i40e/i40e_ethdev.c | 4 +- drivers/net/i40e/i40e_flow.c | 4 ++ drivers/net/ixgbe/ixgbe_flow.c | 4 ++ drivers/net/ixgbe/ixgbe_rxtx.c | 4 +- drivers/net/mlx4/mlx4_flow.c | 7 +++ drivers/net/mlx5/mlx5_flow.c | 13 +++++ drivers/net/sfc/sfc_flow.c | 8 +++ drivers/net/tap/tap_flow.c | 6 ++ lib/librte_ether/rte_flow.c | 1 + lib/librte_ether/rte_flow.h | 2 + 16 files changed, 136 insertions(+), 3 deletions(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index c9c2c3ad9..7436e0356 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -14,6 +14,7 @@ #include <sys/socket.h> #include <rte_common.h> +#include <rte_eth_ctrl.h> #include <rte_ethdev.h> #include <rte_byteorder.h> #include <cmdline_parse.h> @@ -165,6 +166,10 @@ enum index { ACTION_DROP, ACTION_COUNT, ACTION_RSS, + ACTION_RSS_FUNC, + ACTION_RSS_FUNC_DEFAULT, + ACTION_RSS_FUNC_TOEPLITZ, + ACTION_RSS_FUNC_SIMPLE_XOR, ACTION_RSS_TYPES, ACTION_RSS_TYPE, ACTION_RSS_KEY, @@ -632,6 +637,7 @@ static const enum index action_queue[] = { }; static const enum index action_rss[] = { + ACTION_RSS_FUNC, ACTION_RSS_TYPES, ACTION_RSS_KEY, ACTION_RSS_KEY_LEN, @@ -666,6 +672,9 @@ static int parse_vc_conf(struct context *, const struct token *, static int parse_vc_action_rss(struct context *, const struct token *, const char *, unsigned int, void *, unsigned int); +static int parse_vc_action_rss_func(struct context *, const struct token *, + const char *, unsigned int, void *, + unsigned int); static int parse_vc_action_rss_type(struct context *, const struct token *, const char *, unsigned int, void *, unsigned int); @@ -1584,6 +1593,29 @@ static const struct token token_list[] = { .next = NEXT(action_rss), .call = parse_vc_action_rss, }, + [ACTION_RSS_FUNC] = { + .name = "func", + .help = "RSS hash function to apply", + .next = NEXT(action_rss, + NEXT_ENTRY(ACTION_RSS_FUNC_DEFAULT, + ACTION_RSS_FUNC_TOEPLITZ, + ACTION_RSS_FUNC_SIMPLE_XOR)), + }, + [ACTION_RSS_FUNC_DEFAULT] = { + .name = "default", + .help = "default hash function", + .call = parse_vc_action_rss_func, + }, + [ACTION_RSS_FUNC_TOEPLITZ] = { + .name = "toeplitz", + .help = "Toeplitz hash function", + .call = parse_vc_action_rss_func, + }, + [ACTION_RSS_FUNC_SIMPLE_XOR] = { + .name = "simple_xor", + .help = "simple XOR hash function", + .call = parse_vc_action_rss_func, + }, [ACTION_RSS_TYPES] = { .name = "types", .help = "specific RSS hash types", @@ -2074,6 +2106,7 @@ parse_vc_action_rss(struct context *ctx, const struct token *token, action_rss_data = ctx->object; *action_rss_data = (struct action_rss_data){ .conf = (struct rte_flow_action_rss){ + .func = RTE_ETH_HASH_FUNCTION_DEFAULT, .types = rss_hf, .key_len = sizeof(action_rss_data->key), .queue_num = RTE_MIN(nb_rxq, ACTION_RSS_QUEUE_NUM), @@ -2099,6 +2132,45 @@ parse_vc_action_rss(struct context *ctx, const struct token *token, } /** + * Parse func field for RSS action. + * + * The RTE_ETH_HASH_FUNCTION_* value to assign is derived from the + * ACTION_RSS_FUNC_* index that called this function. + */ +static int +parse_vc_action_rss_func(struct context *ctx, const struct token *token, + const char *str, unsigned int len, + void *buf, unsigned int size) +{ + struct action_rss_data *action_rss_data; + enum rte_eth_hash_function func; + + (void)buf; + (void)size; + /* Token name must match. */ + if (parse_default(ctx, token, str, len, NULL, 0) < 0) + return -1; + switch (ctx->curr) { + case ACTION_RSS_FUNC_DEFAULT: + func = RTE_ETH_HASH_FUNCTION_DEFAULT; + break; + case ACTION_RSS_FUNC_TOEPLITZ: + func = RTE_ETH_HASH_FUNCTION_TOEPLITZ; + break; + case ACTION_RSS_FUNC_SIMPLE_XOR: + func = RTE_ETH_HASH_FUNCTION_SIMPLE_XOR; + break; + default: + return -1; + } + if (!ctx->object) + return len; + action_rss_data = ctx->object; + action_rss_data->conf.func = func; + return len; +} + +/** * Parse type field for RSS action. * * Valid tokens are type field names and the "end" token. diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 3da09536a..19e27a6ca 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -1100,6 +1100,7 @@ flow_action_conf_copy(void *buf, const struct rte_flow_action *action) off = 0; if (dst.rss) *dst.rss = (struct rte_flow_action_rss){ + .func = src.rss->func, .types = src.rss->types, .key_len = src.rss->key_len, .queue_num = src.rss->queue_num, diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index cf252eeba..e0c68495c 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -1318,6 +1318,8 @@ field only, both can be requested simultaneously. +---------------+---------------------------------------------+ | Field | Value | +===============+=============================================+ + | ``func`` | RSS hash function to apply | + +---------------+---------------------------------------------+ | ``types`` | specific RSS hash types (see ``ETH_RSS_*``) | +---------------+---------------------------------------------+ | ``key_len`` | hash key length in bytes | diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index 17336d163..546ef3ab7 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3398,6 +3398,9 @@ This section lists supported actions and their attributes, if any. - ``rss``: spread packets among several queues. + - ``func {hash function}``: RSS hash function to apply, allowed tokens are + the same as `set_hash_global_config`_. + - ``types [{RSS hash type} [...]] end``: specific RSS hash types, allowed tokens are the same as `set_hash_input_set`_, except that an empty list does not disable RSS but instead requests unspecified "best-effort" diff --git a/drivers/net/e1000/igb_flow.c b/drivers/net/e1000/igb_flow.c index 8dc5f75f2..82307ec5d 100644 --- a/drivers/net/e1000/igb_flow.c +++ b/drivers/net/e1000/igb_flow.c @@ -1310,6 +1310,10 @@ igb_parse_rss_filter(struct rte_eth_dev *dev, } } + if (rss->func != RTE_ETH_HASH_FUNCTION_DEFAULT) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, + "non-default RSS hash functions are not supported"); if (rss->key_len && rss->key_len != RTE_DIM(rss_conf->key)) return rte_flow_error_set (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, diff --git a/drivers/net/e1000/igb_rxtx.c b/drivers/net/e1000/igb_rxtx.c index 45bb3455c..d5c1cd3d3 100644 --- a/drivers/net/e1000/igb_rxtx.c +++ b/drivers/net/e1000/igb_rxtx.c @@ -2905,6 +2905,7 @@ igb_rss_conf_init(struct igb_rte_flow_rss_conf *out, in->queue_num > RTE_DIM(out->queue)) return -EINVAL; out->conf = (struct rte_flow_action_rss){ + .func = in->func, .types = in->types, .key_len = in->key_len, .queue_num = in->queue_num, @@ -2919,7 +2920,8 @@ int igb_action_rss_same(const struct rte_flow_action_rss *comp, const struct rte_flow_action_rss *with) { - return (comp->types == with->types && + return (comp->func == with->func && + comp->types == with->types && comp->key_len == with->key_len && comp->queue_num == with->queue_num && !memcmp(comp->key, with->key, with->key_len) && diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index e65235fc3..5cb852f2c 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c @@ -12039,6 +12039,7 @@ i40e_rss_conf_init(struct i40e_rte_flow_rss_conf *out, in->queue_num > RTE_DIM(out->queue)) return -EINVAL; out->conf = (struct rte_flow_action_rss){ + .func = in->func, .types = in->types, .key_len = in->key_len, .queue_num = in->queue_num, @@ -12053,7 +12054,8 @@ int i40e_action_rss_same(const struct rte_flow_action_rss *comp, const struct rte_flow_action_rss *with) { - return (comp->types == with->types && + return (comp->func == with->func && + comp->types == with->types && comp->key_len == with->key_len && comp->queue_num == with->queue_num && !memcmp(comp->key, with->key, with->key_len) && diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c index ec6231003..897989bbd 100644 --- a/drivers/net/i40e/i40e_flow.c +++ b/drivers/net/i40e/i40e_flow.c @@ -4376,6 +4376,10 @@ i40e_flow_parse_rss_action(struct rte_eth_dev *dev, } /* Parse RSS related parameters from configuration */ + if (rss->func != RTE_ETH_HASH_FUNCTION_DEFAULT) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, + "non-default RSS hash functions are not supported"); if (rss->key_len && rss->key_len > RTE_DIM(rss_config->key)) return rte_flow_error_set (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, diff --git a/drivers/net/ixgbe/ixgbe_flow.c b/drivers/net/ixgbe/ixgbe_flow.c index 4e31c7c56..00d975b93 100644 --- a/drivers/net/ixgbe/ixgbe_flow.c +++ b/drivers/net/ixgbe/ixgbe_flow.c @@ -2779,6 +2779,10 @@ ixgbe_parse_rss_filter(struct rte_eth_dev *dev, } } + if (rss->func != RTE_ETH_HASH_FUNCTION_DEFAULT) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, + "non-default RSS hash functions are not supported"); if (rss->key_len && rss->key_len != RTE_DIM(rss_conf->key)) return rte_flow_error_set (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, diff --git a/drivers/net/ixgbe/ixgbe_rxtx.c b/drivers/net/ixgbe/ixgbe_rxtx.c index 9fbd7dbd7..e91e7f746 100644 --- a/drivers/net/ixgbe/ixgbe_rxtx.c +++ b/drivers/net/ixgbe/ixgbe_rxtx.c @@ -5683,6 +5683,7 @@ ixgbe_rss_conf_init(struct ixgbe_rte_flow_rss_conf *out, in->queue_num > RTE_DIM(out->queue)) return -EINVAL; out->conf = (struct rte_flow_action_rss){ + .func = in->func, .types = in->types, .key_len = in->key_len, .queue_num = in->queue_num, @@ -5697,7 +5698,8 @@ int ixgbe_action_rss_same(const struct rte_flow_action_rss *comp, const struct rte_flow_action_rss *with) { - return (comp->types == with->types && + return (comp->func == with->func && + comp->types == with->types && comp->key_len == with->key_len && comp->queue_num == with->queue_num && !memcmp(comp->key, with->key, with->key_len) && diff --git a/drivers/net/mlx4/mlx4_flow.c b/drivers/net/mlx4/mlx4_flow.c index dd86e4ce7..002003235 100644 --- a/drivers/net/mlx4/mlx4_flow.c +++ b/drivers/net/mlx4/mlx4_flow.c @@ -790,6 +790,12 @@ mlx4_flow_prepare(struct priv *priv, " of the context size"; goto exit_action_not_supported; } + if (rss->func && + rss->func != RTE_ETH_HASH_FUNCTION_TOEPLITZ) { + msg = "the only supported RSS hash function" + " is Toeplitz"; + goto exit_action_not_supported; + } rte_errno = 0; fields = mlx4_conv_rss_types(priv, rss->types); if (fields == (uint64_t)-1 && rte_errno) { @@ -1283,6 +1289,7 @@ mlx4_flow_internal(struct priv *priv, struct rte_flow_error *error) rte_align32pow2(priv->dev->data->nb_rx_queues + 1) >> 1; uint16_t queue[queues]; struct rte_flow_action_rss action_rss = { + .func = RTE_ETH_HASH_FUNCTION_DEFAULT, .types = -1, .key_len = MLX4_RSS_HASH_KEY_SIZE, .queue_num = queues, diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index a289dff73..f9e6779b4 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -18,6 +18,7 @@ #endif #include <rte_common.h> +#include <rte_eth_ctrl.h> #include <rte_ethdev_driver.h> #include <rte_flow.h> #include <rte_flow_driver.h> @@ -634,6 +635,15 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, if (overlap & FATE) goto exit_action_overlap; overlap |= FATE; + if (rss->func && + rss->func != RTE_ETH_HASH_FUNCTION_TOEPLITZ) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION, + actions, + "the only supported RSS hash" + " function is Toeplitz"); + return -rte_errno; + } if (rss->types & MLX5_RSS_HF_MASK) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, @@ -683,6 +693,7 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, } } parser->rss_conf = (struct rte_flow_action_rss){ + .func = RTE_ETH_HASH_FUNCTION_DEFAULT, .types = rss->types, .key_len = rss_key_len, .queue_num = rss->queue_num, @@ -1915,6 +1926,7 @@ mlx5_flow_list_create(struct rte_eth_dev *dev, /* Copy configuration. */ flow->queues = (uint16_t (*)[])(flow + 1); flow->rss_conf = (struct rte_flow_action_rss){ + .func = RTE_ETH_HASH_FUNCTION_DEFAULT, .types = parser.rss_conf.types, .key_len = parser.rss_conf.key_len, .queue_num = parser.rss_conf.queue_num, @@ -2429,6 +2441,7 @@ mlx5_ctrl_flow_vlan(struct rte_eth_dev *dev, }; uint16_t queue[priv->reta_idx_n]; struct rte_flow_action_rss action_rss = { + .func = RTE_ETH_HASH_FUNCTION_DEFAULT, .types = priv->rss_conf.rss_hf, .key_len = priv->rss_conf.rss_key_len, .queue_num = priv->reta_idx_n, diff --git a/drivers/net/sfc/sfc_flow.c b/drivers/net/sfc/sfc_flow.c index 1a2c0299c..779edad0c 100644 --- a/drivers/net/sfc/sfc_flow.c +++ b/drivers/net/sfc/sfc_flow.c @@ -1261,6 +1261,14 @@ sfc_flow_parse_rss(struct sfc_adapter *sa, rxq_hw_index_max = rxq->hw_index; } + switch (rss->func) { + case RTE_ETH_HASH_FUNCTION_DEFAULT: + case RTE_ETH_HASH_FUNCTION_TOEPLITZ: + break; + default: + return -EINVAL; + } + if ((rss->types & ~SFC_RSS_OFFLOADS) != 0) return -EINVAL; diff --git a/drivers/net/tap/tap_flow.c b/drivers/net/tap/tap_flow.c index 67146aaba..845031a31 100644 --- a/drivers/net/tap/tap_flow.c +++ b/drivers/net/tap/tap_flow.c @@ -2055,6 +2055,12 @@ static int rss_add_actions(struct rte_flow *flow, struct pmd_internals *pmd, struct rss_key rss_entry = { .hash_fields = 0, .key_size = 0 }; + /* Check supported hash functions */ + if (rss->func != RTE_ETH_HASH_FUNCTION_DEFAULT) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, + "non-default RSS hash functions are not supported"); + /* Get a new map key for a new RSS rule */ err = bpf_rss_key(KEY_CMD_GET, &flow->key_idx); if (err < 0) { diff --git a/lib/librte_ether/rte_flow.c b/lib/librte_ether/rte_flow.c index cc7819b6a..a2b51f1e0 100644 --- a/lib/librte_ether/rte_flow.c +++ b/lib/librte_ether/rte_flow.c @@ -330,6 +330,7 @@ flow_action_conf_copy(void *buf, const struct rte_flow_action *action) off = 0; if (dst.rss) *dst.rss = (struct rte_flow_action_rss){ + .func = src.rss->func, .types = src.rss->types, .key_len = src.rss->key_len, .queue_num = src.rss->queue_num, diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index bbc408fa6..97d7d3594 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -19,6 +19,7 @@ #include <rte_arp.h> #include <rte_ether.h> +#include <rte_eth_ctrl.h> #include <rte_icmp.h> #include <rte_ip.h> #include <rte_sctp.h> @@ -1044,6 +1045,7 @@ struct rte_flow_query_count { * both can be requested simultaneously. */ struct rte_flow_action_rss { + enum rte_eth_hash_function func; /**< RSS hash function to apply. */ uint64_t types; /**< Specific RSS hash types (see ETH_RSS_*). */ uint32_t key_len; /**< Hash key length in bytes. */ uint32_t queue_num; /**< Number of entries in @p queue. */ -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v5 09/16] ethdev: add encap level to RSS flow API action 2018-04-19 10:16 ` [dpdk-dev] [PATCH v5 00/16] Flow API overhaul for switch offloads Adrien Mazarguil ` (7 preceding siblings ...) 2018-04-19 10:16 ` [dpdk-dev] [PATCH v5 08/16] ethdev: add hash function to RSS flow API action Adrien Mazarguil @ 2018-04-19 10:16 ` Adrien Mazarguil 2018-04-19 10:16 ` [dpdk-dev] [PATCH v5 10/16] ethdev: refine TPID handling in flow API Adrien Mazarguil ` (7 subsequent siblings) 16 siblings, 0 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-19 10:16 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev Cc: Xueming Li, Wenzhuo Lu, Jingjing Wu, Beilei Xing, Qi Zhang, Konstantin Ananyev, Nelio Laranjeiro, Yongseok Koh, Andrew Rybchenko, Pascal Mazon RSS hash types (ETH_RSS_* macros defined in rte_ethdev.h) describe the protocol header fields of a packet that must be taken into account while computing RSS. When facing encapsulated (e.g. tunneled) packets, there is an ambiguity as to whether these should apply to inner or outer packets. Applications need the ability to tell exactly "where" RSS must be performed. This is addressed by adding encapsulation level information to the RSS flow action. Its default value is 0 and stands for the usual unspecified behavior. Other values provide a specific encapsulation level. Contrary to the change announced by commit 676b605182a5 ("doc: announce ethdev API change for RSS configuration"), this patch does not affect struct rte_eth_rss_conf but struct rte_flow_action_rss as the former is not used anymore by the RSS flow action. ABI impact is therefore limited to rte_flow. This breaks ABI compatibility for the following public functions: - rte_flow_copy() - rte_flow_create() - rte_flow_query() - rte_flow_validate() Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Acked-by: Andrew Rybchenko <arybchenko@solarflare.com> Cc: Xueming Li <xuemingl@mellanox.com> Cc: Ferruh Yigit <ferruh.yigit@intel.com> Cc: Thomas Monjalon <thomas@monjalon.net> Cc: Wenzhuo Lu <wenzhuo.lu@intel.com> Cc: Jingjing Wu <jingjing.wu@intel.com> Cc: Beilei Xing <beilei.xing@intel.com> Cc: Qi Zhang <qi.z.zhang@intel.com> Cc: Konstantin Ananyev <konstantin.ananyev@intel.com> Cc: Nelio Laranjeiro <nelio.laranjeiro@6wind.com> Cc: Yongseok Koh <yskoh@mellanox.com> Cc: Andrew Rybchenko <arybchenko@solarflare.com> Cc: Pascal Mazon <pascal.mazon@6wind.com> --- app/test-pmd/cmdline_flow.c | 13 ++++++++++++ app/test-pmd/config.c | 1 + doc/guides/prog_guide/rte_flow.rst | 24 ++++++++++++++++++++++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 2 ++ drivers/net/e1000/igb_flow.c | 4 ++++ drivers/net/e1000/igb_rxtx.c | 2 ++ drivers/net/i40e/i40e_ethdev.c | 2 ++ drivers/net/i40e/i40e_flow.c | 4 ++++ drivers/net/ixgbe/ixgbe_flow.c | 4 ++++ drivers/net/ixgbe/ixgbe_rxtx.c | 2 ++ drivers/net/mlx4/mlx4_flow.c | 6 ++++++ drivers/net/mlx5/mlx5_flow.c | 11 ++++++++++ drivers/net/sfc/sfc_flow.c | 3 +++ drivers/net/tap/tap_flow.c | 6 +++++- lib/librte_ether/rte_flow.c | 1 + lib/librte_ether/rte_flow.h | 26 ++++++++++++++++++++++++ 16 files changed, 110 insertions(+), 1 deletion(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 7436e0356..976fde7cd 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -167,6 +167,7 @@ enum index { ACTION_COUNT, ACTION_RSS, ACTION_RSS_FUNC, + ACTION_RSS_LEVEL, ACTION_RSS_FUNC_DEFAULT, ACTION_RSS_FUNC_TOEPLITZ, ACTION_RSS_FUNC_SIMPLE_XOR, @@ -638,6 +639,7 @@ static const enum index action_queue[] = { static const enum index action_rss[] = { ACTION_RSS_FUNC, + ACTION_RSS_LEVEL, ACTION_RSS_TYPES, ACTION_RSS_KEY, ACTION_RSS_KEY_LEN, @@ -1616,6 +1618,16 @@ static const struct token token_list[] = { .help = "simple XOR hash function", .call = parse_vc_action_rss_func, }, + [ACTION_RSS_LEVEL] = { + .name = "level", + .help = "encapsulation level for \"types\"", + .next = NEXT(action_rss, NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY_ARB + (offsetof(struct action_rss_data, conf) + + offsetof(struct rte_flow_action_rss, level), + sizeof(((struct rte_flow_action_rss *)0)-> + level))), + }, [ACTION_RSS_TYPES] = { .name = "types", .help = "specific RSS hash types", @@ -2107,6 +2119,7 @@ parse_vc_action_rss(struct context *ctx, const struct token *token, *action_rss_data = (struct action_rss_data){ .conf = (struct rte_flow_action_rss){ .func = RTE_ETH_HASH_FUNCTION_DEFAULT, + .level = 0, .types = rss_hf, .key_len = sizeof(action_rss_data->key), .queue_num = RTE_MIN(nb_rxq, ACTION_RSS_QUEUE_NUM), diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 19e27a6ca..562fb2f8d 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -1101,6 +1101,7 @@ flow_action_conf_copy(void *buf, const struct rte_flow_action *action) if (dst.rss) *dst.rss = (struct rte_flow_action_rss){ .func = src.rss->func, + .level = src.rss->level, .types = src.rss->types, .key_len = src.rss->key_len, .queue_num = src.rss->queue_num, diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index e0c68495c..1a09e8a0f 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -1311,6 +1311,28 @@ Note: RSS hash result is stored in the ``hash.rss`` mbuf field which overlaps ``hash.fdir.lo``. Since `Action: MARK`_ sets the ``hash.fdir.hi`` field only, both can be requested simultaneously. +Also, regarding packet encapsulation ``level``: + +- ``0`` requests the default behavior. Depending on the packet type, it can + mean outermost, innermost, anything in between or even no RSS. + + It basically stands for the innermost encapsulation level RSS can be + performed on according to PMD and device capabilities. + +- ``1`` requests RSS to be performed on the outermost packet encapsulation + level. + +- ``2`` and subsequent values request RSS to be performed on the specified + inner packet encapsulation level, from outermost to innermost (lower to + higher values). + +Values other than ``0`` are not necessarily supported. + +Requesting a specific RSS level on unrecognized traffic results in undefined +behavior. For predictable results, it is recommended to make the flow rule +pattern match packet headers up to the requested encapsulation level so that +only matching traffic goes through. + .. _table_rte_flow_action_rss: .. table:: RSS @@ -1320,6 +1342,8 @@ field only, both can be requested simultaneously. +===============+=============================================+ | ``func`` | RSS hash function to apply | +---------------+---------------------------------------------+ + | ``level`` | encapsulation level for ``types`` | + +---------------+---------------------------------------------+ | ``types`` | specific RSS hash types (see ``ETH_RSS_*``) | +---------------+---------------------------------------------+ | ``key_len`` | hash key length in bytes | diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index 546ef3ab7..3b1073bfc 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3401,6 +3401,8 @@ This section lists supported actions and their attributes, if any. - ``func {hash function}``: RSS hash function to apply, allowed tokens are the same as `set_hash_global_config`_. + - ``level {unsigned}``: encapsulation level for ``types``. + - ``types [{RSS hash type} [...]] end``: specific RSS hash types, allowed tokens are the same as `set_hash_input_set`_, except that an empty list does not disable RSS but instead requests unspecified "best-effort" diff --git a/drivers/net/e1000/igb_flow.c b/drivers/net/e1000/igb_flow.c index 82307ec5d..d1c0b4b8d 100644 --- a/drivers/net/e1000/igb_flow.c +++ b/drivers/net/e1000/igb_flow.c @@ -1314,6 +1314,10 @@ igb_parse_rss_filter(struct rte_eth_dev *dev, return rte_flow_error_set (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, "non-default RSS hash functions are not supported"); + if (rss->level) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, + "a nonzero RSS encapsulation level is not supported"); if (rss->key_len && rss->key_len != RTE_DIM(rss_conf->key)) return rte_flow_error_set (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, diff --git a/drivers/net/e1000/igb_rxtx.c b/drivers/net/e1000/igb_rxtx.c index d5c1cd3d3..a3776a0d7 100644 --- a/drivers/net/e1000/igb_rxtx.c +++ b/drivers/net/e1000/igb_rxtx.c @@ -2906,6 +2906,7 @@ igb_rss_conf_init(struct igb_rte_flow_rss_conf *out, return -EINVAL; out->conf = (struct rte_flow_action_rss){ .func = in->func, + .level = in->level, .types = in->types, .key_len = in->key_len, .queue_num = in->queue_num, @@ -2921,6 +2922,7 @@ igb_action_rss_same(const struct rte_flow_action_rss *comp, const struct rte_flow_action_rss *with) { return (comp->func == with->func && + comp->level == with->level && comp->types == with->types && comp->key_len == with->key_len && comp->queue_num == with->queue_num && diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index 5cb852f2c..42002422b 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c @@ -12040,6 +12040,7 @@ i40e_rss_conf_init(struct i40e_rte_flow_rss_conf *out, return -EINVAL; out->conf = (struct rte_flow_action_rss){ .func = in->func, + .level = in->level, .types = in->types, .key_len = in->key_len, .queue_num = in->queue_num, @@ -12055,6 +12056,7 @@ i40e_action_rss_same(const struct rte_flow_action_rss *comp, const struct rte_flow_action_rss *with) { return (comp->func == with->func && + comp->level == with->level && comp->types == with->types && comp->key_len == with->key_len && comp->queue_num == with->queue_num && diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c index 897989bbd..db668835d 100644 --- a/drivers/net/i40e/i40e_flow.c +++ b/drivers/net/i40e/i40e_flow.c @@ -4380,6 +4380,10 @@ i40e_flow_parse_rss_action(struct rte_eth_dev *dev, return rte_flow_error_set (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, "non-default RSS hash functions are not supported"); + if (rss->level) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, + "a nonzero RSS encapsulation level is not supported"); if (rss->key_len && rss->key_len > RTE_DIM(rss_config->key)) return rte_flow_error_set (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, diff --git a/drivers/net/ixgbe/ixgbe_flow.c b/drivers/net/ixgbe/ixgbe_flow.c index 00d975b93..438bfcdfb 100644 --- a/drivers/net/ixgbe/ixgbe_flow.c +++ b/drivers/net/ixgbe/ixgbe_flow.c @@ -2783,6 +2783,10 @@ ixgbe_parse_rss_filter(struct rte_eth_dev *dev, return rte_flow_error_set (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, "non-default RSS hash functions are not supported"); + if (rss->level) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, + "a nonzero RSS encapsulation level is not supported"); if (rss->key_len && rss->key_len != RTE_DIM(rss_conf->key)) return rte_flow_error_set (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, diff --git a/drivers/net/ixgbe/ixgbe_rxtx.c b/drivers/net/ixgbe/ixgbe_rxtx.c index e91e7f746..2892436e9 100644 --- a/drivers/net/ixgbe/ixgbe_rxtx.c +++ b/drivers/net/ixgbe/ixgbe_rxtx.c @@ -5684,6 +5684,7 @@ ixgbe_rss_conf_init(struct ixgbe_rte_flow_rss_conf *out, return -EINVAL; out->conf = (struct rte_flow_action_rss){ .func = in->func, + .level = in->level, .types = in->types, .key_len = in->key_len, .queue_num = in->queue_num, @@ -5699,6 +5700,7 @@ ixgbe_action_rss_same(const struct rte_flow_action_rss *comp, const struct rte_flow_action_rss *with) { return (comp->func == with->func && + comp->level == with->level && comp->types == with->types && comp->key_len == with->key_len && comp->queue_num == with->queue_num && diff --git a/drivers/net/mlx4/mlx4_flow.c b/drivers/net/mlx4/mlx4_flow.c index 002003235..ce36ac715 100644 --- a/drivers/net/mlx4/mlx4_flow.c +++ b/drivers/net/mlx4/mlx4_flow.c @@ -796,6 +796,11 @@ mlx4_flow_prepare(struct priv *priv, " is Toeplitz"; goto exit_action_not_supported; } + if (rss->level) { + msg = "a nonzero RSS encapsulation level is" + " not supported"; + goto exit_action_not_supported; + } rte_errno = 0; fields = mlx4_conv_rss_types(priv, rss->types); if (fields == (uint64_t)-1 && rte_errno) { @@ -1290,6 +1295,7 @@ mlx4_flow_internal(struct priv *priv, struct rte_flow_error *error) uint16_t queue[queues]; struct rte_flow_action_rss action_rss = { .func = RTE_ETH_HASH_FUNCTION_DEFAULT, + .level = 0, .types = -1, .key_len = MLX4_RSS_HASH_KEY_SIZE, .queue_num = queues, diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index f9e6779b4..0026e938a 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -644,6 +644,14 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, " function is Toeplitz"); return -rte_errno; } + if (rss->level) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION, + actions, + "a nonzero RSS encapsulation" + " level is not supported"); + return -rte_errno; + } if (rss->types & MLX5_RSS_HF_MASK) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, @@ -694,6 +702,7 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, } parser->rss_conf = (struct rte_flow_action_rss){ .func = RTE_ETH_HASH_FUNCTION_DEFAULT, + .level = 0, .types = rss->types, .key_len = rss_key_len, .queue_num = rss->queue_num, @@ -1927,6 +1936,7 @@ mlx5_flow_list_create(struct rte_eth_dev *dev, flow->queues = (uint16_t (*)[])(flow + 1); flow->rss_conf = (struct rte_flow_action_rss){ .func = RTE_ETH_HASH_FUNCTION_DEFAULT, + .level = 0, .types = parser.rss_conf.types, .key_len = parser.rss_conf.key_len, .queue_num = parser.rss_conf.queue_num, @@ -2442,6 +2452,7 @@ mlx5_ctrl_flow_vlan(struct rte_eth_dev *dev, uint16_t queue[priv->reta_idx_n]; struct rte_flow_action_rss action_rss = { .func = RTE_ETH_HASH_FUNCTION_DEFAULT, + .level = 0, .types = priv->rss_conf.rss_hf, .key_len = priv->rss_conf.rss_key_len, .queue_num = priv->reta_idx_n, diff --git a/drivers/net/sfc/sfc_flow.c b/drivers/net/sfc/sfc_flow.c index 779edad0c..3028efbf9 100644 --- a/drivers/net/sfc/sfc_flow.c +++ b/drivers/net/sfc/sfc_flow.c @@ -1269,6 +1269,9 @@ sfc_flow_parse_rss(struct sfc_adapter *sa, return -EINVAL; } + if (rss->level) + return -EINVAL; + if ((rss->types & ~SFC_RSS_OFFLOADS) != 0) return -EINVAL; diff --git a/drivers/net/tap/tap_flow.c b/drivers/net/tap/tap_flow.c index 845031a31..7dfaf9ac5 100644 --- a/drivers/net/tap/tap_flow.c +++ b/drivers/net/tap/tap_flow.c @@ -2055,11 +2055,15 @@ static int rss_add_actions(struct rte_flow *flow, struct pmd_internals *pmd, struct rss_key rss_entry = { .hash_fields = 0, .key_size = 0 }; - /* Check supported hash functions */ + /* Check supported RSS features */ if (rss->func != RTE_ETH_HASH_FUNCTION_DEFAULT) return rte_flow_error_set (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, "non-default RSS hash functions are not supported"); + if (rss->level) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, + "a nonzero RSS encapsulation level is not supported"); /* Get a new map key for a new RSS rule */ err = bpf_rss_key(KEY_CMD_GET, &flow->key_idx); diff --git a/lib/librte_ether/rte_flow.c b/lib/librte_ether/rte_flow.c index a2b51f1e0..83b733ff0 100644 --- a/lib/librte_ether/rte_flow.c +++ b/lib/librte_ether/rte_flow.c @@ -331,6 +331,7 @@ flow_action_conf_copy(void *buf, const struct rte_flow_action *action) if (dst.rss) *dst.rss = (struct rte_flow_action_rss){ .func = src.rss->func, + .level = src.rss->level, .types = src.rss->types, .key_len = src.rss->key_len, .queue_num = src.rss->queue_num, diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index 97d7d3594..d0ff26aa3 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -1046,6 +1046,32 @@ struct rte_flow_query_count { */ struct rte_flow_action_rss { enum rte_eth_hash_function func; /**< RSS hash function to apply. */ + /** + * Packet encapsulation level RSS hash @p types apply to. + * + * - @p 0 requests the default behavior. Depending on the packet + * type, it can mean outermost, innermost, anything in between or + * even no RSS. + * + * It basically stands for the innermost encapsulation level RSS + * can be performed on according to PMD and device capabilities. + * + * - @p 1 requests RSS to be performed on the outermost packet + * encapsulation level. + * + * - @p 2 and subsequent values request RSS to be performed on the + * specified inner packet encapsulation level, from outermost to + * innermost (lower to higher values). + * + * Values other than @p 0 are not necessarily supported. + * + * Requesting a specific RSS level on unrecognized traffic results + * in undefined behavior. For predictable results, it is recommended + * to make the flow rule pattern match packet headers up to the + * requested encapsulation level so that only matching traffic goes + * through. + */ + uint32_t level; uint64_t types; /**< Specific RSS hash types (see ETH_RSS_*). */ uint32_t key_len; /**< Hash key length in bytes. */ uint32_t queue_num; /**< Number of entries in @p queue. */ -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v5 10/16] ethdev: refine TPID handling in flow API 2018-04-19 10:16 ` [dpdk-dev] [PATCH v5 00/16] Flow API overhaul for switch offloads Adrien Mazarguil ` (8 preceding siblings ...) 2018-04-19 10:16 ` [dpdk-dev] [PATCH v5 09/16] ethdev: add encap level " Adrien Mazarguil @ 2018-04-19 10:16 ` Adrien Mazarguil 2018-04-19 10:16 ` [dpdk-dev] [PATCH v5 11/16] ethdev: limit default VLAN TCI mask " Adrien Mazarguil ` (6 subsequent siblings) 16 siblings, 0 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-19 10:16 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev Cc: Wenzhuo Lu, Jingjing Wu, Ajit Khaparde, Somnath Kotur, John Daley, Hyong Youb Kim, Beilei Xing, Qi Zhang, Konstantin Ananyev, Nelio Laranjeiro, Yongseok Koh, Tomasz Duszynski, Dmitri Epshtein, Natalie Samsonov, Jianbo Liu, Andrew Rybchenko, Pascal Mazon TPID handling in rte_flow VLAN and E_TAG pattern item definitions is not consistent with the normal stacking order of pattern items, which is confusing to applications. Problem is that when followed by one of these layers, the EtherType field of the preceding layer keeps its "inner" definition, and the "outer" TPID is provided by the subsequent layer, the reverse of how a packet looks like on the wire: Wire: [ ETH TPID = A | VLAN EtherType = B | B DATA ] rte_flow: [ ETH EtherType = B | VLAN TPID = A | B DATA ] Worse, when QinQ is involved, the stacking order of VLAN layers is unspecified. It is unclear whether it should be reversed (innermost to outermost) as well given TPID applies to the previous layer: Wire: [ ETH TPID = A | VLAN TPID = B | VLAN EtherType = C | C DATA ] rte_flow 1: [ ETH EtherType = C | VLAN TPID = B | VLAN TPID = A | C DATA ] rte_flow 2: [ ETH EtherType = C | VLAN TPID = A | VLAN TPID = B | C DATA ] While specifying EtherType/TPID is hopefully rarely necessary, the stacking order in case of QinQ and the lack of documentation remain an issue. This patch replaces TPID in the VLAN pattern item with an inner EtherType/TPID as is usually done everywhere else (e.g. struct vlan_hdr), clarifies documentation and updates all relevant code. It breaks ABI compatibility for the following public functions: - rte_flow_copy() - rte_flow_create() - rte_flow_query() - rte_flow_validate() Summary of changes for PMDs that implement ETH, VLAN or E_TAG pattern items: - bnxt: EtherType matching is supported with and without VLAN, but TPID matching is not and triggers an error. - e1000: EtherType matching is only supported with the ETHERTYPE filter, which does not support VLAN matching, therefore no impact. - enic: same as bnxt. - i40e: same as bnxt with existing FDIR limitations on allowed EtherType values. The remaining filter types (VXLAN, NVGRE, QINQ) do not support EtherType matching. - ixgbe: same as e1000, with additional minor change to rely on the new E-Tag macro definition. - mlx4: EtherType/TPID matching is not supported, no impact. - mlx5: same as bnxt. - mvpp2: same as bnxt. - sfc: same as bnxt. - tap: same as bnxt. Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Acked-by: Andrew Rybchenko <arybchenko@solarflare.com> Cc: Ferruh Yigit <ferruh.yigit@intel.com> Cc: Thomas Monjalon <thomas@monjalon.net> Cc: Wenzhuo Lu <wenzhuo.lu@intel.com> Cc: Jingjing Wu <jingjing.wu@intel.com> Cc: Ajit Khaparde <ajit.khaparde@broadcom.com> Cc: Somnath Kotur <somnath.kotur@broadcom.com> Cc: John Daley <johndale@cisco.com> Cc: Hyong Youb Kim <hyonkim@cisco.com> Cc: Beilei Xing <beilei.xing@intel.com> Cc: Qi Zhang <qi.z.zhang@intel.com> Cc: Konstantin Ananyev <konstantin.ananyev@intel.com> Cc: Nelio Laranjeiro <nelio.laranjeiro@6wind.com> Cc: Yongseok Koh <yskoh@mellanox.com> Cc: Tomasz Duszynski <tdu@semihalf.com> Cc: Dmitri Epshtein <dima@marvell.com> Cc: Natalie Samsonov <nsamsono@marvell.com> Cc: Jianbo Liu <jianbo.liu@arm.com> Cc: Andrew Rybchenko <arybchenko@solarflare.com> Cc: Pascal Mazon <pascal.mazon@6wind.com> --- v3 changes: Updated mrvl to mvpp2. Moved unrelated default TCI mask update to separate patch. Fixed sfc according to Andrew's comments [1], which made so much sense that I standardized on the same behavior for all other PMDs: matching outer TPID is never supported when a VLAN pattern item is present. This is done because many devices accept several TPIDs but do not provide means to match a given one explicitly, it's all or nothing, and that makes the resulting flow rule inaccurate. [1] http://dpdk.org/ml/archives/dev/2018-April/095870.html --- app/test-pmd/cmdline_flow.c | 17 +++---- doc/guides/nics/tap.rst | 2 +- doc/guides/prog_guide/rte_flow.rst | 19 ++++++-- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 4 +- drivers/net/bnxt/bnxt_filter.c | 35 +++++++++++--- drivers/net/enic/enic_flow.c | 19 +++++--- drivers/net/i40e/i40e_flow.c | 60 ++++++++++++++++++++---- drivers/net/ixgbe/ixgbe_ethdev.c | 3 +- drivers/net/mlx5/mlx5_flow.c | 13 ++++- drivers/net/mvpp2/mrvl_flow.c | 26 +++++++--- drivers/net/sfc/sfc_flow.c | 18 +++++++ drivers/net/tap/tap_flow.c | 14 ++++-- lib/librte_ether/rte_flow.h | 22 ++++++--- lib/librte_net/rte_ether.h | 1 + 14 files changed, 198 insertions(+), 55 deletions(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 976fde7cd..f8f2a559e 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -99,11 +99,11 @@ enum index { ITEM_ETH_SRC, ITEM_ETH_TYPE, ITEM_VLAN, - ITEM_VLAN_TPID, ITEM_VLAN_TCI, ITEM_VLAN_PCP, ITEM_VLAN_DEI, ITEM_VLAN_VID, + ITEM_VLAN_INNER_TYPE, ITEM_IPV4, ITEM_IPV4_TOS, ITEM_IPV4_TTL, @@ -505,11 +505,11 @@ static const enum index item_eth[] = { }; static const enum index item_vlan[] = { - ITEM_VLAN_TPID, ITEM_VLAN_TCI, ITEM_VLAN_PCP, ITEM_VLAN_DEI, ITEM_VLAN_VID, + ITEM_VLAN_INNER_TYPE, ITEM_NEXT, ZERO, }; @@ -1142,12 +1142,6 @@ static const struct token token_list[] = { .next = NEXT(item_vlan), .call = parse_vc, }, - [ITEM_VLAN_TPID] = { - .name = "tpid", - .help = "tag protocol identifier", - .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param), - .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vlan, tpid)), - }, [ITEM_VLAN_TCI] = { .name = "tci", .help = "tag control information", @@ -1175,6 +1169,13 @@ static const struct token token_list[] = { .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan, tci, "\x0f\xff")), }, + [ITEM_VLAN_INNER_TYPE] = { + .name = "inner_type", + .help = "inner EtherType", + .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vlan, + inner_type)), + }, [ITEM_IPV4] = { .name = "ipv4", .help = "match IPv4 header", diff --git a/doc/guides/nics/tap.rst b/doc/guides/nics/tap.rst index c97786aca..3f7a15147 100644 --- a/doc/guides/nics/tap.rst +++ b/doc/guides/nics/tap.rst @@ -108,7 +108,7 @@ The kernel support can be checked with this command:: Supported items: - eth: src and dst (with variable masks), and eth_type (0xffff mask). -- vlan: vid, pcp, tpid, but not eid. (requires kernel 4.9) +- vlan: vid, pcp, but not eid. (requires kernel 4.9) - ipv4/6: src and dst (with variable masks), and ip_proto (0xffff mask). - udp/tcp: src and dst port (0xffff) mask. diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 1a09e8a0f..fd317b48c 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -784,9 +784,15 @@ Item: ``ETH`` Matches an Ethernet header. +The ``type`` field either stands for "EtherType" or "TPID" when followed by +so-called layer 2.5 pattern items such as ``RTE_FLOW_ITEM_TYPE_VLAN``. In +the latter case, ``type`` refers to that of the outer header, with the inner +EtherType/TPID provided by the subsequent pattern item. This is the same +order as on the wire. + - ``dst``: destination MAC. - ``src``: source MAC. -- ``type``: EtherType. +- ``type``: EtherType or TPID. - Default ``mask`` matches destination and source addresses only. Item: ``VLAN`` @@ -794,8 +800,12 @@ Item: ``VLAN`` Matches an 802.1Q/ad VLAN tag. -- ``tpid``: tag protocol identifier. +The corresponding standard outer EtherType (TPID) values are +``ETHER_TYPE_VLAN`` or ``ETHER_TYPE_QINQ``. It can be overridden by the +preceding pattern item. + - ``tci``: tag control information. +- ``inner_type``: inner EtherType or TPID. - Default ``mask`` matches TCI only. Item: ``IPV4`` @@ -866,12 +876,15 @@ Item: ``E_TAG`` Matches an IEEE 802.1BR E-Tag header. -- ``tpid``: tag protocol identifier (0x893F) +The corresponding standard outer EtherType (TPID) value is +``ETHER_TYPE_ETAG``. It can be overridden by the preceding pattern item. + - ``epcp_edei_in_ecid_b``: E-Tag control information (E-TCI), E-PCP (3b), E-DEI (1b), ingress E-CID base (12b). - ``rsvd_grp_ecid_b``: reserved (2b), GRP (2b), E-CID base (12b). - ``in_ecid_e``: ingress E-CID ext. - ``ecid_e``: E-CID ext. +- ``inner_type``: inner EtherType or TPID. - Default ``mask`` simultaneously matches GRP and E-CID base. Item: ``NVGRE`` diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index 3b1073bfc..923664f7d 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3223,15 +3223,15 @@ This section lists supported pattern items and their attributes, if any. - ``dst {MAC-48}``: destination MAC. - ``src {MAC-48}``: source MAC. - - ``type {unsigned}``: EtherType. + - ``type {unsigned}``: EtherType or TPID. - ``vlan``: match 802.1Q/ad VLAN tag. - - ``tpid {unsigned}``: tag protocol identifier. - ``tci {unsigned}``: tag control information. - ``pcp {unsigned}``: priority code point. - ``dei {unsigned}``: drop eligible indicator. - ``vid {unsigned}``: VLAN identifier. + - ``inner_type {unsigned}``: inner EtherType or TPID. - ``ipv4``: match IPv4 header. diff --git a/drivers/net/bnxt/bnxt_filter.c b/drivers/net/bnxt/bnxt_filter.c index fdd94bf02..25806bdc0 100644 --- a/drivers/net/bnxt/bnxt_filter.c +++ b/drivers/net/bnxt/bnxt_filter.c @@ -307,6 +307,7 @@ bnxt_validate_and_parse_flow_type(struct bnxt *bp, uint32_t vf = 0; int use_ntuple; uint32_t en = 0; + uint32_t en_ethertype; int dflt_vnic; use_ntuple = bnxt_filter_type_check(pattern, error); @@ -316,6 +317,9 @@ bnxt_validate_and_parse_flow_type(struct bnxt *bp, filter->filter_type = use_ntuple ? HWRM_CFA_NTUPLE_FILTER : HWRM_CFA_EM_FILTER; + en_ethertype = use_ntuple ? + NTUPLE_FLTR_ALLOC_INPUT_EN_ETHERTYPE : + EM_FLOW_ALLOC_INPUT_EN_ETHERTYPE; while (item->type != RTE_FLOW_ITEM_TYPE_END) { if (item->last) { @@ -385,30 +389,49 @@ bnxt_validate_and_parse_flow_type(struct bnxt *bp, if (eth_mask->type) { filter->ethertype = rte_be_to_cpu_16(eth_spec->type); - en |= use_ntuple ? - NTUPLE_FLTR_ALLOC_INPUT_EN_ETHERTYPE : - EM_FLOW_ALLOC_INPUT_EN_ETHERTYPE; + en |= en_ethertype; } break; case RTE_FLOW_ITEM_TYPE_VLAN: vlan_spec = item->spec; vlan_mask = item->mask; + if (en & en_ethertype) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, + item, + "VLAN TPID matching is not" + " supported"); + return -rte_errno; + } if (vlan_mask->tci && - vlan_mask->tci == RTE_BE16(0x0fff) && - !vlan_mask->tpid) { + vlan_mask->tci == RTE_BE16(0x0fff)) { /* Only the VLAN ID can be matched. */ filter->l2_ovlan = rte_be_to_cpu_16(vlan_spec->tci & RTE_BE16(0x0fff)); en |= EM_FLOW_ALLOC_INPUT_EN_OVLAN_VID; - } else if (vlan_mask->tci || vlan_mask->tpid) { + } else if (vlan_mask->tci) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM, item, "VLAN mask is invalid"); return -rte_errno; } + if (vlan_mask->inner_type && + vlan_mask->inner_type != RTE_BE16(0xffff)) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, + item, + "inner ethertype mask not" + " valid"); + return -rte_errno; + } + if (vlan_mask->inner_type) { + filter->ethertype = + rte_be_to_cpu_16(vlan_spec->inner_type); + en |= en_ethertype; + } break; case RTE_FLOW_ITEM_TYPE_IPV4: diff --git a/drivers/net/enic/enic_flow.c b/drivers/net/enic/enic_flow.c index c34ae84d1..eea14ee73 100644 --- a/drivers/net/enic/enic_flow.c +++ b/drivers/net/enic/enic_flow.c @@ -557,16 +557,21 @@ enic_copy_item_vlan_v2(const struct rte_flow_item *item, if (!spec) return 0; - /* Don't support filtering in tpid */ - if (mask) { - if (mask->tpid != 0) - return ENOTSUP; - } else { + if (!mask) mask = &rte_flow_item_vlan_mask; - RTE_ASSERT(mask->tpid == 0); - } if (*inner_ofst == 0) { + struct ether_hdr *eth_mask = + (void *)gp->layer[FILTER_GENERIC_1_L2].mask; + struct ether_hdr *eth_val = + (void *)gp->layer[FILTER_GENERIC_1_L2].val; + + /* Outer TPID cannot be matched */ + if (eth_mask->ether_type) + return ENOTSUP; + eth_mask->ether_type = mask->inner_type; + eth_val->ether_type = spec->inner_type; + /* Outer header. Use the vlan mask/val fields */ gp->mask_vlan = mask->tci; gp->val_vlan = spec->tci; diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c index db668835d..470ab93d6 100644 --- a/drivers/net/i40e/i40e_flow.c +++ b/drivers/net/i40e/i40e_flow.c @@ -10,6 +10,7 @@ #include <unistd.h> #include <stdarg.h> +#include <rte_debug.h> #include <rte_ether.h> #include <rte_ethdev_driver.h> #include <rte_log.h> @@ -2491,16 +2492,22 @@ i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev, "Invalid MAC_addr mask."); return -rte_errno; } + } + if (eth_spec && eth_mask && eth_mask->type) { + enum rte_flow_item_type next = (item + 1)->type; - if ((eth_mask->type & UINT16_MAX) == - UINT16_MAX) { - input_set |= I40E_INSET_LAST_ETHER_TYPE; - filter->input.flow.l2_flow.ether_type = - eth_spec->type; + if (eth_mask->type != RTE_BE16(0xffff)) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, + item, + "Invalid type mask."); + return -rte_errno; } ether_type = rte_be_to_cpu_16(eth_spec->type); - if (ether_type == ETHER_TYPE_IPv4 || + + if (next == RTE_FLOW_ITEM_TYPE_VLAN || + ether_type == ETHER_TYPE_IPv4 || ether_type == ETHER_TYPE_IPv6 || ether_type == ETHER_TYPE_ARP || ether_type == outer_tpid) { @@ -2510,6 +2517,9 @@ i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev, "Unsupported ether_type."); return -rte_errno; } + input_set |= I40E_INSET_LAST_ETHER_TYPE; + filter->input.flow.l2_flow.ether_type = + eth_spec->type; } pctype = I40E_FILTER_PCTYPE_L2_PAYLOAD; @@ -2519,6 +2529,8 @@ i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev, case RTE_FLOW_ITEM_TYPE_VLAN: vlan_spec = item->spec; vlan_mask = item->mask; + + RTE_ASSERT(!(input_set & I40E_INSET_LAST_ETHER_TYPE)); if (vlan_spec && vlan_mask) { if (vlan_mask->tci == rte_cpu_to_be_16(I40E_TCI_MASK)) { @@ -2527,6 +2539,33 @@ i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev, vlan_spec->tci; } } + if (vlan_spec && vlan_mask && vlan_mask->inner_type) { + if (vlan_mask->inner_type != RTE_BE16(0xffff)) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, + item, + "Invalid inner_type" + " mask."); + return -rte_errno; + } + + ether_type = + rte_be_to_cpu_16(vlan_spec->inner_type); + + if (ether_type == ETHER_TYPE_IPv4 || + ether_type == ETHER_TYPE_IPv6 || + ether_type == ETHER_TYPE_ARP || + ether_type == outer_tpid) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, + item, + "Unsupported inner_type."); + return -rte_errno; + } + input_set |= I40E_INSET_LAST_ETHER_TYPE; + filter->input.flow.l2_flow.ether_type = + vlan_spec->inner_type; + } pctype = I40E_FILTER_PCTYPE_L2_PAYLOAD; layer_idx = I40E_FLXPLD_L2_IDX; @@ -3285,7 +3324,8 @@ i40e_flow_parse_vxlan_pattern(__rte_unused struct rte_eth_dev *dev, case RTE_FLOW_ITEM_TYPE_VLAN: vlan_spec = item->spec; vlan_mask = item->mask; - if (!(vlan_spec && vlan_mask)) { + if (!(vlan_spec && vlan_mask) || + vlan_mask->inner_type) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM, item, @@ -3515,7 +3555,8 @@ i40e_flow_parse_nvgre_pattern(__rte_unused struct rte_eth_dev *dev, case RTE_FLOW_ITEM_TYPE_VLAN: vlan_spec = item->spec; vlan_mask = item->mask; - if (!(vlan_spec && vlan_mask)) { + if (!(vlan_spec && vlan_mask) || + vlan_mask->inner_type) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM, item, @@ -4023,7 +4064,8 @@ i40e_flow_parse_qinq_pattern(__rte_unused struct rte_eth_dev *dev, vlan_spec = item->spec; vlan_mask = item->mask; - if (!(vlan_spec && vlan_mask)) { + if (!(vlan_spec && vlan_mask) || + vlan_mask->inner_type) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM, item, diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c index eaf1aadef..67fbbdc24 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.c +++ b/drivers/net/ixgbe/ixgbe_ethdev.c @@ -115,7 +115,6 @@ #define IXGBE_VT_CTL_POOLING_MODE_MASK 0x00030000 #define IXGBE_VT_CTL_POOLING_MODE_ETAG 0x00010000 -#define DEFAULT_ETAG_ETYPE 0x893f #define IXGBE_ETAG_ETYPE 0x00005084 #define IXGBE_ETAG_ETYPE_MASK 0x0000ffff #define IXGBE_ETAG_ETYPE_VALID 0x80000000 @@ -1481,7 +1480,7 @@ static int ixgbe_l2_tn_filter_init(struct rte_eth_dev *eth_dev) } l2_tn_info->e_tag_en = FALSE; l2_tn_info->e_tag_fwd_en = FALSE; - l2_tn_info->e_tag_ether_type = DEFAULT_ETAG_ETYPE; + l2_tn_info->e_tag_ether_type = ETHER_TYPE_ETAG; return 0; } diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 0026e938a..bcf764b4d 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -18,6 +18,7 @@ #endif #include <rte_common.h> +#include <rte_ether.h> #include <rte_eth_ctrl.h> #include <rte_ethdev_driver.h> #include <rte_flow.h> @@ -306,6 +307,7 @@ static const struct mlx5_flow_items mlx5_flow_items[] = { .actions = valid_actions, .mask = &(const struct rte_flow_item_vlan){ .tci = -1, + .inner_type = -1, }, .default_mask = &rte_flow_item_vlan_mask, .mask_sz = sizeof(struct rte_flow_item_vlan), @@ -1285,6 +1287,7 @@ mlx5_flow_create_vlan(const struct rte_flow_item *item, struct mlx5_flow_parse *parser = data->parser; struct ibv_flow_spec_eth *eth; const unsigned int eth_size = sizeof(struct ibv_flow_spec_eth); + const char *msg = "VLAN cannot be empty"; if (spec) { unsigned int i; @@ -1306,12 +1309,20 @@ mlx5_flow_create_vlan(const struct rte_flow_item *item, */ if (!eth->mask.vlan_tag) goto error; + /* Outer TPID cannot be matched. */ + if (eth->mask.ether_type) { + msg = "VLAN TPID matching is not supported"; + goto error; + } + eth->val.ether_type = spec->inner_type; + eth->mask.ether_type = mask->inner_type; + eth->val.ether_type &= eth->mask.ether_type; } return 0; } error: return rte_flow_error_set(data->error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM, - item, "VLAN cannot be empty"); + item, msg); } /** diff --git a/drivers/net/mvpp2/mrvl_flow.c b/drivers/net/mvpp2/mrvl_flow.c index 8fd4dbfb1..6478eb2fe 100644 --- a/drivers/net/mvpp2/mrvl_flow.c +++ b/drivers/net/mvpp2/mrvl_flow.c @@ -1091,12 +1091,6 @@ mrvl_parse_vlan(const struct rte_flow_item *item, if (ret) return ret; - if (mask->tpid) { - rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM, - NULL, "Not supported by classifier\n"); - return -rte_errno; - } - m = rte_be_to_cpu_16(mask->tci); if (m & MRVL_VLAN_ID_MASK) { RTE_LOG(WARNING, PMD, "vlan id mask is ignored\n"); @@ -1112,6 +1106,26 @@ mrvl_parse_vlan(const struct rte_flow_item *item, goto out; } + if (flow->pattern & F_TYPE) { + rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ITEM, item, + "VLAN TPID matching is not supported\n"); + return -rte_errno; + } + if (mask->inner_type) { + struct rte_flow_item_eth spec_eth = { + .type = spec->inner_type, + }; + struct rte_flow_item_eth mask_eth = { + .type = mask->inner_type, + }; + + RTE_LOG(WARNING, PMD, "inner eth type mask is ignored\n"); + ret = mrvl_parse_type(spec_eth, mask_eth, flow); + if (ret) + goto out; + } + return 0; out: rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, diff --git a/drivers/net/sfc/sfc_flow.c b/drivers/net/sfc/sfc_flow.c index 3028efbf9..cd6a61b39 100644 --- a/drivers/net/sfc/sfc_flow.c +++ b/drivers/net/sfc/sfc_flow.c @@ -7,6 +7,7 @@ * for Solarflare) and Solarflare Communications, Inc. */ +#include <rte_byteorder.h> #include <rte_tailq.h> #include <rte_common.h> #include <rte_ethdev_driver.h> @@ -351,6 +352,7 @@ sfc_flow_parse_vlan(const struct rte_flow_item *item, const struct rte_flow_item_vlan *mask = NULL; const struct rte_flow_item_vlan supp_mask = { .tci = rte_cpu_to_be_16(ETH_VLAN_ID_MAX), + .inner_type = RTE_BE16(0xffff), }; rc = sfc_flow_parse_init(item, @@ -393,6 +395,22 @@ sfc_flow_parse_vlan(const struct rte_flow_item *item, return -rte_errno; } + if (efx_spec->efs_match_flags & EFX_FILTER_MATCH_ETHER_TYPE) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, item, + "VLAN TPID matching is not supported"); + return -rte_errno; + } + if (mask->inner_type == supp_mask.inner_type) { + efx_spec->efs_match_flags |= EFX_FILTER_MATCH_ETHER_TYPE; + efx_spec->efs_ether_type = rte_bswap16(spec->inner_type); + } else if (mask->inner_type) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, item, + "Bad mask for VLAN inner_type"); + return -rte_errno; + } + return 0; } diff --git a/drivers/net/tap/tap_flow.c b/drivers/net/tap/tap_flow.c index 7dfaf9ac5..dff09313a 100644 --- a/drivers/net/tap/tap_flow.c +++ b/drivers/net/tap/tap_flow.c @@ -270,13 +270,13 @@ static const struct tap_flow_items tap_flow_items[] = { .items = ITEMS(RTE_FLOW_ITEM_TYPE_IPV4, RTE_FLOW_ITEM_TYPE_IPV6), .mask = &(const struct rte_flow_item_vlan){ - .tpid = -1, /* DEI matching is not supported */ #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN .tci = 0xffef, #else .tci = 0xefff, #endif + .inner_type = -1, }, .mask_sz = sizeof(struct rte_flow_item_vlan), .default_mask = &rte_flow_item_vlan_mask, @@ -578,13 +578,19 @@ tap_flow_create_vlan(const struct rte_flow_item *item, void *data) /* use default mask if none provided */ if (!mask) mask = tap_flow_items[RTE_FLOW_ITEM_TYPE_VLAN].default_mask; - /* TC does not support tpid masking. Only accept if exact match. */ - if (mask->tpid && mask->tpid != 0xffff) + /* Outer TPID cannot be matched. */ + if (info->eth_type) return -1; /* Double-tagging not supported. */ - if (spec && mask->tpid && spec->tpid != htons(ETH_P_8021Q)) + if (info->vlan) return -1; info->vlan = 1; + if (mask->inner_type) { + /* TC does not support partial eth_type masking */ + if (mask->inner_type != RTE_BE16(0xffff)) + return -1; + info->eth_type = spec->inner_type; + } if (!flow) return 0; msg = &flow->msg; diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index d0ff26aa3..8e50384d0 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -454,11 +454,17 @@ static const struct rte_flow_item_raw rte_flow_item_raw_mask = { * RTE_FLOW_ITEM_TYPE_ETH * * Matches an Ethernet header. + * + * The @p type field either stands for "EtherType" or "TPID" when followed + * by so-called layer 2.5 pattern items such as RTE_FLOW_ITEM_TYPE_VLAN. In + * the latter case, @p type refers to that of the outer header, with the + * inner EtherType/TPID provided by the subsequent pattern item. This is the + * same order as on the wire. */ struct rte_flow_item_eth { struct ether_addr dst; /**< Destination MAC. */ struct ether_addr src; /**< Source MAC. */ - rte_be16_t type; /**< EtherType. */ + rte_be16_t type; /**< EtherType or TPID. */ }; /** Default mask for RTE_FLOW_ITEM_TYPE_ETH. */ @@ -475,19 +481,20 @@ static const struct rte_flow_item_eth rte_flow_item_eth_mask = { * * Matches an 802.1Q/ad VLAN tag. * - * This type normally follows either RTE_FLOW_ITEM_TYPE_ETH or - * RTE_FLOW_ITEM_TYPE_VLAN. + * The corresponding standard outer EtherType (TPID) values are + * ETHER_TYPE_VLAN or ETHER_TYPE_QINQ. It can be overridden by the preceding + * pattern item. */ struct rte_flow_item_vlan { - rte_be16_t tpid; /**< Tag protocol identifier. */ rte_be16_t tci; /**< Tag control information. */ + rte_be16_t inner_type; /**< Inner EtherType or TPID. */ }; /** Default mask for RTE_FLOW_ITEM_TYPE_VLAN. */ #ifndef __cplusplus static const struct rte_flow_item_vlan rte_flow_item_vlan_mask = { - .tpid = RTE_BE16(0x0000), .tci = RTE_BE16(0xffff), + .inner_type = RTE_BE16(0x0000), }; #endif @@ -636,9 +643,11 @@ static const struct rte_flow_item_vxlan rte_flow_item_vxlan_mask = { * RTE_FLOW_ITEM_TYPE_E_TAG. * * Matches a E-tag header. + * + * The corresponding standard outer EtherType (TPID) value is + * ETHER_TYPE_ETAG. It can be overridden by the preceding pattern item. */ struct rte_flow_item_e_tag { - rte_be16_t tpid; /**< Tag protocol identifier (0x893F). */ /** * E-Tag control information (E-TCI). * E-PCP (3b), E-DEI (1b), ingress E-CID base (12b). @@ -648,6 +657,7 @@ struct rte_flow_item_e_tag { rte_be16_t rsvd_grp_ecid_b; uint8_t in_ecid_e; /**< Ingress E-CID ext. */ uint8_t ecid_e; /**< E-CID ext. */ + rte_be16_t inner_type; /**< Inner EtherType or TPID. */ }; /** Default mask for RTE_FLOW_ITEM_TYPE_E_TAG. */ diff --git a/lib/librte_net/rte_ether.h b/lib/librte_net/rte_ether.h index 45daa911a..a271d1c86 100644 --- a/lib/librte_net/rte_ether.h +++ b/lib/librte_net/rte_ether.h @@ -301,6 +301,7 @@ struct vxlan_hdr { #define ETHER_TYPE_RARP 0x8035 /**< Reverse Arp Protocol. */ #define ETHER_TYPE_VLAN 0x8100 /**< IEEE 802.1Q VLAN tagging. */ #define ETHER_TYPE_QINQ 0x88A8 /**< IEEE 802.1ad QinQ tagging. */ +#define ETHER_TYPE_ETAG 0x893F /**< IEEE 802.1BR E-Tag. */ #define ETHER_TYPE_1588 0x88F7 /**< IEEE 802.1AS 1588 Precise Time Protocol. */ #define ETHER_TYPE_SLOW 0x8809 /**< Slow protocols (LACP and Marker). */ #define ETHER_TYPE_TEB 0x6558 /**< Transparent Ethernet Bridging. */ -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v5 11/16] ethdev: limit default VLAN TCI mask in flow API 2018-04-19 10:16 ` [dpdk-dev] [PATCH v5 00/16] Flow API overhaul for switch offloads Adrien Mazarguil ` (9 preceding siblings ...) 2018-04-19 10:16 ` [dpdk-dev] [PATCH v5 10/16] ethdev: refine TPID handling in flow API Adrien Mazarguil @ 2018-04-19 10:16 ` Adrien Mazarguil 2018-04-19 10:16 ` [dpdk-dev] [PATCH v5 12/16] ethdev: add transfer attribute to " Adrien Mazarguil ` (5 subsequent siblings) 16 siblings, 0 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-19 10:16 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev Cc: Wenzhuo Lu, Jingjing Wu, Ajit Khaparde, Somnath Kotur, John Daley, Hyong Youb Kim, Beilei Xing, Qi Zhang, Konstantin Ananyev, Nelio Laranjeiro, Yongseok Koh, Tomasz Duszynski, Dmitri Epshtein, Natalie Samsonov, Jianbo Liu, Andrew Rybchenko, Pascal Mazon VLAN TCI is a 16-bit field broken down as PCP (3b), DEI (1b) and VID (12b). The default mask used by PMDs for the VLAN pattern when one isn't provided by the application comprises the entire TCI, which is problematic because most devices only support VID matching. This forces applications to always provide a mask limited to the VID part in order to successfully apply a flow rule with a VLAN pattern item. Moreover, applications rarely want to match PCP and DEI intentionally. Given the above and since VID is what is commonly referred to when talking about VLAN, this commit excludes PCP and DEI from the default mask. Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Acked-by: Andrew Rybchenko <arybchenko@solarflare.com> Cc: Ferruh Yigit <ferruh.yigit@intel.com> Cc: Thomas Monjalon <thomas@monjalon.net> Cc: Wenzhuo Lu <wenzhuo.lu@intel.com> Cc: Jingjing Wu <jingjing.wu@intel.com> Cc: Ajit Khaparde <ajit.khaparde@broadcom.com> Cc: Somnath Kotur <somnath.kotur@broadcom.com> Cc: John Daley <johndale@cisco.com> Cc: Hyong Youb Kim <hyonkim@cisco.com> Cc: Beilei Xing <beilei.xing@intel.com> Cc: Qi Zhang <qi.z.zhang@intel.com> Cc: Konstantin Ananyev <konstantin.ananyev@intel.com> Cc: Nelio Laranjeiro <nelio.laranjeiro@6wind.com> Cc: Yongseok Koh <yskoh@mellanox.com> Cc: Tomasz Duszynski <tdu@semihalf.com> Cc: Dmitri Epshtein <dima@marvell.com> Cc: Natalie Samsonov <nsamsono@marvell.com> Cc: Jianbo Liu <jianbo.liu@arm.com> Cc: Andrew Rybchenko <arybchenko@solarflare.com> Cc: Pascal Mazon <pascal.mazon@6wind.com> --- v3 changes: These changes were previously mistakenly made part of the previous patch ("ethdev: refine TPID handling in flow API") from which they were split following Andrew's rightful comment [1]. [1] http://dpdk.org/ml/archives/dev/2018-April/095870.html --- doc/guides/prog_guide/rte_flow.rst | 2 +- lib/librte_ether/rte_flow.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index fd317b48c..c62a80566 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -806,7 +806,7 @@ preceding pattern item. - ``tci``: tag control information. - ``inner_type``: inner EtherType or TPID. -- Default ``mask`` matches TCI only. +- Default ``mask`` matches the VID part of TCI only (lower 12 bits). Item: ``IPV4`` ^^^^^^^^^^^^^^ diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index 8e50384d0..513734dce 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -493,7 +493,7 @@ struct rte_flow_item_vlan { /** Default mask for RTE_FLOW_ITEM_TYPE_VLAN. */ #ifndef __cplusplus static const struct rte_flow_item_vlan rte_flow_item_vlan_mask = { - .tci = RTE_BE16(0xffff), + .tci = RTE_BE16(0x0fff), .inner_type = RTE_BE16(0x0000), }; #endif -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v5 12/16] ethdev: add transfer attribute to flow API 2018-04-19 10:16 ` [dpdk-dev] [PATCH v5 00/16] Flow API overhaul for switch offloads Adrien Mazarguil ` (10 preceding siblings ...) 2018-04-19 10:16 ` [dpdk-dev] [PATCH v5 11/16] ethdev: limit default VLAN TCI mask " Adrien Mazarguil @ 2018-04-19 10:16 ` Adrien Mazarguil 2018-04-19 10:16 ` [dpdk-dev] [PATCH v5 13/16] ethdev: update behavior of VF/PF in " Adrien Mazarguil ` (4 subsequent siblings) 16 siblings, 0 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-19 10:16 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev; +Cc: Andrew Rybchenko This new attribute enables applications to create flow rules that do not simply match traffic whose origin is specified in the pattern (e.g. some non-default physical port or VF), but actively affect it by applying the flow rule at the lowest possible level in the underlying device. It breaks ABI compatibility for the following public functions: - rte_flow_copy() - rte_flow_create() - rte_flow_validate() Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Cc: Andrew Rybchenko <arybchenko@solarflare.com> --- v3 changes: Clarified definition for ingress and egress following Andrew's comment on subsequent patch. [1] http://dpdk.org/ml/archives/dev/2018-April/095961.html --- app/test-pmd/cmdline_flow.c | 11 +++++ app/test-pmd/config.c | 6 ++- doc/guides/prog_guide/rte_flow.rst | 26 +++++++++++- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 11 ++--- drivers/net/bnxt/bnxt_filter.c | 8 ++++ drivers/net/e1000/igb_flow.c | 44 ++++++++++++++++++++ drivers/net/enic/enic_flow.c | 6 +++ drivers/net/i40e/i40e_flow.c | 8 ++++ drivers/net/ixgbe/ixgbe_flow.c | 53 ++++++++++++++++++++++++ drivers/net/mlx4/mlx4_flow.c | 4 ++ drivers/net/mlx5/mlx5_flow.c | 7 ++++ drivers/net/mvpp2/mrvl_flow.c | 6 +++ drivers/net/sfc/sfc_flow.c | 6 +++ drivers/net/tap/tap_flow.c | 6 +++ lib/librte_ether/rte_flow.h | 22 +++++++++- 15 files changed, 215 insertions(+), 9 deletions(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index f8f2a559e..1c6b5a112 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -69,6 +69,7 @@ enum index { PRIORITY, INGRESS, EGRESS, + TRANSFER, /* Validate/create pattern. */ PATTERN, @@ -407,6 +408,7 @@ static const enum index next_vc_attr[] = { PRIORITY, INGRESS, EGRESS, + TRANSFER, PATTERN, ZERO, }; @@ -960,6 +962,12 @@ static const struct token token_list[] = { .next = NEXT(next_vc_attr), .call = parse_vc, }, + [TRANSFER] = { + .name = "transfer", + .help = "apply rule directly to endpoints found in pattern", + .next = NEXT(next_vc_attr), + .call = parse_vc, + }, /* Validate/create pattern. */ [PATTERN] = { .name = "pattern", @@ -1945,6 +1953,9 @@ parse_vc(struct context *ctx, const struct token *token, case EGRESS: out->args.vc.attr.egress = 1; return len; + case TRANSFER: + out->args.vc.attr.transfer = 1; + return len; case PATTERN: out->args.vc.pattern = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1), diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 562fb2f8d..a50a5c544 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -1239,6 +1239,7 @@ port_flow_complain(struct rte_flow_error *error) [RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY] = "priority field", [RTE_FLOW_ERROR_TYPE_ATTR_INGRESS] = "ingress field", [RTE_FLOW_ERROR_TYPE_ATTR_EGRESS] = "egress field", + [RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER] = "transfer field", [RTE_FLOW_ERROR_TYPE_ATTR] = "attributes structure", [RTE_FLOW_ERROR_TYPE_ITEM_NUM] = "pattern length", [RTE_FLOW_ERROR_TYPE_ITEM_SPEC] = "item specification", @@ -1504,12 +1505,13 @@ port_flow_list(portid_t port_id, uint32_t n, const uint32_t group[n]) const struct rte_flow_item *item = pf->pattern; const struct rte_flow_action *action = pf->actions; - printf("%" PRIu32 "\t%" PRIu32 "\t%" PRIu32 "\t%c%c\t", + printf("%" PRIu32 "\t%" PRIu32 "\t%" PRIu32 "\t%c%c%c\t", pf->id, pf->attr.group, pf->attr.priority, pf->attr.ingress ? 'i' : '-', - pf->attr.egress ? 'e' : '-'); + pf->attr.egress ? 'e' : '-', + pf->attr.transfer ? 't' : '-'); while (item->type != RTE_FLOW_ITEM_TYPE_END) { if (item->type != RTE_FLOW_ITEM_TYPE_VOID) printf("%s ", flow_item[item->type].name); diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index c62a80566..550a4c95b 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -170,7 +170,13 @@ Note that support for more than a single priority level is not guaranteed. Attribute: Traffic direction ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Flow rules can apply to inbound and/or outbound traffic (ingress/egress). +Flow rule patterns apply to inbound and/or outbound traffic. + +In the context of this API, **ingress** and **egress** respectively stand +for **inbound** and **outbound** based on the standpoint of the application +creating a flow rule. + +There are no exceptions to this definition. Several pattern items and actions are valid and can be used in both directions. At least one direction must be specified. @@ -178,6 +184,24 @@ directions. At least one direction must be specified. Specifying both directions at once for a given rule is not recommended but may be valid in a few cases (e.g. shared counters). +Attribute: Transfer +^^^^^^^^^^^^^^^^^^^ + +Instead of simply matching the properties of traffic as it would appear on a +given DPDK port ID, enabling this attribute transfers a flow rule to the +lowest possible level of any device endpoints found in the pattern. + +When supported, this effectively enables an application to reroute traffic +not necessarily intended for it (e.g. coming from or addressed to different +physical ports, VFs or applications) at the device level. + +It complements the behavior of some pattern items such as `Item: PORT`_ and +is meaningless without them. + +When transferring flow rules, **ingress** and **egress** attributes +(`Attribute: Traffic direction`_) keep their original meaning, as if +processing traffic emitted or received by the application. + Pattern item ~~~~~~~~~~~~ diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index 923664f7d..0bf6c33c9 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -2970,14 +2970,14 @@ following sections. - Check whether a flow rule can be created:: flow validate {port_id} - [group {group_id}] [priority {level}] [ingress] [egress] + [group {group_id}] [priority {level}] [ingress] [egress] [transfer] pattern {item} [/ {item} [...]] / end actions {action} [/ {action} [...]] / end - Create a flow rule:: flow create {port_id} - [group {group_id}] [priority {level}] [ingress] [egress] + [group {group_id}] [priority {level}] [ingress] [egress] [transfer] pattern {item} [/ {item} [...]] / end actions {action} [/ {action} [...]] / end @@ -3010,7 +3010,7 @@ underlying device in its current state but stops short of creating it. It is bound to ``rte_flow_validate()``:: flow validate {port_id} - [group {group_id}] [priority {level}] [ingress] [egress] + [group {group_id}] [priority {level}] [ingress] [egress] [transfer] pattern {item} [/ {item} [...]] / end actions {action} [/ {action} [...]] / end @@ -3047,7 +3047,7 @@ Creating flow rules to ``rte_flow_create()``:: flow create {port_id} - [group {group_id}] [priority {level}] [ingress] [egress] + [group {group_id}] [priority {level}] [ingress] [egress] [transfer] pattern {item} [/ {item} [...]] / end actions {action} [/ {action} [...]] / end @@ -3061,7 +3061,7 @@ Otherwise it will show an error message of the form:: Parameters describe in the following order: -- Attributes (*group*, *priority*, *ingress*, *egress* tokens). +- Attributes (*group*, *priority*, *ingress*, *egress*, *transfer* tokens). - A matching pattern, starting with the *pattern* token and terminated by an *end* pattern item. - Actions, starting with the *actions* token and terminated by an *end* @@ -3089,6 +3089,7 @@ specified before the ``pattern`` token. - ``priority {level}``: priority level within group. - ``ingress``: rule applies to ingress traffic. - ``egress``: rule applies to egress traffic. +- ``transfer``: apply rule directly to endpoints found in pattern. Each instance of an attribute specified several times overrides the previous value as shown below (group 4 is used):: diff --git a/drivers/net/bnxt/bnxt_filter.c b/drivers/net/bnxt/bnxt_filter.c index 25806bdc0..68deb3445 100644 --- a/drivers/net/bnxt/bnxt_filter.c +++ b/drivers/net/bnxt/bnxt_filter.c @@ -754,6 +754,14 @@ bnxt_flow_parse_attr(const struct rte_flow_attr *attr, } /* Not supported */ + if (attr->transfer) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + attr, "No support for transfer."); + return -rte_errno; + } + + /* Not supported */ if (attr->priority) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, diff --git a/drivers/net/e1000/igb_flow.c b/drivers/net/e1000/igb_flow.c index d1c0b4b8d..073852913 100644 --- a/drivers/net/e1000/igb_flow.c +++ b/drivers/net/e1000/igb_flow.c @@ -379,6 +379,15 @@ cons_parse_ntuple_filter(const struct rte_flow_attr *attr, return -rte_errno; } + /* not supported */ + if (attr->transfer) { + memset(filter, 0, sizeof(struct rte_eth_ntuple_filter)); + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + attr, "No support for transfer."); + return -rte_errno; + } + if (attr->priority > 0xFFFF) { memset(filter, 0, sizeof(struct rte_eth_ntuple_filter)); rte_flow_error_set(error, EINVAL, @@ -624,6 +633,14 @@ cons_parse_ethertype_filter(const struct rte_flow_attr *attr, } /* Not supported */ + if (attr->transfer) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + attr, "No support for transfer."); + return -rte_errno; + } + + /* Not supported */ if (attr->priority) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, @@ -923,6 +940,15 @@ cons_parse_syn_filter(const struct rte_flow_attr *attr, return -rte_errno; } + /* not supported */ + if (attr->transfer) { + memset(filter, 0, sizeof(struct rte_eth_syn_filter)); + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + attr, "No support for transfer."); + return -rte_errno; + } + /* Support 2 priorities, the lowest or highest. */ if (!attr->priority) { filter->hig_pri = 0; @@ -1211,6 +1237,15 @@ cons_parse_flex_filter(const struct rte_flow_attr *attr, return -rte_errno; } + /* not supported */ + if (attr->transfer) { + memset(filter, 0, sizeof(struct rte_eth_flex_filter)); + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + attr, "No support for transfer."); + return -rte_errno; + } + if (attr->priority > 0xFFFF) { memset(filter, 0, sizeof(struct rte_eth_flex_filter)); rte_flow_error_set(error, EINVAL, @@ -1361,6 +1396,15 @@ igb_parse_rss_filter(struct rte_eth_dev *dev, return -rte_errno; } + /* not supported */ + if (attr->transfer) { + memset(rss_conf, 0, sizeof(struct igb_rte_flow_rss_conf)); + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + attr, "No support for transfer."); + return -rte_errno; + } + if (attr->priority > 0xFFFF) { memset(rss_conf, 0, sizeof(struct igb_rte_flow_rss_conf)); rte_flow_error_set(error, EINVAL, diff --git a/drivers/net/enic/enic_flow.c b/drivers/net/enic/enic_flow.c index eea14ee73..525f3dd7c 100644 --- a/drivers/net/enic/enic_flow.c +++ b/drivers/net/enic/enic_flow.c @@ -1318,6 +1318,12 @@ enic_flow_parse(struct rte_eth_dev *dev, NULL, "egress is not supported"); return -rte_errno; + } else if (attrs->transfer) { + rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + NULL, + "transfer is not supported"); + return -rte_errno; } else if (!attrs->ingress) { rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c index 470ab93d6..f416b6a00 100644 --- a/drivers/net/i40e/i40e_flow.c +++ b/drivers/net/i40e/i40e_flow.c @@ -1918,6 +1918,14 @@ i40e_flow_parse_attr(const struct rte_flow_attr *attr, } /* Not supported */ + if (attr->transfer) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + attr, "No support for transfer."); + return -rte_errno; + } + + /* Not supported */ if (attr->priority) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, diff --git a/drivers/net/ixgbe/ixgbe_flow.c b/drivers/net/ixgbe/ixgbe_flow.c index 438bfcdfb..eb0644c82 100644 --- a/drivers/net/ixgbe/ixgbe_flow.c +++ b/drivers/net/ixgbe/ixgbe_flow.c @@ -557,6 +557,15 @@ cons_parse_ntuple_filter(const struct rte_flow_attr *attr, return -rte_errno; } + /* not supported */ + if (attr->transfer) { + memset(filter, 0, sizeof(struct rte_eth_ntuple_filter)); + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + attr, "No support for transfer."); + return -rte_errno; + } + if (attr->priority > 0xFFFF) { memset(filter, 0, sizeof(struct rte_eth_ntuple_filter)); rte_flow_error_set(error, EINVAL, @@ -787,6 +796,14 @@ cons_parse_ethertype_filter(const struct rte_flow_attr *attr, } /* Not supported */ + if (attr->transfer) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + attr, "No support for transfer."); + return -rte_errno; + } + + /* Not supported */ if (attr->priority) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, @@ -1078,6 +1095,15 @@ cons_parse_syn_filter(const struct rte_flow_attr *attr, return -rte_errno; } + /* not supported */ + if (attr->transfer) { + memset(filter, 0, sizeof(struct rte_eth_syn_filter)); + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + attr, "No support for transfer."); + return -rte_errno; + } + /* Support 2 priorities, the lowest or highest. */ if (!attr->priority) { filter->hig_pri = 0; @@ -1250,6 +1276,15 @@ cons_parse_l2_tn_filter(struct rte_eth_dev *dev, } /* not supported */ + if (attr->transfer) { + memset(filter, 0, sizeof(struct rte_eth_l2_tunnel_conf)); + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + attr, "No support for transfer."); + return -rte_errno; + } + + /* not supported */ if (attr->priority) { memset(filter, 0, sizeof(struct rte_eth_l2_tunnel_conf)); rte_flow_error_set(error, EINVAL, @@ -1354,6 +1389,15 @@ ixgbe_parse_fdir_act_attr(const struct rte_flow_attr *attr, } /* not supported */ + if (attr->transfer) { + memset(rule, 0, sizeof(struct ixgbe_fdir_rule)); + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + attr, "No support for transfer."); + return -rte_errno; + } + + /* not supported */ if (attr->priority) { memset(rule, 0, sizeof(struct ixgbe_fdir_rule)); rte_flow_error_set(error, EINVAL, @@ -2829,6 +2873,15 @@ ixgbe_parse_rss_filter(struct rte_eth_dev *dev, return -rte_errno; } + /* not supported */ + if (attr->transfer) { + memset(rss_conf, 0, sizeof(struct ixgbe_rte_flow_rss_conf)); + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + attr, "No support for transfer."); + return -rte_errno; + } + if (attr->priority > 0xFFFF) { memset(rss_conf, 0, sizeof(struct ixgbe_rte_flow_rss_conf)); rte_flow_error_set(error, EINVAL, diff --git a/drivers/net/mlx4/mlx4_flow.c b/drivers/net/mlx4/mlx4_flow.c index ce36ac715..e3d7aa8ef 100644 --- a/drivers/net/mlx4/mlx4_flow.c +++ b/drivers/net/mlx4/mlx4_flow.c @@ -652,6 +652,10 @@ mlx4_flow_prepare(struct priv *priv, return rte_flow_error_set (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, NULL, "egress is not supported"); + if (attr->transfer) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + NULL, "transfer is not supported"); if (!attr->ingress) return rte_flow_error_set (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index bcf764b4d..e6c8b3df8 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -568,6 +568,13 @@ mlx5_flow_convert_attributes(const struct rte_flow_attr *attr, "egress is not supported"); return -rte_errno; } + if (attr->transfer) { + rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + NULL, + "transfer is not supported"); + return -rte_errno; + } if (!attr->ingress) { rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, diff --git a/drivers/net/mvpp2/mrvl_flow.c b/drivers/net/mvpp2/mrvl_flow.c index 6478eb2fe..a2e2129cc 100644 --- a/drivers/net/mvpp2/mrvl_flow.c +++ b/drivers/net/mvpp2/mrvl_flow.c @@ -2187,6 +2187,12 @@ mrvl_flow_parse_attr(struct mrvl_priv *priv __rte_unused, "Egress is not supported"); return -rte_errno; } + if (attr->transfer) { + rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, NULL, + "Transfer is not supported"); + return -rte_errno; + } return 0; } diff --git a/drivers/net/sfc/sfc_flow.c b/drivers/net/sfc/sfc_flow.c index cd6a61b39..bcde2c2f7 100644 --- a/drivers/net/sfc/sfc_flow.c +++ b/drivers/net/sfc/sfc_flow.c @@ -1116,6 +1116,12 @@ sfc_flow_parse_attr(const struct rte_flow_attr *attr, "Egress is not supported"); return -rte_errno; } + if (attr->transfer != 0) { + rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, attr, + "Transfer is not supported"); + return -rte_errno; + } if (attr->ingress == 0) { rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, attr, diff --git a/drivers/net/tap/tap_flow.c b/drivers/net/tap/tap_flow.c index dff09313a..ad2ba9f4e 100644 --- a/drivers/net/tap/tap_flow.c +++ b/drivers/net/tap/tap_flow.c @@ -1039,6 +1039,12 @@ priv_flow_process(struct pmd_internals *pmd, }; int action = 0; /* Only one action authorized for now */ + if (attr->transfer) { + rte_flow_error_set( + error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + NULL, "transfer is not supported"); + return -rte_errno; + } if (attr->group > MAX_GROUP) { rte_flow_error_set( error, EINVAL, RTE_FLOW_ERROR_TYPE_ATTR_GROUP, diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index 513734dce..ab2bf2dce 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -72,7 +72,26 @@ struct rte_flow_attr { uint32_t priority; /**< Priority level within group. */ uint32_t ingress:1; /**< Rule applies to ingress traffic. */ uint32_t egress:1; /**< Rule applies to egress traffic. */ - uint32_t reserved:30; /**< Reserved, must be zero. */ + /** + * Instead of simply matching the properties of traffic as it would + * appear on a given DPDK port ID, enabling this attribute transfers + * a flow rule to the lowest possible level of any device endpoints + * found in the pattern. + * + * When supported, this effectively enables an application to + * re-route traffic not necessarily intended for it (e.g. coming + * from or addressed to different physical ports, VFs or + * applications) at the device level. + * + * It complements the behavior of some pattern items such as + * RTE_FLOW_ITEM_TYPE_PORT and is meaningless without them. + * + * When transferring flow rules, ingress and egress attributes keep + * their original meaning, as if processing traffic emitted or + * received by the application. + */ + uint32_t transfer:1; + uint32_t reserved:29; /**< Reserved, must be zero. */ }; /** @@ -1181,6 +1200,7 @@ enum rte_flow_error_type { RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, /**< Priority field. */ RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, /**< Ingress field. */ RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, /**< Egress field. */ + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, /**< Transfer field. */ RTE_FLOW_ERROR_TYPE_ATTR, /**< Attributes structure. */ RTE_FLOW_ERROR_TYPE_ITEM_NUM, /**< Pattern length. */ RTE_FLOW_ERROR_TYPE_ITEM_SPEC, /**< Item specification. */ -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v5 13/16] ethdev: update behavior of VF/PF in flow API 2018-04-19 10:16 ` [dpdk-dev] [PATCH v5 00/16] Flow API overhaul for switch offloads Adrien Mazarguil ` (11 preceding siblings ...) 2018-04-19 10:16 ` [dpdk-dev] [PATCH v5 12/16] ethdev: add transfer attribute to " Adrien Mazarguil @ 2018-04-19 10:16 ` Adrien Mazarguil 2018-04-19 10:16 ` [dpdk-dev] [PATCH v5 14/16] ethdev: rename physical port item " Adrien Mazarguil ` (3 subsequent siblings) 16 siblings, 0 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-19 10:16 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev Cc: Ajit Khaparde, Somnath Kotur, Beilei Xing, Qi Zhang Contrary to all other pattern items, these are inconsistently documented as affecting traffic instead of simply matching its origin, without provision for the latter. This commit clarifies documentation and updates PMDs since the original behavior now has to be explicitly requested using the new transfer attribute. It breaks ABI compatibility for the following public functions: - rte_flow_create() - rte_flow_validate() Impacted PMDs are bnxt and i40e, for which the VF pattern item is now only supported when a transfer attribute is also present. Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Cc: Ajit Khaparde <ajit.khaparde@broadcom.com> Cc: Somnath Kotur <somnath.kotur@broadcom.com> Cc: Beilei Xing <beilei.xing@intel.com> Cc: Qi Zhang <qi.z.zhang@intel.com> --- app/test-pmd/cmdline_flow.c | 12 +++--- doc/guides/prog_guide/rte_flow.rst | 36 +++++++++--------- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 12 +++--- drivers/net/bnxt/bnxt_filter.c | 22 ++++++----- drivers/net/i40e/i40e_flow.c | 23 +++++++----- lib/librte_ether/rte_flow.h | 47 ++++++++++-------------- 6 files changed, 77 insertions(+), 75 deletions(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 1c6b5a112..41103de67 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -1041,21 +1041,21 @@ static const struct token token_list[] = { }, [ITEM_PF] = { .name = "pf", - .help = "match packets addressed to the physical function", + .help = "match traffic from/to the physical function", .priv = PRIV_ITEM(PF, 0), .next = NEXT(NEXT_ENTRY(ITEM_NEXT)), .call = parse_vc, }, [ITEM_VF] = { .name = "vf", - .help = "match packets addressed to a virtual function ID", + .help = "match traffic from/to a virtual function ID", .priv = PRIV_ITEM(VF, sizeof(struct rte_flow_item_vf)), .next = NEXT(item_vf), .call = parse_vc, }, [ITEM_VF_ID] = { .name = "id", - .help = "destination VF ID", + .help = "VF ID", .next = NEXT(item_vf, NEXT_ENTRY(UNSIGNED), item_param), .args = ARGS(ARGS_ENTRY(struct rte_flow_item_vf, id)), }, @@ -1686,14 +1686,14 @@ static const struct token token_list[] = { }, [ACTION_PF] = { .name = "pf", - .help = "redirect packets to physical device function", + .help = "direct traffic to physical function", .priv = PRIV_ACTION(PF, 0), .next = NEXT(NEXT_ENTRY(ACTION_NEXT)), .call = parse_vc, }, [ACTION_VF] = { .name = "vf", - .help = "redirect packets to virtual device function", + .help = "direct traffic to a virtual function ID", .priv = PRIV_ACTION(VF, sizeof(struct rte_flow_action_vf)), .next = NEXT(action_vf), .call = parse_vc, @@ -1708,7 +1708,7 @@ static const struct token token_list[] = { }, [ACTION_VF_ID] = { .name = "id", - .help = "VF ID to redirect packets to", + .help = "VF ID", .next = NEXT(action_vf, NEXT_ENTRY(UNSIGNED)), .args = ARGS(ARGS_ENTRY(struct rte_flow_action_vf, id)), .call = parse_vc_conf, diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 550a4c95b..a0a124aa2 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -528,15 +528,12 @@ Usage example, matching non-TCPv4 packets only: Item: ``PF`` ^^^^^^^^^^^^ -Matches packets addressed to the physical function of the device. +Matches traffic originating from (ingress) or going to (egress) the physical +function of the current device. -If the underlying device function differs from the one that would normally -receive the matched traffic, specifying this item prevents it from reaching -that device unless the flow rule contains a `Action: PF`_. Packets are not -duplicated between device instances by default. +If supported, should work even if the physical function is not managed by +the application and thus not associated with a DPDK port ID. -- Likely to return an error or never match any traffic if applied to a VF - device. - Can be combined with any number of `Item: VF`_ to match both PF and VF traffic. - ``spec``, ``last`` and ``mask`` must not be set. @@ -558,15 +555,15 @@ duplicated between device instances by default. Item: ``VF`` ^^^^^^^^^^^^ -Matches packets addressed to a virtual function ID of the device. +Matches traffic originating from (ingress) or going to (egress) a given +virtual function of the current device. -If the underlying device function differs from the one that would normally -receive the matched traffic, specifying this item prevents it from reaching -that device unless the flow rule contains a `Action: VF`_. Packets are not -duplicated between device instances by default. +If supported, should work even if the virtual function is not managed by the +application and thus not associated with a DPDK port ID. + +Note this pattern item does not match VF representors traffic which, as +separate entities, should be addressed through their own DPDK port IDs. -- Likely to return an error or never match any traffic if this causes a VF - device to match traffic addressed to a different VF. - Can be specified multiple times to match traffic addressed to several VF IDs. - Can be combined with a PF item to match both PF and VF traffic. @@ -1395,7 +1392,10 @@ only matching traffic goes through. Action: ``PF`` ^^^^^^^^^^^^^^ -Redirects packets to the physical function (PF) of the current device. +Directs matching traffic to the physical function (PF) of the current +device. + +See `Item: PF`_. - No configurable properties. @@ -1412,13 +1412,15 @@ Redirects packets to the physical function (PF) of the current device. Action: ``VF`` ^^^^^^^^^^^^^^ -Redirects packets to a virtual function (VF) of the current device. +Directs matching traffic to a given virtual function of the current device. Packets matched by a VF pattern item can be redirected to their original VF ID instead of the specified one. This parameter may not be available and is not guaranteed to work properly if the VF part is matched by a prior flow rule or if packets are not addressed to a VF in the first place. +See `Item: VF`_. + .. _table_rte_flow_action_vf: .. table:: VF @@ -1428,7 +1430,7 @@ rule or if packets are not addressed to a VF in the first place. +==============+================================+ | ``original`` | use original VF ID if possible | +--------------+--------------------------------+ - | ``vf`` | VF ID to redirect packets to | + | ``id`` | VF ID | +--------------+--------------------------------+ Action: ``METER`` diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index 0bf6c33c9..af37c3d82 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3202,11 +3202,11 @@ This section lists supported pattern items and their attributes, if any. - ``num {unsigned}``: number of layers covered. -- ``pf``: match packets addressed to the physical function. +- ``pf``: match traffic from/to the physical function. -- ``vf``: match packets addressed to a virtual function ID. +- ``vf``: match traffic from/to a virtual function ID. - - ``id {unsigned}``: destination VF ID. + - ``id {unsigned}``: VF ID. - ``port``: device-specific physical port index to use. @@ -3416,12 +3416,12 @@ This section lists supported actions and their attributes, if any. - ``queues [{unsigned} [...]] end``: queue indices to use. -- ``pf``: redirect packets to physical device function. +- ``pf``: direct traffic to physical function. -- ``vf``: redirect packets to virtual device function. +- ``vf``: direct traffic to a virtual function ID. - ``original {boolean}``: use original VF ID if possible. - - ``id {unsigned}``: VF ID to redirect packets to. + - ``id {unsigned}``: VF ID. Destroying flow rules ~~~~~~~~~~~~~~~~~~~~~ diff --git a/drivers/net/bnxt/bnxt_filter.c b/drivers/net/bnxt/bnxt_filter.c index 68deb3445..dadd1e32f 100644 --- a/drivers/net/bnxt/bnxt_filter.c +++ b/drivers/net/bnxt/bnxt_filter.c @@ -283,6 +283,7 @@ bnxt_filter_type_check(const struct rte_flow_item pattern[], static int bnxt_validate_and_parse_flow_type(struct bnxt *bp, + const struct rte_flow_attr *attr, const struct rte_flow_item pattern[], struct rte_flow_error *error, struct bnxt_filter_info *filter) @@ -707,6 +708,16 @@ bnxt_validate_and_parse_flow_type(struct bnxt *bp, return -rte_errno; } + if (!attr->transfer) { + rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ITEM, + item, + "Matching VF traffic without" + " affecting it (transfer attribute)" + " is unsupported"); + return -rte_errno; + } + filter->mirror_vnic_id = dflt_vnic = bnxt_hwrm_func_qcfg_vf_dflt_vnic_id(bp, vf); if (dflt_vnic < 0) { @@ -754,14 +765,6 @@ bnxt_flow_parse_attr(const struct rte_flow_attr *attr, } /* Not supported */ - if (attr->transfer) { - rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, - attr, "No support for transfer."); - return -rte_errno; - } - - /* Not supported */ if (attr->priority) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, @@ -841,7 +844,8 @@ bnxt_validate_and_parse_flow(struct rte_eth_dev *dev, goto ret; } - rc = bnxt_validate_and_parse_flow_type(bp, pattern, error, filter); + rc = bnxt_validate_and_parse_flow_type(bp, attr, pattern, error, + filter); if (rc != 0) goto ret; diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c index f416b6a00..057e4f96d 100644 --- a/drivers/net/i40e/i40e_flow.c +++ b/drivers/net/i40e/i40e_flow.c @@ -54,6 +54,7 @@ static int i40e_flow_parse_ethertype_action(struct rte_eth_dev *dev, struct rte_flow_error *error, struct rte_eth_ethertype_filter *filter); static int i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev, + const struct rte_flow_attr *attr, const struct rte_flow_item *pattern, struct rte_flow_error *error, struct i40e_fdir_filter_conf *filter); @@ -1918,14 +1919,6 @@ i40e_flow_parse_attr(const struct rte_flow_attr *attr, } /* Not supported */ - if (attr->transfer) { - rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, - attr, "No support for transfer."); - return -rte_errno; - } - - /* Not supported */ if (attr->priority) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, @@ -2429,6 +2422,7 @@ i40e_flow_fdir_get_pctype_value(struct i40e_pf *pf, */ static int i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev, + const struct rte_flow_attr *attr, const struct rte_flow_item *pattern, struct rte_flow_error *error, struct i40e_fdir_filter_conf *filter) @@ -2966,6 +2960,16 @@ i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev, break; case RTE_FLOW_ITEM_TYPE_VF: vf_spec = item->spec; + if (!attr->transfer) { + rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ITEM, + item, + "Matching VF traffic" + " without affecting it" + " (transfer attribute)" + " is unsupported"); + return -rte_errno; + } filter->input.flow_ext.is_vf = 1; filter->input.flow_ext.dst_id = vf_spec->id; if (filter->input.flow_ext.is_vf && @@ -3128,7 +3132,8 @@ i40e_flow_parse_fdir_filter(struct rte_eth_dev *dev, &filter->fdir_filter; int ret; - ret = i40e_flow_parse_fdir_pattern(dev, pattern, error, fdir_filter); + ret = i40e_flow_parse_fdir_pattern(dev, attr, pattern, error, + fdir_filter); if (ret) return ret; diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index ab2bf2dce..f1c7a664e 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -152,13 +152,8 @@ enum rte_flow_item_type { /** * [META] * - * Matches packets addressed to the physical function of the device. - * - * If the underlying device function differs from the one that would - * normally receive the matched traffic, specifying this item - * prevents it from reaching that device unless the flow rule - * contains a PF action. Packets are not duplicated between device - * instances by default. + * Matches traffic originating from (ingress) or going to (egress) + * the physical function of the current device. * * No associated specification structure. */ @@ -167,13 +162,8 @@ enum rte_flow_item_type { /** * [META] * - * Matches packets addressed to a virtual function ID of the device. - * - * If the underlying device function differs from the one that would - * normally receive the matched traffic, specifying this item - * prevents it from reaching that device unless the flow rule - * contains a VF action. Packets are not duplicated between device - * instances by default. + * Matches traffic originating from (ingress) or going to (egress) a + * given virtual function of the current device. * * See struct rte_flow_item_vf. */ @@ -371,15 +361,15 @@ static const struct rte_flow_item_any rte_flow_item_any_mask = { /** * RTE_FLOW_ITEM_TYPE_VF * - * Matches packets addressed to a virtual function ID of the device. + * Matches traffic originating from (ingress) or going to (egress) a given + * virtual function of the current device. * - * If the underlying device function differs from the one that would - * normally receive the matched traffic, specifying this item prevents it - * from reaching that device unless the flow rule contains a VF - * action. Packets are not duplicated between device instances by default. + * If supported, should work even if the virtual function is not managed by + * the application and thus not associated with a DPDK port ID. + * + * Note this pattern item does not match VF representors traffic which, as + * separate entities, should be addressed through their own DPDK port IDs. * - * - Likely to return an error or never match any traffic if this causes a - * VF device to match traffic addressed to a different VF. * - Can be specified multiple times to match traffic addressed to several * VF IDs. * - Can be combined with a PF item to match both PF and VF traffic. @@ -387,7 +377,7 @@ static const struct rte_flow_item_any rte_flow_item_any_mask = { * A zeroed mask can be used to match any VF ID. */ struct rte_flow_item_vf { - uint32_t id; /**< Destination VF ID. */ + uint32_t id; /**< VF ID. */ }; /** Default mask for RTE_FLOW_ITEM_TYPE_VF. */ @@ -988,16 +978,16 @@ enum rte_flow_action_type { RTE_FLOW_ACTION_TYPE_RSS, /** - * Redirects packets to the physical function (PF) of the current - * device. + * Directs matching traffic to the physical function (PF) of the + * current device. * * No associated configuration structure. */ RTE_FLOW_ACTION_TYPE_PF, /** - * Redirects packets to the virtual function (VF) of the current - * device with the specified ID. + * Directs matching traffic to a given virtual function of the + * current device. * * See struct rte_flow_action_vf. */ @@ -1111,7 +1101,8 @@ struct rte_flow_action_rss { /** * RTE_FLOW_ACTION_TYPE_VF * - * Redirects packets to a virtual function (VF) of the current device. + * Directs matching traffic to a given virtual function of the current + * device. * * Packets matched by a VF pattern item can be redirected to their original * VF ID instead of the specified one. This parameter may not be available @@ -1122,7 +1113,7 @@ struct rte_flow_action_rss { struct rte_flow_action_vf { uint32_t original:1; /**< Use original VF ID if possible. */ uint32_t reserved:31; /**< Reserved, must be zero. */ - uint32_t id; /**< VF ID to redirect packets to. */ + uint32_t id; /**< VF ID. */ }; /** -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v5 14/16] ethdev: rename physical port item in flow API 2018-04-19 10:16 ` [dpdk-dev] [PATCH v5 00/16] Flow API overhaul for switch offloads Adrien Mazarguil ` (12 preceding siblings ...) 2018-04-19 10:16 ` [dpdk-dev] [PATCH v5 13/16] ethdev: update behavior of VF/PF in " Adrien Mazarguil @ 2018-04-19 10:16 ` Adrien Mazarguil 2018-04-19 10:16 ` [dpdk-dev] [PATCH v5 15/16] ethdev: add physical port action to " Adrien Mazarguil ` (2 subsequent siblings) 16 siblings, 0 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-19 10:16 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev While RTE_FLOW_ITEM_TYPE_PORT refers to physical ports of the underlying device using specific identifiers, these are often confused with DPDK port IDs exposed to applications in the global name space. Since this pattern item is seldom used, rename it RTE_FLOW_ITEM_PHY_PORT for better clarity. No ABI impact. Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Acked-by: Andrew Rybchenko <arybchenko@solarflare.com> --- app/test-pmd/cmdline_flow.c | 27 +++++++++++---------- app/test-pmd/config.c | 2 +- doc/guides/prog_guide/rte_flow.rst | 22 ++++++++--------- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 2 +- lib/librte_ether/rte_flow.c | 2 +- lib/librte_ether/rte_flow.h | 31 ++++++++++-------------- 6 files changed, 41 insertions(+), 45 deletions(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 41103de67..f9f937277 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -87,8 +87,8 @@ enum index { ITEM_PF, ITEM_VF, ITEM_VF_ID, - ITEM_PORT, - ITEM_PORT_INDEX, + ITEM_PHY_PORT, + ITEM_PHY_PORT_INDEX, ITEM_RAW, ITEM_RAW_RELATIVE, ITEM_RAW_SEARCH, @@ -441,7 +441,7 @@ static const enum index next_item[] = { ITEM_ANY, ITEM_PF, ITEM_VF, - ITEM_PORT, + ITEM_PHY_PORT, ITEM_RAW, ITEM_ETH, ITEM_VLAN, @@ -482,8 +482,8 @@ static const enum index item_vf[] = { ZERO, }; -static const enum index item_port[] = { - ITEM_PORT_INDEX, +static const enum index item_phy_port[] = { + ITEM_PHY_PORT_INDEX, ITEM_NEXT, ZERO, }; @@ -1059,18 +1059,19 @@ static const struct token token_list[] = { .next = NEXT(item_vf, NEXT_ENTRY(UNSIGNED), item_param), .args = ARGS(ARGS_ENTRY(struct rte_flow_item_vf, id)), }, - [ITEM_PORT] = { - .name = "port", - .help = "device-specific physical port index to use", - .priv = PRIV_ITEM(PORT, sizeof(struct rte_flow_item_port)), - .next = NEXT(item_port), + [ITEM_PHY_PORT] = { + .name = "phy_port", + .help = "match traffic from/to a specific physical port", + .priv = PRIV_ITEM(PHY_PORT, + sizeof(struct rte_flow_item_phy_port)), + .next = NEXT(item_phy_port), .call = parse_vc, }, - [ITEM_PORT_INDEX] = { + [ITEM_PHY_PORT_INDEX] = { .name = "index", .help = "physical port index", - .next = NEXT(item_port, NEXT_ENTRY(UNSIGNED), item_param), - .args = ARGS(ARGS_ENTRY(struct rte_flow_item_port, index)), + .next = NEXT(item_phy_port, NEXT_ENTRY(UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_phy_port, index)), }, [ITEM_RAW] = { .name = "raw", diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index a50a5c544..840320108 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -976,7 +976,7 @@ static const struct { MK_FLOW_ITEM(ANY, sizeof(struct rte_flow_item_any)), MK_FLOW_ITEM(PF, 0), MK_FLOW_ITEM(VF, sizeof(struct rte_flow_item_vf)), - MK_FLOW_ITEM(PORT, sizeof(struct rte_flow_item_port)), + MK_FLOW_ITEM(PHY_PORT, sizeof(struct rte_flow_item_phy_port)), MK_FLOW_ITEM(RAW, sizeof(struct rte_flow_item_raw)), MK_FLOW_ITEM(ETH, sizeof(struct rte_flow_item_eth)), MK_FLOW_ITEM(VLAN, sizeof(struct rte_flow_item_vlan)), diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index a0a124aa2..4e053c24b 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -195,8 +195,8 @@ When supported, this effectively enables an application to reroute traffic not necessarily intended for it (e.g. coming from or addressed to different physical ports, VFs or applications) at the device level. -It complements the behavior of some pattern items such as `Item: PORT`_ and -is meaningless without them. +It complements the behavior of some pattern items such as `Item: PHY_PORT`_ +and is meaningless without them. When transferring flow rules, **ingress** and **egress** attributes (`Attribute: Traffic direction`_) keep their original meaning, as if @@ -583,15 +583,15 @@ separate entities, should be addressed through their own DPDK port IDs. | ``mask`` | ``id`` | zeroed to match any VF ID | +----------+----------+---------------------------+ -Item: ``PORT`` -^^^^^^^^^^^^^^ +Item: ``PHY_PORT`` +^^^^^^^^^^^^^^^^^^ -Matches packets coming from the specified physical port of the underlying -device. +Matches traffic originating from (ingress) or going to (egress) a physical +port of the underlying device. -The first PORT item overrides the physical port normally associated with the -specified DPDK input port (port_id). This item can be provided several times -to match additional physical ports. +The first PHY_PORT item overrides the physical port normally associated with +the specified DPDK input port (port_id). This item can be provided several +times to match additional physical ports. Note that physical ports are not necessarily tied to DPDK input ports (port_id) when those are not under DPDK control. Possible values are @@ -603,9 +603,9 @@ associated with a port_id should be retrieved by other means. - Default ``mask`` matches any port index. -.. _table_rte_flow_item_port: +.. _table_rte_flow_item_phy_port: -.. table:: PORT +.. table:: PHY_PORT +----------+-----------+--------------------------------+ | Field | Subfield | Value | diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index af37c3d82..a2bbd1930 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3208,7 +3208,7 @@ This section lists supported pattern items and their attributes, if any. - ``id {unsigned}``: VF ID. -- ``port``: device-specific physical port index to use. +- ``phy_port``: match traffic from/to a specific physical port. - ``index {unsigned}``: physical port index. diff --git a/lib/librte_ether/rte_flow.c b/lib/librte_ether/rte_flow.c index 83b733ff0..36e277a4f 100644 --- a/lib/librte_ether/rte_flow.c +++ b/lib/librte_ether/rte_flow.c @@ -38,7 +38,7 @@ static const struct rte_flow_desc_data rte_flow_desc_item[] = { MK_FLOW_ITEM(ANY, sizeof(struct rte_flow_item_any)), MK_FLOW_ITEM(PF, 0), MK_FLOW_ITEM(VF, sizeof(struct rte_flow_item_vf)), - MK_FLOW_ITEM(PORT, sizeof(struct rte_flow_item_port)), + MK_FLOW_ITEM(PHY_PORT, sizeof(struct rte_flow_item_phy_port)), MK_FLOW_ITEM(RAW, sizeof(struct rte_flow_item_raw)), MK_FLOW_ITEM(ETH, sizeof(struct rte_flow_item_eth)), MK_FLOW_ITEM(VLAN, sizeof(struct rte_flow_item_vlan)), diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index f1c7a664e..2c7c4d009 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -84,7 +84,7 @@ struct rte_flow_attr { * applications) at the device level. * * It complements the behavior of some pattern items such as - * RTE_FLOW_ITEM_TYPE_PORT and is meaningless without them. + * RTE_FLOW_ITEM_TYPE_PHY_PORT and is meaningless without them. * * When transferring flow rules, ingress and egress attributes keep * their original meaning, as if processing traffic emitted or @@ -172,17 +172,12 @@ enum rte_flow_item_type { /** * [META] * - * Matches packets coming from the specified physical port of the - * underlying device. - * - * The first PORT item overrides the physical port normally - * associated with the specified DPDK input port (port_id). This - * item can be provided several times to match additional physical - * ports. + * Matches traffic originating from (ingress) or going to (egress) a + * physical port of the underlying device. * - * See struct rte_flow_item_port. + * See struct rte_flow_item_phy_port. */ - RTE_FLOW_ITEM_TYPE_PORT, + RTE_FLOW_ITEM_TYPE_PHY_PORT, /** * Matches a byte string of a given length at a given offset. @@ -388,13 +383,13 @@ static const struct rte_flow_item_vf rte_flow_item_vf_mask = { #endif /** - * RTE_FLOW_ITEM_TYPE_PORT + * RTE_FLOW_ITEM_TYPE_PHY_PORT * - * Matches packets coming from the specified physical port of the underlying - * device. + * Matches traffic originating from (ingress) or going to (egress) a + * physical port of the underlying device. * - * The first PORT item overrides the physical port normally associated with - * the specified DPDK input port (port_id). This item can be provided + * The first PHY_PORT item overrides the physical port normally associated + * with the specified DPDK input port (port_id). This item can be provided * several times to match additional physical ports. * * Note that physical ports are not necessarily tied to DPDK input ports @@ -407,13 +402,13 @@ static const struct rte_flow_item_vf rte_flow_item_vf_mask = { * * A zeroed mask can be used to match any port index. */ -struct rte_flow_item_port { +struct rte_flow_item_phy_port { uint32_t index; /**< Physical port index. */ }; -/** Default mask for RTE_FLOW_ITEM_TYPE_PORT. */ +/** Default mask for RTE_FLOW_ITEM_TYPE_PHY_PORT. */ #ifndef __cplusplus -static const struct rte_flow_item_port rte_flow_item_port_mask = { +static const struct rte_flow_item_phy_port rte_flow_item_phy_port_mask = { .index = 0x00000000, }; #endif -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v5 15/16] ethdev: add physical port action to flow API 2018-04-19 10:16 ` [dpdk-dev] [PATCH v5 00/16] Flow API overhaul for switch offloads Adrien Mazarguil ` (13 preceding siblings ...) 2018-04-19 10:16 ` [dpdk-dev] [PATCH v5 14/16] ethdev: rename physical port item " Adrien Mazarguil @ 2018-04-19 10:16 ` Adrien Mazarguil 2018-04-19 10:16 ` [dpdk-dev] [PATCH v5 16/16] ethdev: add port ID item and " Adrien Mazarguil 2018-04-25 15:27 ` [dpdk-dev] [PATCH v6 00/16] Flow API overhaul for switch offloads Adrien Mazarguil 16 siblings, 0 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-19 10:16 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev; +Cc: Zhang, Qi Z This patch adds the missing action counterpart to the PHY_PORT pattern item, that is, the ability to directly inject matching traffic into a physical port of the underlying device. It breaks ABI compatibility for the following public functions: - rte_flow_copy() - rte_flow_create() - rte_flow_query() - rte_flow_validate() Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Acked-by: Andrew Rybchenko <arybchenko@solarflare.com> Acked-by: Mohammad Abdul Awal <mohammad.abdul.awal@intel.com> Cc: "Zhang, Qi Z" <qi.z.zhang@intel.com> --- app/test-pmd/cmdline_flow.c | 35 ++++++++++++++++++++++++ app/test-pmd/config.c | 1 + doc/guides/prog_guide/rte_flow.rst | 20 ++++++++++++++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 5 ++++ lib/librte_ether/rte_flow.c | 1 + lib/librte_ether/rte_flow.h | 22 +++++++++++++++ 6 files changed, 84 insertions(+) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index f9f937277..356714801 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -182,6 +182,9 @@ enum index { ACTION_VF, ACTION_VF_ORIGINAL, ACTION_VF_ID, + ACTION_PHY_PORT, + ACTION_PHY_PORT_ORIGINAL, + ACTION_PHY_PORT_INDEX, ACTION_METER, ACTION_METER_ID, }; @@ -623,6 +626,7 @@ static const enum index next_action[] = { ACTION_RSS, ACTION_PF, ACTION_VF, + ACTION_PHY_PORT, ACTION_METER, ZERO, }; @@ -657,6 +661,13 @@ static const enum index action_vf[] = { ZERO, }; +static const enum index action_phy_port[] = { + ACTION_PHY_PORT_ORIGINAL, + ACTION_PHY_PORT_INDEX, + ACTION_NEXT, + ZERO, +}; + static const enum index action_meter[] = { ACTION_METER_ID, ACTION_NEXT, @@ -1714,6 +1725,30 @@ static const struct token token_list[] = { .args = ARGS(ARGS_ENTRY(struct rte_flow_action_vf, id)), .call = parse_vc_conf, }, + [ACTION_PHY_PORT] = { + .name = "phy_port", + .help = "direct packets to physical port index", + .priv = PRIV_ACTION(PHY_PORT, + sizeof(struct rte_flow_action_phy_port)), + .next = NEXT(action_phy_port), + .call = parse_vc, + }, + [ACTION_PHY_PORT_ORIGINAL] = { + .name = "original", + .help = "use original port index if possible", + .next = NEXT(action_phy_port, NEXT_ENTRY(BOOLEAN)), + .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_phy_port, + original, 1)), + .call = parse_vc_conf, + }, + [ACTION_PHY_PORT_INDEX] = { + .name = "index", + .help = "physical port index", + .next = NEXT(action_phy_port, NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_phy_port, + index)), + .call = parse_vc_conf, + }, [ACTION_METER] = { .name = "meter", .help = "meter the directed packets at given id", diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 840320108..2d68f1fb0 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -1074,6 +1074,7 @@ static const struct { MK_FLOW_ACTION(RSS, sizeof(struct rte_flow_action_rss)), MK_FLOW_ACTION(PF, 0), MK_FLOW_ACTION(VF, sizeof(struct rte_flow_action_vf)), + MK_FLOW_ACTION(PHY_PORT, sizeof(struct rte_flow_action_phy_port)), MK_FLOW_ACTION(METER, sizeof(struct rte_flow_action_meter)), }; diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 4e053c24b..a39c1e1b0 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -1433,6 +1433,26 @@ See `Item: VF`_. | ``id`` | VF ID | +--------------+--------------------------------+ +Action: ``PHY_PORT`` +^^^^^^^^^^^^^^^^^^^^ + +Directs matching traffic to a given physical port index of the underlying +device. + +See `Item: PHY_PORT`_. + +.. _table_rte_flow_action_phy_port: + +.. table:: PHY_PORT + + +--------------+-------------------------------------+ + | Field | Value | + +==============+=====================================+ + | ``original`` | use original port index if possible | + +--------------+-------------------------------------+ + | ``index`` | physical port index | + +--------------+-------------------------------------+ + Action: ``METER`` ^^^^^^^^^^^^^^^^^ diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index a2bbd1930..64d8dfddb 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3423,6 +3423,11 @@ This section lists supported actions and their attributes, if any. - ``original {boolean}``: use original VF ID if possible. - ``id {unsigned}``: VF ID. +- ``phy_port``: direct packets to physical port index. + + - ``original {boolean}``: use original port index if possible. + - ``index {unsigned}``: physical port index. + Destroying flow rules ~~~~~~~~~~~~~~~~~~~~~ diff --git a/lib/librte_ether/rte_flow.c b/lib/librte_ether/rte_flow.c index 36e277a4f..00989c73b 100644 --- a/lib/librte_ether/rte_flow.c +++ b/lib/librte_ether/rte_flow.c @@ -76,6 +76,7 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = { MK_FLOW_ACTION(RSS, sizeof(struct rte_flow_action_rss)), MK_FLOW_ACTION(PF, 0), MK_FLOW_ACTION(VF, sizeof(struct rte_flow_action_vf)), + MK_FLOW_ACTION(PHY_PORT, sizeof(struct rte_flow_action_phy_port)), }; static int diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index 2c7c4d009..58b75e934 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -989,6 +989,14 @@ enum rte_flow_action_type { RTE_FLOW_ACTION_TYPE_VF, /** + * Directs packets to a given physical port index of the underlying + * device. + * + * See struct rte_flow_action_phy_port. + */ + RTE_FLOW_ACTION_TYPE_PHY_PORT, + + /** * Traffic metering and policing (MTR). * * See struct rte_flow_action_meter. @@ -1112,6 +1120,20 @@ struct rte_flow_action_vf { }; /** + * RTE_FLOW_ACTION_TYPE_PHY_PORT + * + * Directs packets to a given physical port index of the underlying + * device. + * + * @see RTE_FLOW_ITEM_TYPE_PHY_PORT + */ +struct rte_flow_action_phy_port { + uint32_t original:1; /**< Use original port index if possible. */ + uint32_t reserved:31; /**< Reserved, must be zero. */ + uint32_t index; /**< Physical port index. */ +}; + +/** * RTE_FLOW_ACTION_TYPE_METER * * Traffic metering and policing (MTR). -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v5 16/16] ethdev: add port ID item and action to flow API 2018-04-19 10:16 ` [dpdk-dev] [PATCH v5 00/16] Flow API overhaul for switch offloads Adrien Mazarguil ` (14 preceding siblings ...) 2018-04-19 10:16 ` [dpdk-dev] [PATCH v5 15/16] ethdev: add physical port action to " Adrien Mazarguil @ 2018-04-19 10:16 ` Adrien Mazarguil 2018-04-25 15:27 ` [dpdk-dev] [PATCH v6 00/16] Flow API overhaul for switch offloads Adrien Mazarguil 16 siblings, 0 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-19 10:16 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev; +Cc: Zhang, Qi Z, Declan Doherty RTE_FLOW_ACTION_TYPE_PORT_ID brings the ability to inject matching traffic into a different device, as identified by its DPDK port ID. This is normally only supported when the target port ID has some kind of relationship with the port ID the flow rule is created against, such as being exposed by a common physical device (e.g. a different port of an Ethernet switch). The converse pattern item, RTE_FLOW_ITEM_TYPE_PORT_ID, makes the resulting flow rule match traffic whose origin is the specified port ID. Note that specifying a port ID that differs from the one the flow rule is created against is normally meaningless (if even accepted), but can make sense if combined with the transfer attribute. These must not be confused with their PHY_PORT counterparts, which refer to physical ports using device-specific indices, but unlike PORT_ID are not necessarily tied to DPDK port IDs. This breaks ABI compatibility for the following public functions: - rte_flow_copy() - rte_flow_create() - rte_flow_query() - rte_flow_validate() Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Reviewed-by: Qi Zhang <qi.z.zhang@intel.com> Acked-by: Andrew Rybchenko <arybchenko@solarflare.com> Cc: "Zhang, Qi Z" <qi.z.zhang@intel.com> Cc: Declan Doherty <declan.doherty@intel.com> --- This patch provides the same functionality and supersedes Qi Zhang's "ether: add flow action to redirect packet to a port" [1]. The main differences are: - Action is named PORT_ID instead of PORT. - Addition of a PORT_ID pattern item. - More extensive documentation. - Testpmd support. - rte_flow_copy() support. [1] http://dpdk.org/ml/archives/dev/2018-April/094648.html --- app/test-pmd/cmdline_flow.c | 57 ++++++++++++++++++++++++ app/test-pmd/config.c | 2 + doc/guides/prog_guide/rte_flow.rst | 48 ++++++++++++++++++++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 9 ++++ lib/librte_ether/rte_flow.c | 2 + lib/librte_ether/rte_flow.h | 56 +++++++++++++++++++++++ 6 files changed, 174 insertions(+) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 356714801..32fe6645a 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -89,6 +89,8 @@ enum index { ITEM_VF_ID, ITEM_PHY_PORT, ITEM_PHY_PORT_INDEX, + ITEM_PORT_ID, + ITEM_PORT_ID_ID, ITEM_RAW, ITEM_RAW_RELATIVE, ITEM_RAW_SEARCH, @@ -185,6 +187,9 @@ enum index { ACTION_PHY_PORT, ACTION_PHY_PORT_ORIGINAL, ACTION_PHY_PORT_INDEX, + ACTION_PORT_ID, + ACTION_PORT_ID_ORIGINAL, + ACTION_PORT_ID_ID, ACTION_METER, ACTION_METER_ID, }; @@ -445,6 +450,7 @@ static const enum index next_item[] = { ITEM_PF, ITEM_VF, ITEM_PHY_PORT, + ITEM_PORT_ID, ITEM_RAW, ITEM_ETH, ITEM_VLAN, @@ -491,6 +497,12 @@ static const enum index item_phy_port[] = { ZERO, }; +static const enum index item_port_id[] = { + ITEM_PORT_ID_ID, + ITEM_NEXT, + ZERO, +}; + static const enum index item_raw[] = { ITEM_RAW_RELATIVE, ITEM_RAW_SEARCH, @@ -627,6 +639,7 @@ static const enum index next_action[] = { ACTION_PF, ACTION_VF, ACTION_PHY_PORT, + ACTION_PORT_ID, ACTION_METER, ZERO, }; @@ -668,6 +681,13 @@ static const enum index action_phy_port[] = { ZERO, }; +static const enum index action_port_id[] = { + ACTION_PORT_ID_ORIGINAL, + ACTION_PORT_ID_ID, + ACTION_NEXT, + ZERO, +}; + static const enum index action_meter[] = { ACTION_METER_ID, ACTION_NEXT, @@ -1084,6 +1104,20 @@ static const struct token token_list[] = { .next = NEXT(item_phy_port, NEXT_ENTRY(UNSIGNED), item_param), .args = ARGS(ARGS_ENTRY(struct rte_flow_item_phy_port, index)), }, + [ITEM_PORT_ID] = { + .name = "port_id", + .help = "match traffic from/to a given DPDK port ID", + .priv = PRIV_ITEM(PORT_ID, + sizeof(struct rte_flow_item_port_id)), + .next = NEXT(item_port_id), + .call = parse_vc, + }, + [ITEM_PORT_ID_ID] = { + .name = "id", + .help = "DPDK port ID", + .next = NEXT(item_port_id, NEXT_ENTRY(UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_port_id, id)), + }, [ITEM_RAW] = { .name = "raw", .help = "match an arbitrary byte string", @@ -1749,6 +1783,29 @@ static const struct token token_list[] = { index)), .call = parse_vc_conf, }, + [ACTION_PORT_ID] = { + .name = "port_id", + .help = "direct matching traffic to a given DPDK port ID", + .priv = PRIV_ACTION(PORT_ID, + sizeof(struct rte_flow_action_port_id)), + .next = NEXT(action_port_id), + .call = parse_vc, + }, + [ACTION_PORT_ID_ORIGINAL] = { + .name = "original", + .help = "use original DPDK port ID if possible", + .next = NEXT(action_port_id, NEXT_ENTRY(BOOLEAN)), + .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_port_id, + original, 1)), + .call = parse_vc_conf, + }, + [ACTION_PORT_ID_ID] = { + .name = "id", + .help = "DPDK port ID", + .next = NEXT(action_port_id, NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_port_id, id)), + .call = parse_vc_conf, + }, [ACTION_METER] = { .name = "meter", .help = "meter the directed packets at given id", diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 2d68f1fb0..e7026011b 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -977,6 +977,7 @@ static const struct { MK_FLOW_ITEM(PF, 0), MK_FLOW_ITEM(VF, sizeof(struct rte_flow_item_vf)), MK_FLOW_ITEM(PHY_PORT, sizeof(struct rte_flow_item_phy_port)), + MK_FLOW_ITEM(PORT_ID, sizeof(struct rte_flow_item_port_id)), MK_FLOW_ITEM(RAW, sizeof(struct rte_flow_item_raw)), MK_FLOW_ITEM(ETH, sizeof(struct rte_flow_item_eth)), MK_FLOW_ITEM(VLAN, sizeof(struct rte_flow_item_vlan)), @@ -1075,6 +1076,7 @@ static const struct { MK_FLOW_ACTION(PF, 0), MK_FLOW_ACTION(VF, sizeof(struct rte_flow_action_vf)), MK_FLOW_ACTION(PHY_PORT, sizeof(struct rte_flow_action_phy_port)), + MK_FLOW_ACTION(PORT_ID, sizeof(struct rte_flow_action_port_id)), MK_FLOW_ACTION(METER, sizeof(struct rte_flow_action_meter)), }; diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index a39c1e1b0..2fb8e9c3f 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -617,6 +617,36 @@ associated with a port_id should be retrieved by other means. | ``mask`` | ``index`` | zeroed to match any port index | +----------+-----------+--------------------------------+ +Item: ``PORT_ID`` +^^^^^^^^^^^^^^^^^ + +Matches traffic originating from (ingress) or going to (egress) a given DPDK +port ID. + +Normally only supported if the port ID in question is known by the +underlying PMD and related to the device the flow rule is created against. + +This must not be confused with `Item: PHY_PORT`_ which refers to the +physical port of a device, whereas `Item: PORT_ID`_ refers to a ``struct +rte_eth_dev`` object on the application side (also known as "port +representor" depending on the kind of underlying device). + +- Default ``mask`` matches the specified DPDK port ID. + +.. _table_rte_flow_item_port_id: + +.. table:: PORT_ID + + +----------+----------+-----------------------------+ + | Field | Subfield | Value | + +==========+==========+=============================+ + | ``spec`` | ``id`` | DPDK port ID | + +----------+----------+-----------------------------+ + | ``last`` | ``id`` | upper range value | + +----------+----------+-----------------------------+ + | ``mask`` | ``id`` | zeroed to match any port ID | + +----------+----------+-----------------------------+ + Data matching item types ~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1453,6 +1483,24 @@ See `Item: PHY_PORT`_. | ``index`` | physical port index | +--------------+-------------------------------------+ +Action: ``PORT_ID`` +^^^^^^^^^^^^^^^^^^^ +Directs matching traffic to a given DPDK port ID. + +See `Item: PORT_ID`_. + +.. _table_rte_flow_action_port_id: + +.. table:: PORT_ID + + +--------------+---------------------------------------+ + | Field | Value | + +==============+=======================================+ + | ``original`` | use original DPDK port ID if possible | + +--------------+---------------------------------------+ + | ``id`` | DPDK port ID | + +--------------+---------------------------------------+ + Action: ``METER`` ^^^^^^^^^^^^^^^^^ diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index 64d8dfddb..bfb5ad027 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3212,6 +3212,10 @@ This section lists supported pattern items and their attributes, if any. - ``index {unsigned}``: physical port index. +- ``port_id``: match traffic from/to a given DPDK port ID. + + - ``id {unsigned}``: DPDK port ID. + - ``raw``: match an arbitrary byte string. - ``relative {boolean}``: look for pattern after the previous item. @@ -3428,6 +3432,11 @@ This section lists supported actions and their attributes, if any. - ``original {boolean}``: use original port index if possible. - ``index {unsigned}``: physical port index. +- ``port_id``: direct matching traffic to a given DPDK port ID. + + - ``original {boolean}``: use original DPDK port ID if possible. + - ``id {unsigned}``: DPDK port ID. + Destroying flow rules ~~~~~~~~~~~~~~~~~~~~~ diff --git a/lib/librte_ether/rte_flow.c b/lib/librte_ether/rte_flow.c index 00989c73b..cecab59f6 100644 --- a/lib/librte_ether/rte_flow.c +++ b/lib/librte_ether/rte_flow.c @@ -39,6 +39,7 @@ static const struct rte_flow_desc_data rte_flow_desc_item[] = { MK_FLOW_ITEM(PF, 0), MK_FLOW_ITEM(VF, sizeof(struct rte_flow_item_vf)), MK_FLOW_ITEM(PHY_PORT, sizeof(struct rte_flow_item_phy_port)), + MK_FLOW_ITEM(PORT_ID, sizeof(struct rte_flow_item_port_id)), MK_FLOW_ITEM(RAW, sizeof(struct rte_flow_item_raw)), MK_FLOW_ITEM(ETH, sizeof(struct rte_flow_item_eth)), MK_FLOW_ITEM(VLAN, sizeof(struct rte_flow_item_vlan)), @@ -77,6 +78,7 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = { MK_FLOW_ACTION(PF, 0), MK_FLOW_ACTION(VF, sizeof(struct rte_flow_action_vf)), MK_FLOW_ACTION(PHY_PORT, sizeof(struct rte_flow_action_phy_port)), + MK_FLOW_ACTION(PORT_ID, sizeof(struct rte_flow_action_port_id)), }; static int diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index 58b75e934..09a21e531 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -180,6 +180,16 @@ enum rte_flow_item_type { RTE_FLOW_ITEM_TYPE_PHY_PORT, /** + * [META] + * + * Matches traffic originating from (ingress) or going to (egress) a + * given DPDK port ID. + * + * See struct rte_flow_item_port_id. + */ + RTE_FLOW_ITEM_TYPE_PORT_ID, + + /** * Matches a byte string of a given length at a given offset. * * See struct rte_flow_item_raw. @@ -414,6 +424,32 @@ static const struct rte_flow_item_phy_port rte_flow_item_phy_port_mask = { #endif /** + * RTE_FLOW_ITEM_TYPE_PORT_ID + * + * Matches traffic originating from (ingress) or going to (egress) a given + * DPDK port ID. + * + * Normally only supported if the port ID in question is known by the + * underlying PMD and related to the device the flow rule is created + * against. + * + * This must not be confused with @p PHY_PORT which refers to the physical + * port of a device, whereas @p PORT_ID refers to a struct rte_eth_dev + * object on the application side (also known as "port representor" + * depending on the kind of underlying device). + */ +struct rte_flow_item_port_id { + uint32_t id; /**< DPDK port ID. */ +}; + +/** Default mask for RTE_FLOW_ITEM_TYPE_PORT_ID. */ +#ifndef __cplusplus +static const struct rte_flow_item_port_id rte_flow_item_port_id_mask = { + .id = 0xffffffff, +}; +#endif + +/** * RTE_FLOW_ITEM_TYPE_RAW * * Matches a byte string of a given length at a given offset. @@ -997,6 +1033,13 @@ enum rte_flow_action_type { RTE_FLOW_ACTION_TYPE_PHY_PORT, /** + * Directs matching traffic to a given DPDK port ID. + * + * See struct rte_flow_action_port_id. + */ + RTE_FLOW_ACTION_TYPE_PORT_ID, + + /** * Traffic metering and policing (MTR). * * See struct rte_flow_action_meter. @@ -1134,6 +1177,19 @@ struct rte_flow_action_phy_port { }; /** + * RTE_FLOW_ACTION_TYPE_PORT_ID + * + * Directs matching traffic to a given DPDK port ID. + * + * @see RTE_FLOW_ITEM_TYPE_PORT_ID + */ +struct rte_flow_action_port_id { + uint32_t original:1; /**< Use original DPDK port ID if possible. */ + uint32_t reserved:31; /**< Reserved, must be zero. */ + uint32_t id; /**< DPDK port ID. */ +}; + +/** * RTE_FLOW_ACTION_TYPE_METER * * Traffic metering and policing (MTR). -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v6 00/16] Flow API overhaul for switch offloads 2018-04-19 10:16 ` [dpdk-dev] [PATCH v5 00/16] Flow API overhaul for switch offloads Adrien Mazarguil ` (15 preceding siblings ...) 2018-04-19 10:16 ` [dpdk-dev] [PATCH v5 16/16] ethdev: add port ID item and " Adrien Mazarguil @ 2018-04-25 15:27 ` Adrien Mazarguil 2018-04-25 15:27 ` [dpdk-dev] [PATCH v6 01/16] ethdev: add error types to flow API Adrien Mazarguil ` (16 more replies) 16 siblings, 17 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-25 15:27 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev As summarized in a prior RFC [1], the flow API (rte_flow) was chosen as a means to manage switch offloads supported by many devices (usually going by names such as E-Switch or vSwitch) through user-specified flow rules. Combined with the need to support encap/decap actions, this requires a change in the way flow actions are processed (in order and possibly repeated) which modifies the behavior of some of the existing actions, thus warranting a major ABI breakage. Given this ABI breakage is also required by other work submitted for the current release [2][3], this series addresses various longstanding issues with the flow API and makes minor improvements in preparation for upcoming features. Changes summary: - Additional error types. - Clearer documentation. - Improved C++ compatibility. - Exhaustive RSS action. - Consistent behavior of VLAN pattern item. - New "transfer" attribute bringing consistency to VF/PF pattern items. - Confusing "PORT" pattern item renamed "PHY_PORT", with new action counterpart. - New "PORT_ID" pattern item and action to be used with port representors. This series piggybacks on the major ABI update introduced by a prior commit [4] for DPDK 18.05 and depends on several fixes [5] which must be applied first. [1] "[RFC] Switch device offload with DPDK" http://dpdk.org/ml/archives/dev/2018-March/092513.html [2] commit 676b605182a5 ("doc: announce ethdev API change for RSS configuration") [3] "[PATCH v1 00/21] MLX5 tunnel Rx offloading" http://dpdk.org/ml/archives/dev/2018-March/092264.html [4] commit 653e038efc9b ("ethdev: remove versioning of filter control function") [5] "[PATCH v6 00/11] Bunch of flow API-related fixes" http://dpdk.org/ml/archives/dev/2018-April/098035.html v6 changes: - Fixed mlx5 issue raised by Nelio in "ethdev: flatten RSS configuration in flow API". - Updated release notes (API update / ABI breakage) in relevant patches. - Removed Xueming's deprecation notice in "ethdev: add encap level to RSS flow API action" since it's covered by this series. - Reworded a few patches as fixes since they address API flaws. - Rebased series once again. v5 changes: - Fixed errors reported by GCC and Clang in patch 05/16 ("ethdev: alter behavior of flow API actions"). - Rebased series once again. v4 changes: - No change besides new acked-by lines, rebased series to address conflicts. v3 changes: - Rebased series, fixed latest conflicts. - Addressed Andrew's comments, see affected patches for details: - Empty RSS types in flow rule means PMD-specific RSS instead of no RSS. - RSS hash function now explicitly compared against RTE_ETH_HASH_FUNCTION_DEFAULT instead of 0 in all PMDs. - sfc PMD updated to also accept Toeplitz. - Implicit VLAN TPID matching now removed from all PMDs. - Default mask upate for VLAN TCI now split as separate patch #11. - Ingress/egress definition clarified in patch #12. v2 changes: - Squashed "ethdev: update ABI for flow API functions" in subsequent patches. - Emphasized ABI impact in relevant commit logs. - Modified documentation in "ethdev: alter behavior of flow API actions" to describe how terminating flow rules without any action of the fate kind result in undefined behavior instead of dropping traffic. - Fixed other minor documentation formatting issues. - Modified "ethdev: refine TPID handling in flow API" as follows: - Using standard macro definitions for VLAN, QinQ and E-Tag EtherTypes. - Fixed endian conversion in sfc. - Replaced a condition in VLAN pattern item processing with an assertion check for i40e. Adrien Mazarguil (16): ethdev: add error types to flow API ethdev: clarify flow API pattern items and actions doc: remove flow API migration section ethdev: remove DUP action from flow API ethdev: alter behavior of flow API actions ethdev: fix C99 flexible arrays from flow API ethdev: flatten RSS configuration in flow API ethdev: add hash function to RSS flow API action ethdev: add encap level to RSS flow API action ethdev: fix TPID handling in flow API ethdev: fix default VLAN TCI mask in flow API ethdev: add transfer attribute to flow API ethdev: fix behavior of VF/PF in flow API ethdev: rename physical port item in flow API ethdev: add physical port action to flow API ethdev: add port ID item and action to flow API app/test-pmd/cmdline_flow.c | 394 +++++++++++---- app/test-pmd/config.c | 78 +-- doc/guides/nics/tap.rst | 2 +- doc/guides/prog_guide/rte_flow.rst | 618 ++++++++--------------- doc/guides/rel_notes/deprecation.rst | 4 - doc/guides/rel_notes/release_18_05.rst | 48 ++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 60 ++- drivers/net/bnxt/bnxt_filter.c | 49 +- drivers/net/e1000/e1000_ethdev.h | 13 +- drivers/net/e1000/igb_ethdev.c | 4 +- drivers/net/e1000/igb_flow.c | 83 ++- drivers/net/e1000/igb_rxtx.c | 55 +- drivers/net/enic/enic_flow.c | 50 +- drivers/net/i40e/i40e_ethdev.c | 57 ++- drivers/net/i40e/i40e_ethdev.h | 15 +- drivers/net/i40e/i40e_flow.c | 130 +++-- drivers/net/ixgbe/ixgbe_ethdev.c | 7 +- drivers/net/ixgbe/ixgbe_ethdev.h | 13 +- drivers/net/ixgbe/ixgbe_flow.c | 91 +++- drivers/net/ixgbe/ixgbe_rxtx.c | 55 +- drivers/net/mlx4/mlx4.c | 2 +- drivers/net/mlx4/mlx4_flow.c | 117 +++-- drivers/net/mlx4/mlx4_flow.h | 2 +- drivers/net/mlx4/mlx4_rxq.c | 2 +- drivers/net/mlx4/mlx4_rxtx.h | 2 +- drivers/net/mlx5/mlx5_flow.c | 316 ++++++------ drivers/net/mlx5/mlx5_rxq.c | 26 +- drivers/net/mlx5/mlx5_rxtx.h | 26 +- drivers/net/mvpp2/mrvl_flow.c | 32 +- drivers/net/sfc/sfc_flow.c | 78 ++- drivers/net/tap/tap_flow.c | 49 +- examples/ipsec-secgw/ipsec.c | 21 +- lib/librte_ether/rte_ethdev_version.map | 16 +- lib/librte_ether/rte_flow.c | 68 +-- lib/librte_ether/rte_flow.h | 339 ++++++++----- lib/librte_net/rte_ether.h | 1 + 36 files changed, 1796 insertions(+), 1127 deletions(-) -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v6 01/16] ethdev: add error types to flow API 2018-04-25 15:27 ` [dpdk-dev] [PATCH v6 00/16] Flow API overhaul for switch offloads Adrien Mazarguil @ 2018-04-25 15:27 ` Adrien Mazarguil 2018-04-25 15:27 ` [dpdk-dev] [PATCH v6 02/16] ethdev: clarify flow API pattern items and actions Adrien Mazarguil ` (15 subsequent siblings) 16 siblings, 0 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-25 15:27 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev These enable more precise reporting of objects responsible for errors. This breaks ABI compatibility for the following public functions: - rte_flow_create() - rte_flow_destroy() - rte_flow_error_set() - rte_flow_flush() - rte_flow_isolate() - rte_flow_query() - rte_flow_validate() Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Acked-by: Andrew Rybchenko <arybchenko@solarflare.com> --- v6 changes: Updated ABI changes section in release notes. --- app/test-pmd/config.c | 4 ++++ doc/guides/rel_notes/release_18_05.rst | 7 +++++++ lib/librte_ether/rte_ethdev_version.map | 14 +++++++------- lib/librte_ether/rte_flow.h | 4 ++++ 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 216a7eb4e..b275d759d 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -1261,8 +1261,12 @@ port_flow_complain(struct rte_flow_error *error) [RTE_FLOW_ERROR_TYPE_ATTR_EGRESS] = "egress field", [RTE_FLOW_ERROR_TYPE_ATTR] = "attributes structure", [RTE_FLOW_ERROR_TYPE_ITEM_NUM] = "pattern length", + [RTE_FLOW_ERROR_TYPE_ITEM_SPEC] = "item specification", + [RTE_FLOW_ERROR_TYPE_ITEM_LAST] = "item specification range", + [RTE_FLOW_ERROR_TYPE_ITEM_MASK] = "item specification mask", [RTE_FLOW_ERROR_TYPE_ITEM] = "specific pattern item", [RTE_FLOW_ERROR_TYPE_ACTION_NUM] = "number of actions", + [RTE_FLOW_ERROR_TYPE_ACTION_CONF] = "action configuration", [RTE_FLOW_ERROR_TYPE_ACTION] = "specific action", }; const char *errstr; diff --git a/doc/guides/rel_notes/release_18_05.rst b/doc/guides/rel_notes/release_18_05.rst index 752a2c308..e50caa74a 100644 --- a/doc/guides/rel_notes/release_18_05.rst +++ b/doc/guides/rel_notes/release_18_05.rst @@ -283,6 +283,13 @@ ABI Changes type ``uint16_t``: ``burst_size``, ``ring_size``, and ``nb_queues``. These are parameter values recommended for use by the PMD. +* ethdev: ABI for most flow API functions was updated. + + This includes functions ``rte_flow_create``, ``rte_flow_destroy``, + ``rte_flow_error_set``, ``rte_flow_flush``, ``rte_flow_isolate``, + ``rte_flow_query`` and ``rte_flow_validate``, due to changes in error type + definitions (``enum rte_flow_error_type``). + Removed Items ------------- diff --git a/lib/librte_ether/rte_ethdev_version.map b/lib/librte_ether/rte_ethdev_version.map index 02713e430..180d2ca2d 100644 --- a/lib/librte_ether/rte_ethdev_version.map +++ b/lib/librte_ether/rte_ethdev_version.map @@ -127,11 +127,6 @@ DPDK_17.02 { _rte_eth_dev_reset; rte_eth_dev_fw_version_get; - rte_flow_create; - rte_flow_destroy; - rte_flow_flush; - rte_flow_query; - rte_flow_validate; } DPDK_16.07; @@ -153,7 +148,6 @@ DPDK_17.08 { _rte_eth_dev_callback_process; rte_eth_dev_adjust_nb_rx_tx_desc; rte_flow_copy; - rte_flow_isolate; rte_tm_capabilities_get; rte_tm_hierarchy_commit; rte_tm_level_capabilities_get; @@ -192,7 +186,6 @@ DPDK_17.11 { rte_eth_dev_get_sec_ctx; rte_eth_dev_pool_ops_supported; rte_eth_dev_reset; - rte_flow_error_set; } DPDK_17.08; @@ -208,6 +201,13 @@ DPDK_18.05 { rte_eth_dev_count_avail; rte_eth_find_next_owned_by; + rte_flow_create; + rte_flow_destroy; + rte_flow_error_set; + rte_flow_flush; + rte_flow_isolate; + rte_flow_query; + rte_flow_validate; } DPDK_18.02; diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index 44ae19d3b..26b95c772 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -1186,8 +1186,12 @@ enum rte_flow_error_type { RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, /**< Egress field. */ RTE_FLOW_ERROR_TYPE_ATTR, /**< Attributes structure. */ RTE_FLOW_ERROR_TYPE_ITEM_NUM, /**< Pattern length. */ + RTE_FLOW_ERROR_TYPE_ITEM_SPEC, /**< Item specification. */ + RTE_FLOW_ERROR_TYPE_ITEM_LAST, /**< Item specification range. */ + RTE_FLOW_ERROR_TYPE_ITEM_MASK, /**< Item specification mask. */ RTE_FLOW_ERROR_TYPE_ITEM, /**< Specific pattern item. */ RTE_FLOW_ERROR_TYPE_ACTION_NUM, /**< Number of actions. */ + RTE_FLOW_ERROR_TYPE_ACTION_CONF, /**< Action configuration. */ RTE_FLOW_ERROR_TYPE_ACTION, /**< Specific action. */ }; -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v6 02/16] ethdev: clarify flow API pattern items and actions 2018-04-25 15:27 ` [dpdk-dev] [PATCH v6 00/16] Flow API overhaul for switch offloads Adrien Mazarguil 2018-04-25 15:27 ` [dpdk-dev] [PATCH v6 01/16] ethdev: add error types to flow API Adrien Mazarguil @ 2018-04-25 15:27 ` Adrien Mazarguil 2018-04-25 15:27 ` [dpdk-dev] [PATCH v6 03/16] doc: remove flow API migration section Adrien Mazarguil ` (14 subsequent siblings) 16 siblings, 0 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-25 15:27 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev Although pattern items and actions examples end with "and so on", these lists include all existing definitions and as a result are updated almost every time new types are added. This is cumbersome and pointless. This patch also synchronizes Doxygen and external API documentation wording with a slight clarification regarding meta pattern items. No fundamental API change. Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Acked-by: Andrew Rybchenko <arybchenko@solarflare.com> --- doc/guides/prog_guide/rte_flow.rst | 23 +++++++++++------------ lib/librte_ether/rte_flow.h | 23 ++++++++++------------- 2 files changed, 21 insertions(+), 25 deletions(-) diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 961943dda..a11ebd617 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -186,12 +186,13 @@ Pattern item Pattern items fall in two categories: -- Matching protocol headers and packet data (ANY, RAW, ETH, VLAN, IPV4, - IPV6, ICMP, UDP, TCP, SCTP, VXLAN, MPLS, GRE, ESP and so on), usually - associated with a specification structure. +- Matching protocol headers and packet data, usually associated with a + specification structure. These must be stacked in the same order as the + protocol layers to match inside packets, starting from the lowest. -- Matching meta-data or affecting pattern processing (END, VOID, INVERT, PF, - VF, PORT and so on), often without a specification structure. +- Matching meta-data or affecting pattern processing, often without a + specification structure. Since they do not match packet contents, their + position in the list is usually not relevant. Item specification structures are used to match specific values among protocol fields (or item properties). Documentation describes for each item @@ -1001,15 +1002,13 @@ to a flow rule. That list is not ordered. They fall in three categories: -- Terminating actions (such as QUEUE, DROP, RSS, PF, VF) that prevent - processing matched packets by subsequent flow rules, unless overridden - with PASSTHRU. +- Terminating actions that prevent processing matched packets by subsequent + flow rules, unless overridden with PASSTHRU. -- Non-terminating actions (PASSTHRU, DUP) that leave matched packets up for - additional processing by subsequent flow rules. +- Non-terminating actions that leave matched packets up for additional + processing by subsequent flow rules. -- Other non-terminating meta actions that do not affect the fate of packets - (END, VOID, MARK, FLAG, COUNT, SECURITY). +- Other non-terminating meta actions that do not affect the fate of packets. When several actions are combined in a flow rule, they should all have different types (e.g. dropping a packet twice is not possible). diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index 26b95c772..d28a2a473 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -78,15 +78,13 @@ struct rte_flow_attr { * * Pattern items fall in two categories: * - * - Matching protocol headers and packet data (ANY, RAW, ETH, VLAN, IPV4, - * IPV6, ICMP, UDP, TCP, SCTP, VXLAN and so on), usually associated with a + * - Matching protocol headers and packet data, usually associated with a * specification structure. These must be stacked in the same order as the - * protocol layers to match, starting from the lowest. + * protocol layers to match inside packets, starting from the lowest. * - * - Matching meta-data or affecting pattern processing (END, VOID, INVERT, - * PF, VF, PORT and so on), often without a specification structure. Since - * they do not match packet contents, these can be specified anywhere - * within item lists without affecting others. + * - Matching meta-data or affecting pattern processing, often without a + * specification structure. Since they do not match packet contents, their + * position in the list is usually not relevant. * * See the description of individual types for more information. Those * marked with [META] fall into the second category. @@ -865,15 +863,14 @@ struct rte_flow_item { * * They fall in three categories: * - * - Terminating actions (such as QUEUE, DROP, RSS, PF, VF) that prevent - * processing matched packets by subsequent flow rules, unless overridden - * with PASSTHRU. + * - Terminating actions that prevent processing matched packets by + * subsequent flow rules, unless overridden with PASSTHRU. * - * - Non terminating actions (PASSTHRU, DUP) that leave matched packets up - * for additional processing by subsequent flow rules. + * - Non terminating actions that leave matched packets up for additional + * processing by subsequent flow rules. * * - Other non terminating meta actions that do not affect the fate of - * packets (END, VOID, MARK, FLAG, COUNT). + * packets. * * When several actions are combined in a flow rule, they should all have * different types (e.g. dropping a packet twice is not possible). -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v6 03/16] doc: remove flow API migration section 2018-04-25 15:27 ` [dpdk-dev] [PATCH v6 00/16] Flow API overhaul for switch offloads Adrien Mazarguil 2018-04-25 15:27 ` [dpdk-dev] [PATCH v6 01/16] ethdev: add error types to flow API Adrien Mazarguil 2018-04-25 15:27 ` [dpdk-dev] [PATCH v6 02/16] ethdev: clarify flow API pattern items and actions Adrien Mazarguil @ 2018-04-25 15:27 ` Adrien Mazarguil 2018-04-25 15:27 ` [dpdk-dev] [PATCH v6 04/16] ethdev: remove DUP action from flow API Adrien Mazarguil ` (13 subsequent siblings) 16 siblings, 0 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-25 15:27 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev This section has become less relevant since the flow API (rte_flow) is now a mature DPDK API with applications developed directly on top of it instead of an afterthought. This patch removes it for the following reasons: - It has never been updated to track the latest changes in the legacy filter types and never will. - Many provided examples are theoretical and misleading since PMDs do not implement them. Others are obvious. - Upcoming work on the flow API will alter the behavior of several pattern items, actions and in some cases, flow rules, which will in turn cause existing examples to be wrong. Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Acked-by: Andrew Rybchenko <arybchenko@solarflare.com> --- doc/guides/prog_guide/rte_flow.rst | 298 -------------------------------- 1 file changed, 298 deletions(-) diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index a11ebd617..51826d04c 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -55,9 +55,6 @@ encompasses and supersedes (including all functions and filter types) in order to expose a single interface with an unambiguous behavior that is common to all poll-mode drivers (PMDs). -Several methods to migrate existing applications are described in `API -migration`_. - Flow rule --------- @@ -2068,298 +2065,3 @@ Future evolutions - Optional software fallback when PMDs are unable to handle requested flow rules so applications do not have to implement their own. - -API migration -------------- - -Exhaustive list of deprecated filter types (normally prefixed with -*RTE_ETH_FILTER_*) found in ``rte_eth_ctrl.h`` and methods to convert them -to *rte_flow* rules. - -``MACVLAN`` to ``ETH`` → ``VF``, ``PF`` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -*MACVLAN* can be translated to a basic `Item: ETH`_ flow rule with a -terminating `Action: VF`_ or `Action: PF`_. - -.. _table_rte_flow_migration_macvlan: - -.. table:: MACVLAN conversion - - +--------------------------+---------+ - | Pattern | Actions | - +===+=====+==========+=====+=========+ - | 0 | ETH | ``spec`` | any | VF, | - | | +----------+-----+ PF | - | | | ``last`` | N/A | | - | | +----------+-----+ | - | | | ``mask`` | any | | - +---+-----+----------+-----+---------+ - | 1 | END | END | - +---+----------------------+---------+ - -``ETHERTYPE`` to ``ETH`` → ``QUEUE``, ``DROP`` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -*ETHERTYPE* is basically an `Item: ETH`_ flow rule with a terminating -`Action: QUEUE`_ or `Action: DROP`_. - -.. _table_rte_flow_migration_ethertype: - -.. table:: ETHERTYPE conversion - - +--------------------------+---------+ - | Pattern | Actions | - +===+=====+==========+=====+=========+ - | 0 | ETH | ``spec`` | any | QUEUE, | - | | +----------+-----+ DROP | - | | | ``last`` | N/A | | - | | +----------+-----+ | - | | | ``mask`` | any | | - +---+-----+----------+-----+---------+ - | 1 | END | END | - +---+----------------------+---------+ - -``FLEXIBLE`` to ``RAW`` → ``QUEUE`` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -*FLEXIBLE* can be translated to one `Item: RAW`_ pattern with a terminating -`Action: QUEUE`_ and a defined priority level. - -.. _table_rte_flow_migration_flexible: - -.. table:: FLEXIBLE conversion - - +--------------------------+---------+ - | Pattern | Actions | - +===+=====+==========+=====+=========+ - | 0 | RAW | ``spec`` | any | QUEUE | - | | +----------+-----+ | - | | | ``last`` | N/A | | - | | +----------+-----+ | - | | | ``mask`` | any | | - +---+-----+----------+-----+---------+ - | 1 | END | END | - +---+----------------------+---------+ - -``SYN`` to ``TCP`` → ``QUEUE`` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -*SYN* is a `Item: TCP`_ rule with only the ``syn`` bit enabled and masked, -and a terminating `Action: QUEUE`_. - -Priority level can be set to simulate the high priority bit. - -.. _table_rte_flow_migration_syn: - -.. table:: SYN conversion - - +-----------------------------------+---------+ - | Pattern | Actions | - +===+======+==========+=============+=========+ - | 0 | ETH | ``spec`` | unset | QUEUE | - | | +----------+-------------+ | - | | | ``last`` | unset | | - | | +----------+-------------+ | - | | | ``mask`` | unset | | - +---+------+----------+-------------+---------+ - | 1 | IPV4 | ``spec`` | unset | END | - | | +----------+-------------+ | - | | | ``mask`` | unset | | - | | +----------+-------------+ | - | | | ``mask`` | unset | | - +---+------+----------+---------+---+ | - | 2 | TCP | ``spec`` | ``syn`` | 1 | | - | | +----------+---------+---+ | - | | | ``mask`` | ``syn`` | 1 | | - +---+------+----------+---------+---+ | - | 3 | END | | - +---+-------------------------------+---------+ - -``NTUPLE`` to ``IPV4``, ``TCP``, ``UDP`` → ``QUEUE`` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -*NTUPLE* is similar to specifying an empty L2, `Item: IPV4`_ as L3 with -`Item: TCP`_ or `Item: UDP`_ as L4 and a terminating `Action: QUEUE`_. - -A priority level can be specified as well. - -.. _table_rte_flow_migration_ntuple: - -.. table:: NTUPLE conversion - - +-----------------------------+---------+ - | Pattern | Actions | - +===+======+==========+=======+=========+ - | 0 | ETH | ``spec`` | unset | QUEUE | - | | +----------+-------+ | - | | | ``last`` | unset | | - | | +----------+-------+ | - | | | ``mask`` | unset | | - +---+------+----------+-------+---------+ - | 1 | IPV4 | ``spec`` | any | END | - | | +----------+-------+ | - | | | ``last`` | unset | | - | | +----------+-------+ | - | | | ``mask`` | any | | - +---+------+----------+-------+ | - | 2 | TCP, | ``spec`` | any | | - | | UDP +----------+-------+ | - | | | ``last`` | unset | | - | | +----------+-------+ | - | | | ``mask`` | any | | - +---+------+----------+-------+ | - | 3 | END | | - +---+-------------------------+---------+ - -``TUNNEL`` to ``ETH``, ``IPV4``, ``IPV6``, ``VXLAN`` (or other) → ``QUEUE`` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -*TUNNEL* matches common IPv4 and IPv6 L3/L4-based tunnel types. - -In the following table, `Item: ANY`_ is used to cover the optional L4. - -.. _table_rte_flow_migration_tunnel: - -.. table:: TUNNEL conversion - - +-------------------------------------------------------+---------+ - | Pattern | Actions | - +===+==========================+==========+=============+=========+ - | 0 | ETH | ``spec`` | any | QUEUE | - | | +----------+-------------+ | - | | | ``last`` | unset | | - | | +----------+-------------+ | - | | | ``mask`` | any | | - +---+--------------------------+----------+-------------+---------+ - | 1 | IPV4, IPV6 | ``spec`` | any | END | - | | +----------+-------------+ | - | | | ``last`` | unset | | - | | +----------+-------------+ | - | | | ``mask`` | any | | - +---+--------------------------+----------+-------------+ | - | 2 | ANY | ``spec`` | any | | - | | +----------+-------------+ | - | | | ``last`` | unset | | - | | +----------+---------+---+ | - | | | ``mask`` | ``num`` | 0 | | - +---+--------------------------+----------+---------+---+ | - | 3 | VXLAN, GENEVE, TEREDO, | ``spec`` | any | | - | | NVGRE, GRE, ... +----------+-------------+ | - | | | ``last`` | unset | | - | | +----------+-------------+ | - | | | ``mask`` | any | | - +---+--------------------------+----------+-------------+ | - | 4 | END | | - +---+---------------------------------------------------+---------+ - -``FDIR`` to most item types → ``QUEUE``, ``DROP``, ``PASSTHRU`` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -*FDIR* is more complex than any other type, there are several methods to -emulate its functionality. It is summarized for the most part in the table -below. - -A few features are intentionally not supported: - -- The ability to configure the matching input set and masks for the entire - device, PMDs should take care of it automatically according to the - requested flow rules. - - For example if a device supports only one bit-mask per protocol type, - source/address IPv4 bit-masks can be made immutable by the first created - rule. Subsequent IPv4 or TCPv4 rules can only be created if they are - compatible. - - Note that only protocol bit-masks affected by existing flow rules are - immutable, others can be changed later. They become mutable again after - the related flow rules are destroyed. - -- Returning four or eight bytes of matched data when using flex bytes - filtering. Although a specific action could implement it, it conflicts - with the much more useful 32 bits tagging on devices that support it. - -- Side effects on RSS processing of the entire device. Flow rules that - conflict with the current device configuration should not be - allowed. Similarly, device configuration should not be allowed when it - affects existing flow rules. - -- Device modes of operation. "none" is unsupported since filtering cannot be - disabled as long as a flow rule is present. - -- "MAC VLAN" or "tunnel" perfect matching modes should be automatically set - according to the created flow rules. - -- Signature mode of operation is not defined but could be handled through - "FUZZY" item. - -.. _table_rte_flow_migration_fdir: - -.. table:: FDIR conversion - - +----------------------------------------+-----------------------+ - | Pattern | Actions | - +===+===================+==========+=====+=======================+ - | 0 | ETH, RAW | ``spec`` | any | QUEUE, DROP, PASSTHRU | - | | +----------+-----+ | - | | | ``last`` | N/A | | - | | +----------+-----+ | - | | | ``mask`` | any | | - +---+-------------------+----------+-----+-----------------------+ - | 1 | IPV4, IPv6 | ``spec`` | any | MARK | - | | +----------+-----+ | - | | | ``last`` | N/A | | - | | +----------+-----+ | - | | | ``mask`` | any | | - +---+-------------------+----------+-----+-----------------------+ - | 2 | TCP, UDP, SCTP | ``spec`` | any | END | - | | +----------+-----+ | - | | | ``last`` | N/A | | - | | +----------+-----+ | - | | | ``mask`` | any | | - +---+-------------------+----------+-----+ | - | 3 | VF, PF, FUZZY | ``spec`` | any | | - | | (optional) +----------+-----+ | - | | | ``last`` | N/A | | - | | +----------+-----+ | - | | | ``mask`` | any | | - +---+-------------------+----------+-----+ | - | 4 | END | | - +---+------------------------------------+-----------------------+ - -``HASH`` -~~~~~~~~ - -There is no counterpart to this filter type because it translates to a -global device setting instead of a pattern item. Device settings are -automatically set according to the created flow rules. - -``L2_TUNNEL`` to ``VOID`` → ``VXLAN`` (or others) -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -All packets are matched. This type alters incoming packets to encapsulate -them in a chosen tunnel type, optionally redirect them to a VF as well. - -The destination pool for tag based forwarding can be emulated with other -flow rules using `Action: DUP`_. - -.. _table_rte_flow_migration_l2tunnel: - -.. table:: L2_TUNNEL conversion - - +---------------------------+--------------------+ - | Pattern | Actions | - +===+======+==========+=====+====================+ - | 0 | VOID | ``spec`` | N/A | VXLAN, GENEVE, ... | - | | | | | | - | | | | | | - | | +----------+-----+ | - | | | ``last`` | N/A | | - | | +----------+-----+ | - | | | ``mask`` | N/A | | - | | | | | | - +---+------+----------+-----+--------------------+ - | 1 | END | VF (optional) | - +---+ +--------------------+ - | 2 | | END | - +---+-----------------------+--------------------+ -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v6 04/16] ethdev: remove DUP action from flow API 2018-04-25 15:27 ` [dpdk-dev] [PATCH v6 00/16] Flow API overhaul for switch offloads Adrien Mazarguil ` (2 preceding siblings ...) 2018-04-25 15:27 ` [dpdk-dev] [PATCH v6 03/16] doc: remove flow API migration section Adrien Mazarguil @ 2018-04-25 15:27 ` Adrien Mazarguil 2018-04-25 15:27 ` [dpdk-dev] [PATCH v6 05/16] ethdev: alter behavior of flow API actions Adrien Mazarguil ` (12 subsequent siblings) 16 siblings, 0 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-25 15:27 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev Upcoming changes in relation to the handling of actions list will make the DUP action redundant as specifying several QUEUE actions will achieve the same behavior. Besides, no PMD implements this action. By removing an entry from enum rte_flow_action_type, this patch breaks ABI compatibility for the following public functions: - rte_flow_copy() - rte_flow_create() - rte_flow_query() - rte_flow_validate() Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Acked-by: Andrew Rybchenko <arybchenko@solarflare.com> --- v6 changes: Updated API and ABI changes sections in release notes. --- app/test-pmd/cmdline_flow.c | 23 ----------------------- app/test-pmd/config.c | 1 - doc/guides/prog_guide/rte_flow.rst | 23 ----------------------- doc/guides/rel_notes/release_18_05.rst | 13 ++++++++----- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 8 -------- lib/librte_ether/rte_ethdev_version.map | 2 +- lib/librte_ether/rte_flow.c | 1 - lib/librte_ether/rte_flow.h | 24 ------------------------ 8 files changed, 9 insertions(+), 86 deletions(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index f0b4b7bc4..2ddb08feb 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -164,8 +164,6 @@ enum index { ACTION_QUEUE_INDEX, ACTION_DROP, ACTION_COUNT, - ACTION_DUP, - ACTION_DUP_INDEX, ACTION_RSS, ACTION_RSS_TYPES, ACTION_RSS_TYPE, @@ -625,7 +623,6 @@ static const enum index next_action[] = { ACTION_QUEUE, ACTION_DROP, ACTION_COUNT, - ACTION_DUP, ACTION_RSS, ACTION_PF, ACTION_VF, @@ -645,12 +642,6 @@ static const enum index action_queue[] = { ZERO, }; -static const enum index action_dup[] = { - ACTION_DUP_INDEX, - ACTION_NEXT, - ZERO, -}; - static const enum index action_rss[] = { ACTION_RSS_TYPES, ACTION_RSS_KEY, @@ -1597,20 +1588,6 @@ static const struct token token_list[] = { .next = NEXT(NEXT_ENTRY(ACTION_NEXT)), .call = parse_vc, }, - [ACTION_DUP] = { - .name = "dup", - .help = "duplicate packets to a given queue index", - .priv = PRIV_ACTION(DUP, sizeof(struct rte_flow_action_dup)), - .next = NEXT(action_dup), - .call = parse_vc, - }, - [ACTION_DUP_INDEX] = { - .name = "index", - .help = "queue index to duplicate packets to", - .next = NEXT(action_dup, NEXT_ENTRY(UNSIGNED)), - .args = ARGS(ARGS_ENTRY(struct rte_flow_action_dup, index)), - .call = parse_vc_conf, - }, [ACTION_RSS] = { .name = "rss", .help = "spread packets among several queues", diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index b275d759d..9729177f8 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -1082,7 +1082,6 @@ static const struct { MK_FLOW_ACTION(QUEUE, sizeof(struct rte_flow_action_queue)), MK_FLOW_ACTION(DROP, 0), MK_FLOW_ACTION(COUNT, 0), - MK_FLOW_ACTION(DUP, sizeof(struct rte_flow_action_dup)), MK_FLOW_ACTION(RSS, sizeof(struct rte_flow_action_rss)), /* +queue[] */ MK_FLOW_ACTION(PF, 0), MK_FLOW_ACTION(VF, sizeof(struct rte_flow_action_vf)), diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 51826d04c..a237e4fd2 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -1299,26 +1299,6 @@ Query structure to retrieve and reset flow rule counters: | ``bytes`` | out | number of bytes through this rule | +---------------+-----+-----------------------------------+ -Action: ``DUP`` -^^^^^^^^^^^^^^^ - -Duplicates packets to a given queue index. - -This is normally combined with QUEUE, however when used alone, it is -actually similar to QUEUE + PASSTHRU. - -- Non-terminating by default. - -.. _table_rte_flow_action_dup: - -.. table:: DUP - - +-----------+------------------------------------+ - | Field | Value | - +===========+====================================+ - | ``index`` | queue index to duplicate packet to | - +-----------+------------------------------------+ - Action: ``RSS`` ^^^^^^^^^^^^^^^ @@ -2010,9 +1990,6 @@ Unsupported actions and tagging (`Action: MARK`_ or `Action: FLAG`_) may be implemented in software as long as the target queue is used by a single rule. -- A rule specifying both `Action: DUP`_ + `Action: QUEUE`_ may be translated - to two hidden rules combining `Action: QUEUE`_ and `Action: PASSTHRU`_. - - When a single target queue is provided, `Action: RSS`_ can also be implemented through `Action: QUEUE`_. diff --git a/doc/guides/rel_notes/release_18_05.rst b/doc/guides/rel_notes/release_18_05.rst index e50caa74a..d3b619216 100644 --- a/doc/guides/rel_notes/release_18_05.rst +++ b/doc/guides/rel_notes/release_18_05.rst @@ -243,6 +243,8 @@ API Changes fall-back value. Previously, setting ``nb_tx_desc`` to zero would have resulted in an error. +* ethdev: unused DUP action was removed from the flow API. + ABI Changes ----------- @@ -283,12 +285,13 @@ ABI Changes type ``uint16_t``: ``burst_size``, ``ring_size``, and ``nb_queues``. These are parameter values recommended for use by the PMD. -* ethdev: ABI for most flow API functions was updated. +* ethdev: ABI for all flow API functions was updated. - This includes functions ``rte_flow_create``, ``rte_flow_destroy``, - ``rte_flow_error_set``, ``rte_flow_flush``, ``rte_flow_isolate``, - ``rte_flow_query`` and ``rte_flow_validate``, due to changes in error type - definitions (``enum rte_flow_error_type``). + This includes functions ``rte_flow_copy``, ``rte_flow_create``, + ``rte_flow_destroy``, ``rte_flow_error_set``, ``rte_flow_flush``, + ``rte_flow_isolate``, ``rte_flow_query`` and ``rte_flow_validate``, due to + changes in error type definitions (``enum rte_flow_error_type``) and + removal of the unused DUP action (``enum rte_flow_action_type``). Removed Items diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index 06caea3f5..68c286bd4 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3387,10 +3387,6 @@ actions can sometimes be combined when the end result is unambiguous:: :: - drop / dup index 6 / end # same as above - -:: - queue index 6 / rss queues 6 7 8 / end # queue has no effect :: @@ -3424,10 +3420,6 @@ This section lists supported actions and their attributes, if any. - ``count``: enable counters for this rule. -- ``dup``: duplicate packets to a given queue index. - - - ``index {unsigned}``: queue index to duplicate packets to. - - ``rss``: spread packets among several queues. - ``types [{RSS hash type} [...]] end``: RSS hash types, allowed tokens diff --git a/lib/librte_ether/rte_ethdev_version.map b/lib/librte_ether/rte_ethdev_version.map index 180d2ca2d..29ca68eb7 100644 --- a/lib/librte_ether/rte_ethdev_version.map +++ b/lib/librte_ether/rte_ethdev_version.map @@ -147,7 +147,6 @@ DPDK_17.08 { _rte_eth_dev_callback_process; rte_eth_dev_adjust_nb_rx_tx_desc; - rte_flow_copy; rte_tm_capabilities_get; rte_tm_hierarchy_commit; rte_tm_level_capabilities_get; @@ -201,6 +200,7 @@ DPDK_18.05 { rte_eth_dev_count_avail; rte_eth_find_next_owned_by; + rte_flow_copy; rte_flow_create; rte_flow_destroy; rte_flow_error_set; diff --git a/lib/librte_ether/rte_flow.c b/lib/librte_ether/rte_flow.c index ada280810..80f9cb6cb 100644 --- a/lib/librte_ether/rte_flow.c +++ b/lib/librte_ether/rte_flow.c @@ -73,7 +73,6 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = { MK_FLOW_ACTION(QUEUE, sizeof(struct rte_flow_action_queue)), MK_FLOW_ACTION(DROP, 0), MK_FLOW_ACTION(COUNT, 0), - MK_FLOW_ACTION(DUP, sizeof(struct rte_flow_action_dup)), MK_FLOW_ACTION(RSS, sizeof(struct rte_flow_action_rss)), /* +queue[] */ MK_FLOW_ACTION(PF, 0), MK_FLOW_ACTION(VF, sizeof(struct rte_flow_action_vf)), diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index d28a2a473..6ace24ff4 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -961,16 +961,6 @@ enum rte_flow_action_type { RTE_FLOW_ACTION_TYPE_COUNT, /** - * Duplicates packets to a given queue index. - * - * This is normally combined with QUEUE, however when used alone, it - * is actually similar to QUEUE + PASSTHRU. - * - * See struct rte_flow_action_dup. - */ - RTE_FLOW_ACTION_TYPE_DUP, - - /** * Similar to QUEUE, except RSS is additionally performed on packets * to spread them among several queues according to the provided * parameters. @@ -1052,20 +1042,6 @@ struct rte_flow_query_count { }; /** - * RTE_FLOW_ACTION_TYPE_DUP - * - * Duplicates packets to a given queue index. - * - * This is normally combined with QUEUE, however when used alone, it is - * actually similar to QUEUE + PASSTHRU. - * - * Non-terminating by default. - */ -struct rte_flow_action_dup { - uint16_t index; /**< Queue index to duplicate packets to. */ -}; - -/** * RTE_FLOW_ACTION_TYPE_RSS * * Similar to QUEUE, except RSS is additionally performed on packets to -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v6 05/16] ethdev: alter behavior of flow API actions 2018-04-25 15:27 ` [dpdk-dev] [PATCH v6 00/16] Flow API overhaul for switch offloads Adrien Mazarguil ` (3 preceding siblings ...) 2018-04-25 15:27 ` [dpdk-dev] [PATCH v6 04/16] ethdev: remove DUP action from flow API Adrien Mazarguil @ 2018-04-25 15:27 ` Adrien Mazarguil 2018-04-25 15:27 ` [dpdk-dev] [PATCH v6 06/16] ethdev: fix C99 flexible arrays from flow API Adrien Mazarguil ` (11 subsequent siblings) 16 siblings, 0 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-25 15:27 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev Cc: Ajit Khaparde, Wenzhuo Lu, John Daley, Gaetan Rivet, Beilei Xing, Konstantin Ananyev, Nelio Laranjeiro, Andrew Rybchenko, Pascal Mazon This patch makes the following changes to flow rule actions: - List order now matters, they are redefined as performed first to last instead of "all simultaneously". - Repeated actions are now supported (e.g. specifying QUEUE multiple times now duplicates traffic among them). Previously only the last action of any given kind was taken into account. - No more distinction between terminating/non-terminating/meta actions. Flow rules themselves are now defined as always terminating unless a PASSTHRU action is specified. These changes alter the behavior of flow rules in corner cases in order to prepare the flow API for actions that modify traffic contents or properties (e.g. encapsulation, compression) and for which order matter when combined. Previously one would have to do so through multiple flow rules by combining PASSTRHU with priority levels, however this proved overly complex to implement at the PMD level, hence this simpler approach. This breaks ABI compatibility for the following public functions: - rte_flow_create() - rte_flow_validate() PMDs with rte_flow support are modified accordingly: - bnxt: no change, implementation already forbids multiple actions and does not support PASSTHRU. - e1000: no change, same as bnxt. - enic: modified to forbid redundant actions, no support for default drop. - failsafe: no change needed. - i40e: no change, implementation already forbids multiple actions. - ixgbe: same as i40e. - mlx4: modified to forbid multiple fate-deciding actions and drop when unspecified. - mlx5: same as mlx4, with other redundant actions also forbidden. - sfc: same as mlx4. - tap: implementation already complies with the new behavior except for the default pass-through modified as a default drop. Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Reviewed-by: Andrew Rybchenko <arybchenko@oktetlabs.ru> Cc: Ajit Khaparde <ajit.khaparde@broadcom.com> Cc: Wenzhuo Lu <wenzhuo.lu@intel.com> Cc: John Daley <johndale@cisco.com> Cc: Gaetan Rivet <gaetan.rivet@6wind.com> Cc: Beilei Xing <beilei.xing@intel.com> Cc: Konstantin Ananyev <konstantin.ananyev@intel.com> Cc: Nelio Laranjeiro <nelio.laranjeiro@6wind.com> Cc: Andrew Rybchenko <arybchenko@solarflare.com> Cc: Pascal Mazon <pascal.mazon@6wind.com> -- v6 changes: Updated API and ABI changes sections in release notes. v5 changes: Fixed issues raised by GCC and Clang with overlap checks in both enic and mlx5, as reported by Andrew [1]. [1] http://dpdk.org/ml/archives/dev/2018-April/097864.html --- doc/guides/prog_guide/rte_flow.rst | 67 +++++++++++----------------- doc/guides/rel_notes/release_18_05.rst | 15 +++++-- drivers/net/enic/enic_flow.c | 25 +++++++++++ drivers/net/mlx4/mlx4_flow.c | 21 ++++++--- drivers/net/mlx5/mlx5_flow.c | 69 +++++++++++++---------------- drivers/net/sfc/sfc_flow.c | 22 ++++++--- drivers/net/tap/tap_flow.c | 11 +++++ lib/librte_ether/rte_flow.h | 54 +++++++--------------- 8 files changed, 150 insertions(+), 134 deletions(-) diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index a237e4fd2..80360d068 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -995,28 +995,27 @@ Actions Each possible action is represented by a type. Some have associated configuration structures. Several actions combined in a list can be assigned -to a flow rule. That list is not ordered. +to a flow rule and are performed in order. They fall in three categories: -- Terminating actions that prevent processing matched packets by subsequent - flow rules, unless overridden with PASSTHRU. +- Actions that modify the fate of matching traffic, for instance by dropping + or assigning it a specific destination. -- Non-terminating actions that leave matched packets up for additional - processing by subsequent flow rules. +- Actions that modify matching traffic contents or its properties. This + includes adding/removing encapsulation, encryption, compression and marks. -- Other non-terminating meta actions that do not affect the fate of packets. +- Actions related to the flow rule itself, such as updating counters or + making it non-terminating. -When several actions are combined in a flow rule, they should all have -different types (e.g. dropping a packet twice is not possible). +Flow rules being terminating by default, not specifying any action of the +fate kind results in undefined behavior. This applies to both ingress and +egress. -Only the last action of a given type is taken into account. PMDs still -perform error checking on the entire list. +PASSTHRU, when supported, makes a flow rule non-terminating. Like matching patterns, action lists are terminated by END items. -*Note that PASSTHRU is the only action able to override a terminating rule.* - Example of action that redirects packets to queue index 10: .. _table_rte_flow_action_example: @@ -1029,12 +1028,11 @@ Example of action that redirects packets to queue index 10: | ``index`` | 10 | +-----------+-------+ -Action lists examples, their order is not significant, applications must -consider all actions to be performed simultaneously: +Actions are performed in list order: -.. _table_rte_flow_count_and_drop: +.. _table_rte_flow_count_then_drop: -.. table:: Count and drop +.. table:: Count then drop +-------+--------+ | Index | Action | @@ -1050,7 +1048,7 @@ consider all actions to be performed simultaneously: .. _table_rte_flow_mark_count_redirect: -.. table:: Mark, count and redirect +.. table:: Mark, count then redirect +-------+--------+-----------+-------+ | Index | Action | Field | Value | @@ -1080,12 +1078,15 @@ consider all actions to be performed simultaneously: | 2 | END | +-------+----------------------------+ -In the above example, considering both actions are performed simultaneously, -the end result is that only QUEUE has any effect. +In the above example, while DROP and QUEUE must be performed in order, both +have to happen before reaching END. Only QUEUE has a visible effect. + +Note that such a list may be thought as ambiguous and rejected on that +basis. -.. _table_rte_flow_redirect_queue_3: +.. _table_rte_flow_redirect_queue_5_3: -.. table:: Redirect to queue 3 +.. table:: Redirect to queues 5 and 3 +-------+--------+-----------+-------+ | Index | Action | Field | Value | @@ -1099,9 +1100,9 @@ the end result is that only QUEUE has any effect. | 3 | END | +-------+----------------------------+ -As previously described, only the last action of a given type found in the -list is taken into account. The above example also shows that VOID is -ignored. +As previously described, all actions must be taken into account. This +effectively duplicates traffic to both queues. The above example also shows +that VOID is ignored. Action types ~~~~~~~~~~~~ @@ -1151,9 +1152,8 @@ PMDs. Action: ``PASSTHRU`` ^^^^^^^^^^^^^^^^^^^^ -Leaves packets up for additional processing by subsequent flow rules. This -is the default when a rule does not contain a terminating action, but can be -specified to force a rule to become non-terminating. +Leaves traffic up for additional processing by subsequent flow rules; makes +a flow rule non-terminating. - No configurable properties. @@ -1227,8 +1227,6 @@ Action: ``QUEUE`` Assigns packets to a given queue index. -- Terminating by default. - .. _table_rte_flow_action_queue: .. table:: QUEUE @@ -1245,8 +1243,6 @@ Action: ``DROP`` Drop packets. - No configurable properties. -- Terminating by default. -- PASSTHRU overrides this action if both are specified. .. _table_rte_flow_action_drop: @@ -1309,8 +1305,6 @@ Note: RSS hash result is stored in the ``hash.rss`` mbuf field which overlaps ``hash.fdir.lo``. Since `Action: MARK`_ sets the ``hash.fdir.hi`` field only, both can be requested simultaneously. -- Terminating by default. - .. _table_rte_flow_action_rss: .. table:: RSS @@ -1331,7 +1325,6 @@ Action: ``PF`` Redirects packets to the physical function (PF) of the current device. - No configurable properties. -- Terminating by default. .. _table_rte_flow_action_pf: @@ -1353,8 +1346,6 @@ ID instead of the specified one. This parameter may not be available and is not guaranteed to work properly if the VF part is matched by a prior flow rule or if packets are not addressed to a VF in the first place. -- Terminating by default. - .. _table_rte_flow_action_vf: .. table:: VF @@ -1378,8 +1369,6 @@ action parameter. More than one flow can use the same MTR object through the meter action. The MTR object can be further updated or queried using the rte_mtr* API. -- Non-terminating by default. - .. _table_rte_flow_action_meter: .. table:: METER @@ -1415,8 +1404,6 @@ direction. Multiple flows can be configured to use the same security session. -- Non-terminating by default. - .. _table_rte_flow_action_security: .. table:: SECURITY diff --git a/doc/guides/rel_notes/release_18_05.rst b/doc/guides/rel_notes/release_18_05.rst index d3b619216..1db6c5257 100644 --- a/doc/guides/rel_notes/release_18_05.rst +++ b/doc/guides/rel_notes/release_18_05.rst @@ -243,7 +243,15 @@ API Changes fall-back value. Previously, setting ``nb_tx_desc`` to zero would have resulted in an error. -* ethdev: unused DUP action was removed from the flow API. +* ethdev: several changes were made to the flow API. + + * Unused DUP action was removed. + * Actions semantics in flow rules: list order now matters ("first + to last" instead of "all simultaneously"), repeated actions are now + all performed, and they do not individually have (non-)terminating + properties anymore. + * Flow rules are now always terminating unless a PASSTHRU action is + present. ABI Changes @@ -290,8 +298,9 @@ ABI Changes This includes functions ``rte_flow_copy``, ``rte_flow_create``, ``rte_flow_destroy``, ``rte_flow_error_set``, ``rte_flow_flush``, ``rte_flow_isolate``, ``rte_flow_query`` and ``rte_flow_validate``, due to - changes in error type definitions (``enum rte_flow_error_type``) and - removal of the unused DUP action (``enum rte_flow_action_type``). + changes in error type definitions (``enum rte_flow_error_type``), removal + of the unused DUP action (``enum rte_flow_action_type``) and modified + behavior for flow rule actions (see API changes). Removed Items diff --git a/drivers/net/enic/enic_flow.c b/drivers/net/enic/enic_flow.c index b9f36587c..c34ae84d1 100644 --- a/drivers/net/enic/enic_flow.c +++ b/drivers/net/enic/enic_flow.c @@ -3,6 +3,7 @@ */ #include <errno.h> +#include <stdint.h> #include <rte_log.h> #include <rte_ethdev_driver.h> #include <rte_flow_driver.h> @@ -964,6 +965,9 @@ static int enic_copy_action_v1(const struct rte_flow_action actions[], struct filter_action_v2 *enic_action) { + enum { FATE = 1, }; + uint32_t overlap = 0; + FLOW_TRACE(); for (; actions->type != RTE_FLOW_ACTION_TYPE_END; actions++) { @@ -975,6 +979,10 @@ enic_copy_action_v1(const struct rte_flow_action actions[], const struct rte_flow_action_queue *queue = (const struct rte_flow_action_queue *) actions->conf; + + if (overlap & FATE) + return ENOTSUP; + overlap |= FATE; enic_action->rq_idx = enic_rte_rq_idx_to_sop_idx(queue->index); break; @@ -984,6 +992,8 @@ enic_copy_action_v1(const struct rte_flow_action actions[], break; } } + if (!(overlap & FATE)) + return ENOTSUP; enic_action->type = FILTER_ACTION_RQ_STEERING; return 0; } @@ -1001,6 +1011,9 @@ static int enic_copy_action_v2(const struct rte_flow_action actions[], struct filter_action_v2 *enic_action) { + enum { FATE = 1, MARK = 2, }; + uint32_t overlap = 0; + FLOW_TRACE(); for (; actions->type != RTE_FLOW_ACTION_TYPE_END; actions++) { @@ -1009,6 +1022,10 @@ enic_copy_action_v2(const struct rte_flow_action actions[], const struct rte_flow_action_queue *queue = (const struct rte_flow_action_queue *) actions->conf; + + if (overlap & FATE) + return ENOTSUP; + overlap |= FATE; enic_action->rq_idx = enic_rte_rq_idx_to_sop_idx(queue->index); enic_action->flags |= FILTER_ACTION_RQ_STEERING_FLAG; @@ -1019,6 +1036,9 @@ enic_copy_action_v2(const struct rte_flow_action actions[], (const struct rte_flow_action_mark *) actions->conf; + if (overlap & MARK) + return ENOTSUP; + overlap |= MARK; /* ENIC_MAGIC_FILTER_ID is reserved and is the highest * in the range of allows mark ids. */ @@ -1029,6 +1049,9 @@ enic_copy_action_v2(const struct rte_flow_action actions[], break; } case RTE_FLOW_ACTION_TYPE_FLAG: { + if (overlap & MARK) + return ENOTSUP; + overlap |= MARK; enic_action->filter_id = ENIC_MAGIC_FILTER_ID; enic_action->flags |= FILTER_ACTION_FILTER_ID_FLAG; break; @@ -1044,6 +1067,8 @@ enic_copy_action_v2(const struct rte_flow_action actions[], break; } } + if (!(overlap & FATE)) + return ENOTSUP; enic_action->type = FILTER_ACTION_V2; return 0; } diff --git a/drivers/net/mlx4/mlx4_flow.c b/drivers/net/mlx4/mlx4_flow.c index 67fd568bc..15cdf07b7 100644 --- a/drivers/net/mlx4/mlx4_flow.c +++ b/drivers/net/mlx4/mlx4_flow.c @@ -637,6 +637,7 @@ mlx4_flow_prepare(struct priv *priv, struct rte_flow temp = { .ibv_attr_size = sizeof(*temp.ibv_attr) }; struct rte_flow *flow = &temp; const char *msg = NULL; + int overlap; if (attr->group) return rte_flow_error_set @@ -656,6 +657,7 @@ mlx4_flow_prepare(struct priv *priv, (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, NULL, "only ingress is supported"); fill: + overlap = 0; proc = mlx4_flow_proc_item_list; /* Go over pattern. */ for (item = pattern; item->type; ++item) { @@ -702,6 +704,16 @@ mlx4_flow_prepare(struct priv *priv, } /* Go over actions list. */ for (action = actions; action->type; ++action) { + /* This one may appear anywhere multiple times. */ + if (action->type == RTE_FLOW_ACTION_TYPE_VOID) + continue; + /* Fate-deciding actions may appear exactly once. */ + if (overlap) { + msg = "cannot combine several fate-deciding actions," + " choose between DROP, QUEUE or RSS"; + goto exit_action_not_supported; + } + overlap = 1; switch (action->type) { const struct rte_flow_action_queue *queue; const struct rte_flow_action_rss *rss; @@ -709,8 +721,6 @@ mlx4_flow_prepare(struct priv *priv, uint64_t fields; unsigned int i; - case RTE_FLOW_ACTION_TYPE_VOID: - continue; case RTE_FLOW_ACTION_TYPE_DROP: flow->drop = 1; break; @@ -801,10 +811,9 @@ mlx4_flow_prepare(struct priv *priv, goto exit_action_not_supported; } } - if (!flow->rss && !flow->drop) - return rte_flow_error_set - (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, - NULL, "no valid action"); + /* When fate is unknown, drop traffic. */ + if (!overlap) + flow->drop = 1; /* Validation ends here. */ if (!addr) { if (flow->rss) diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 1807e3f5b..586e780c4 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -4,6 +4,7 @@ */ #include <sys/queue.h> +#include <stdint.h> #include <string.h> /* Verbs header. */ @@ -646,6 +647,8 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, struct rte_flow_error *error, struct mlx5_flow_parse *parser) { + enum { FATE = 1, MARK = 2, COUNT = 4, }; + uint32_t overlap = 0; struct priv *priv = dev->data->dev_private; int ret; @@ -662,39 +665,31 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, if (actions->type == RTE_FLOW_ACTION_TYPE_VOID) { continue; } else if (actions->type == RTE_FLOW_ACTION_TYPE_DROP) { + if (overlap & FATE) + goto exit_action_overlap; + overlap |= FATE; parser->drop = 1; } else if (actions->type == RTE_FLOW_ACTION_TYPE_QUEUE) { const struct rte_flow_action_queue *queue = (const struct rte_flow_action_queue *) actions->conf; - uint16_t n; - uint16_t found = 0; + if (overlap & FATE) + goto exit_action_overlap; + overlap |= FATE; if (!queue || (queue->index > (priv->rxqs_n - 1))) goto exit_action_not_supported; - for (n = 0; n < parser->queues_n; ++n) { - if (parser->queues[n] == queue->index) { - found = 1; - break; - } - } - if (parser->queues_n > 1 && !found) { - rte_flow_error_set(error, ENOTSUP, - RTE_FLOW_ERROR_TYPE_ACTION, - actions, - "queue action not in RSS queues"); - return -rte_errno; - } - if (!found) { - parser->queues_n = 1; - parser->queues[0] = queue->index; - } + parser->queues_n = 1; + parser->queues[0] = queue->index; } else if (actions->type == RTE_FLOW_ACTION_TYPE_RSS) { const struct rte_flow_action_rss *rss = (const struct rte_flow_action_rss *) actions->conf; uint16_t n; + if (overlap & FATE) + goto exit_action_overlap; + overlap |= FATE; if (!rss || !rss->num) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, @@ -702,26 +697,6 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, "no valid queues"); return -rte_errno; } - if (parser->queues_n == 1) { - uint16_t found = 0; - - assert(parser->queues_n); - for (n = 0; n < rss->num; ++n) { - if (parser->queues[0] == - rss->queue[n]) { - found = 1; - break; - } - } - if (!found) { - rte_flow_error_set(error, ENOTSUP, - RTE_FLOW_ERROR_TYPE_ACTION, - actions, - "queue action not in RSS" - " queues"); - return -rte_errno; - } - } if (rss->num > RTE_DIM(parser->queues)) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, @@ -755,6 +730,9 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, (const struct rte_flow_action_mark *) actions->conf; + if (overlap & MARK) + goto exit_action_overlap; + overlap |= MARK; if (!mark) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, @@ -772,14 +750,23 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, parser->mark = 1; parser->mark_id = mark->id; } else if (actions->type == RTE_FLOW_ACTION_TYPE_FLAG) { + if (overlap & MARK) + goto exit_action_overlap; + overlap |= MARK; parser->mark = 1; } else if (actions->type == RTE_FLOW_ACTION_TYPE_COUNT && priv->config.flow_counter_en) { + if (overlap & COUNT) + goto exit_action_overlap; + overlap |= COUNT; parser->count = 1; } else { goto exit_action_not_supported; } } + /* When fate is unknown, drop traffic. */ + if (!(overlap & FATE)) + parser->drop = 1; if (parser->drop && parser->mark) parser->mark = 0; if (!parser->queues_n && !parser->drop) { @@ -792,6 +779,10 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, actions, "action not supported"); return -rte_errno; +exit_action_overlap: + rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, + actions, "overlapping actions are not supported"); + return -rte_errno; } /** diff --git a/drivers/net/sfc/sfc_flow.c b/drivers/net/sfc/sfc_flow.c index fe4c0b0c5..056405515 100644 --- a/drivers/net/sfc/sfc_flow.c +++ b/drivers/net/sfc/sfc_flow.c @@ -1467,10 +1467,19 @@ sfc_flow_parse_actions(struct sfc_adapter *sa, } for (; actions->type != RTE_FLOW_ACTION_TYPE_END; actions++) { + /* This one may appear anywhere multiple times. */ + if (actions->type == RTE_FLOW_ACTION_TYPE_VOID) + continue; + /* Fate-deciding actions may appear exactly once. */ + if (is_specified) { + rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, + actions, + "Cannot combine several fate-deciding actions," + "choose between QUEUE, RSS or DROP"); + return -rte_errno; + } switch (actions->type) { - case RTE_FLOW_ACTION_TYPE_VOID: - break; - case RTE_FLOW_ACTION_TYPE_QUEUE: rc = sfc_flow_parse_queue(sa, actions->conf, flow); if (rc != 0) { @@ -1512,11 +1521,10 @@ sfc_flow_parse_actions(struct sfc_adapter *sa, } } + /* When fate is unknown, drop traffic. */ if (!is_specified) { - rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ACTION_NUM, actions, - "Action is unspecified"); - return -rte_errno; + flow->spec.template.efs_dmaq_id = + EFX_FILTER_SPEC_RX_DMAQ_ID_DROP; } return 0; diff --git a/drivers/net/tap/tap_flow.c b/drivers/net/tap/tap_flow.c index 3b7a960b0..fe2f94010 100644 --- a/drivers/net/tap/tap_flow.c +++ b/drivers/net/tap/tap_flow.c @@ -1140,6 +1140,7 @@ priv_flow_process(struct pmd_internals *pmd, else goto end; } +actions: for (; actions->type != RTE_FLOW_ACTION_TYPE_END; ++actions) { int err = 0; @@ -1222,6 +1223,16 @@ priv_flow_process(struct pmd_internals *pmd, if (err) goto exit_action_not_supported; } + /* When fate is unknown, drop traffic. */ + if (!action) { + static const struct rte_flow_action drop[] = { + { .type = RTE_FLOW_ACTION_TYPE_DROP, }, + { .type = RTE_FLOW_ACTION_TYPE_END, }, + }; + + actions = drop; + goto actions; + } end: if (flow) tap_nlattr_nested_finish(&flow->msg); /* nested TCA_OPTIONS */ diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index 6ace24ff4..96184f030 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -859,32 +859,28 @@ struct rte_flow_item { * * Each possible action is represented by a type. Some have associated * configuration structures. Several actions combined in a list can be - * affected to a flow rule. That list is not ordered. + * assigned to a flow rule and are performed in order. * * They fall in three categories: * - * - Terminating actions that prevent processing matched packets by - * subsequent flow rules, unless overridden with PASSTHRU. + * - Actions that modify the fate of matching traffic, for instance by + * dropping or assigning it a specific destination. * - * - Non terminating actions that leave matched packets up for additional - * processing by subsequent flow rules. + * - Actions that modify matching traffic contents or its properties. This + * includes adding/removing encapsulation, encryption, compression and + * marks. * - * - Other non terminating meta actions that do not affect the fate of - * packets. + * - Actions related to the flow rule itself, such as updating counters or + * making it non-terminating. * - * When several actions are combined in a flow rule, they should all have - * different types (e.g. dropping a packet twice is not possible). + * Flow rules being terminating by default, not specifying any action of the + * fate kind results in undefined behavior. This applies to both ingress and + * egress. * - * Only the last action of a given type is taken into account. PMDs still - * perform error checking on the entire list. - * - * Note that PASSTHRU is the only action able to override a terminating - * rule. + * PASSTHRU, when supported, makes a flow rule non-terminating. */ enum rte_flow_action_type { /** - * [META] - * * End marker for action lists. Prevents further processing of * actions, thereby ending the list. * @@ -893,8 +889,6 @@ enum rte_flow_action_type { RTE_FLOW_ACTION_TYPE_END, /** - * [META] - * * Used as a placeholder for convenience. It is ignored and simply * discarded by PMDs. * @@ -903,18 +897,14 @@ enum rte_flow_action_type { RTE_FLOW_ACTION_TYPE_VOID, /** - * Leaves packets up for additional processing by subsequent flow - * rules. This is the default when a rule does not contain a - * terminating action, but can be specified to force a rule to - * become non-terminating. + * Leaves traffic up for additional processing by subsequent flow + * rules; makes a flow rule non-terminating. * * No associated configuration structure. */ RTE_FLOW_ACTION_TYPE_PASSTHRU, /** - * [META] - * * Attaches an integer value to packets and sets PKT_RX_FDIR and * PKT_RX_FDIR_ID mbuf flags. * @@ -923,8 +913,6 @@ enum rte_flow_action_type { RTE_FLOW_ACTION_TYPE_MARK, /** - * [META] - * * Flags packets. Similar to MARK without a specific value; only * sets the PKT_RX_FDIR mbuf flag. * @@ -949,9 +937,7 @@ enum rte_flow_action_type { RTE_FLOW_ACTION_TYPE_DROP, /** - * [META] - * - * Enables counters for this rule. + * Enables counters for this flow rule. * * These counters can be retrieved and reset through rte_flow_query(), * see struct rte_flow_query_count. @@ -1020,8 +1006,6 @@ struct rte_flow_action_mark { * RTE_FLOW_ACTION_TYPE_QUEUE * * Assign packets to a given queue index. - * - * Terminating by default. */ struct rte_flow_action_queue { uint16_t index; /**< Queue index to use. */ @@ -1050,8 +1034,6 @@ struct rte_flow_query_count { * Note: RSS hash result is stored in the hash.rss mbuf field which overlaps * hash.fdir.lo. Since the MARK action sets the hash.fdir.hi field only, * both can be requested simultaneously. - * - * Terminating by default. */ struct rte_flow_action_rss { const struct rte_eth_rss_conf *rss_conf; /**< RSS parameters. */ @@ -1069,8 +1051,6 @@ struct rte_flow_action_rss { * and is not guaranteed to work properly if the VF part is matched by a * prior flow rule or if packets are not addressed to a VF in the first * place. - * - * Terminating by default. */ struct rte_flow_action_vf { uint32_t original:1; /**< Use original VF ID if possible. */ @@ -1085,8 +1065,6 @@ struct rte_flow_action_vf { * * Packets matched by items of this type can be either dropped or passed to the * next item with their color set by the MTR object. - * - * Non-terminating by default. */ struct rte_flow_action_meter { uint32_t mtr_id; /**< MTR object ID created with rte_mtr_create(). */ @@ -1116,8 +1094,6 @@ struct rte_flow_action_meter { * direction. * * Multiple flows can be configured to use the same security session. - * - * Non-terminating by default. */ struct rte_flow_action_security { void *security_session; /**< Pointer to security session structure. */ -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v6 06/16] ethdev: fix C99 flexible arrays from flow API 2018-04-25 15:27 ` [dpdk-dev] [PATCH v6 00/16] Flow API overhaul for switch offloads Adrien Mazarguil ` (4 preceding siblings ...) 2018-04-25 15:27 ` [dpdk-dev] [PATCH v6 05/16] ethdev: alter behavior of flow API actions Adrien Mazarguil @ 2018-04-25 15:27 ` Adrien Mazarguil 2018-04-25 15:27 ` [dpdk-dev] [PATCH v6 07/16] ethdev: flatten RSS configuration in " Adrien Mazarguil ` (10 subsequent siblings) 16 siblings, 0 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-25 15:27 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev This patch replaces C99-style flexible arrays in struct rte_flow_action_rss and struct rte_flow_item_raw with standard pointers to the same data. They proved difficult to use in the field (e.g. no possibility of static initialization) and unsuitable for C++ applications. Affected PMDs and examples are updated accordingly. This breaks ABI compatibility for the following public functions: - rte_flow_copy() - rte_flow_create() - rte_flow_query() - rte_flow_validate() Fixes: b1a4b4cbc0a8 ("ethdev: introduce generic flow API") Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Acked-by: Thomas Monjalon <thomas@monjalon.net> Acked-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com> -- v6 changes: - Reworded patch title as a "fix" (not candidate for backports) since it addresses a flaw in the original API definition. - Updated API and ABI changes sections in release notes. --- app/test-pmd/cmdline_flow.c | 117 +++++++++++++++------------- app/test-pmd/config.c | 25 ++++-- doc/guides/prog_guide/rte_flow.rst | 18 ++--- doc/guides/rel_notes/release_18_05.rst | 8 +- drivers/net/mlx4/mlx4_flow.c | 22 +++--- drivers/net/mlx5/mlx5_flow.c | 20 ++--- examples/ipsec-secgw/ipsec.c | 17 ++-- lib/librte_ether/rte_flow.c | 25 ++++-- lib/librte_ether/rte_flow.h | 8 +- 9 files changed, 141 insertions(+), 119 deletions(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 2ddb08feb..798b7948d 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -179,25 +179,22 @@ enum index { ACTION_METER_ID, }; -/** Size of pattern[] field in struct rte_flow_item_raw. */ -#define ITEM_RAW_PATTERN_SIZE 36 +/** Maximum size for pattern in struct rte_flow_item_raw. */ +#define ITEM_RAW_PATTERN_SIZE 40 /** Storage size for struct rte_flow_item_raw including pattern. */ #define ITEM_RAW_SIZE \ - (offsetof(struct rte_flow_item_raw, pattern) + ITEM_RAW_PATTERN_SIZE) + (sizeof(struct rte_flow_item_raw) + ITEM_RAW_PATTERN_SIZE) /** Maximum number of queue indices in struct rte_flow_action_rss. */ #define ACTION_RSS_QUEUE_NUM 32 /** Storage for struct rte_flow_action_rss including external data. */ -union action_rss_data { +struct action_rss_data { struct rte_flow_action_rss conf; - struct { - uint8_t conf_data[offsetof(struct rte_flow_action_rss, queue)]; - uint16_t queue[ACTION_RSS_QUEUE_NUM]; - struct rte_eth_rss_conf rss_conf; - uint8_t rss_key[RSS_HASH_KEY_LENGTH]; - } s; + uint16_t queue[ACTION_RSS_QUEUE_NUM]; + struct rte_eth_rss_conf rss_conf; + uint8_t rss_key[RSS_HASH_KEY_LENGTH]; }; /** Maximum number of subsequent tokens and arguments on the stack. */ @@ -320,13 +317,6 @@ struct token { .size = sizeof(*((s *)0)->f), \ }) -/** Static initializer for ARGS() with arbitrary size. */ -#define ARGS_ENTRY_USZ(s, f, sz) \ - (&(const struct arg){ \ - .offset = offsetof(s, f), \ - .size = (sz), \ - }) - /** Static initializer for ARGS() with arbitrary offset and size. */ #define ARGS_ENTRY_ARB(o, s) \ (&(const struct arg){ \ @@ -1105,9 +1095,9 @@ static const struct token token_list[] = { NEXT_ENTRY(ITEM_PARAM_IS, ITEM_PARAM_SPEC, ITEM_PARAM_MASK)), - .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, length), - ARGS_ENTRY_USZ(struct rte_flow_item_raw, - pattern, + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, pattern), + ARGS_ENTRY(struct rte_flow_item_raw, length), + ARGS_ENTRY_ARB(sizeof(struct rte_flow_item_raw), ITEM_RAW_PATTERN_SIZE)), }, [ITEM_ETH] = { @@ -1591,7 +1581,7 @@ static const struct token token_list[] = { [ACTION_RSS] = { .name = "rss", .help = "spread packets among several queues", - .priv = PRIV_ACTION(RSS, sizeof(union action_rss_data)), + .priv = PRIV_ACTION(RSS, sizeof(struct action_rss_data)), .next = NEXT(action_rss), .call = parse_vc_action_rss, }, @@ -1610,23 +1600,21 @@ static const struct token token_list[] = { .name = "key", .help = "RSS hash key", .next = NEXT(action_rss, NEXT_ENTRY(STRING)), - .args = ARGS(ARGS_ENTRY_ARB - (((uintptr_t)&((union action_rss_data *)0)-> - s.rss_conf.rss_key_len), + .args = ARGS(ARGS_ENTRY_ARB(0, 0), + ARGS_ENTRY_ARB + (offsetof(struct action_rss_data, rss_conf) + + offsetof(struct rte_eth_rss_conf, rss_key_len), sizeof(((struct rte_eth_rss_conf *)0)-> rss_key_len)), - ARGS_ENTRY_ARB - (((uintptr_t)((union action_rss_data *)0)-> - s.rss_key), - RSS_HASH_KEY_LENGTH)), + ARGS_ENTRY(struct action_rss_data, rss_key)), }, [ACTION_RSS_KEY_LEN] = { .name = "key_len", .help = "RSS hash key length in bytes", .next = NEXT(action_rss, NEXT_ENTRY(UNSIGNED)), .args = ARGS(ARGS_ENTRY_ARB_BOUNDED - (((uintptr_t)&((union action_rss_data *)0)-> - s.rss_conf.rss_key_len), + (offsetof(struct action_rss_data, rss_conf) + + offsetof(struct rte_eth_rss_conf, rss_key_len), sizeof(((struct rte_eth_rss_conf *)0)-> rss_key_len), 0, @@ -2067,7 +2055,7 @@ parse_vc_action_rss(struct context *ctx, const struct token *token, { struct buffer *out = buf; struct rte_flow_action *action; - union action_rss_data *action_rss_data; + struct action_rss_data *action_rss_data; unsigned int i; int ret; @@ -2085,29 +2073,29 @@ parse_vc_action_rss(struct context *ctx, const struct token *token, ctx->objmask = NULL; /* Set up default configuration. */ action_rss_data = ctx->object; - *action_rss_data = (union action_rss_data){ + *action_rss_data = (struct action_rss_data){ .conf = (struct rte_flow_action_rss){ - .rss_conf = &action_rss_data->s.rss_conf, + .rss_conf = &action_rss_data->rss_conf, .num = RTE_MIN(nb_rxq, ACTION_RSS_QUEUE_NUM), + .queue = action_rss_data->queue, }, + .queue = { 0 }, + .rss_conf = (struct rte_eth_rss_conf){ + .rss_key = action_rss_data->rss_key, + .rss_key_len = sizeof(action_rss_data->rss_key), + .rss_hf = rss_hf, + }, + .rss_key = "testpmd's default RSS hash key", }; - action_rss_data->s.rss_conf = (struct rte_eth_rss_conf){ - .rss_key = action_rss_data->s.rss_key, - .rss_key_len = sizeof(action_rss_data->s.rss_key), - .rss_hf = rss_hf, - }; - strncpy((void *)action_rss_data->s.rss_key, - "testpmd's default RSS hash key", - sizeof(action_rss_data->s.rss_key)); for (i = 0; i < action_rss_data->conf.num; ++i) - action_rss_data->conf.queue[i] = i; + action_rss_data->queue[i] = i; if (!port_id_is_invalid(ctx->port, DISABLED_WARN) && ctx->port != (portid_t)RTE_PORT_ALL) { struct rte_eth_dev_info info; rte_eth_dev_info_get(ctx->port, &info); - action_rss_data->s.rss_conf.rss_key_len = - RTE_MIN(sizeof(action_rss_data->s.rss_key), + action_rss_data->rss_conf.rss_key_len = + RTE_MIN(sizeof(action_rss_data->rss_key), info.hash_key_size); } action->conf = &action_rss_data->conf; @@ -2125,7 +2113,7 @@ parse_vc_action_rss_type(struct context *ctx, const struct token *token, void *buf, unsigned int size) { static const enum index next[] = NEXT_ENTRY(ACTION_RSS_TYPE); - union action_rss_data *action_rss_data; + struct action_rss_data *action_rss_data; unsigned int i; (void)token; @@ -2135,7 +2123,7 @@ parse_vc_action_rss_type(struct context *ctx, const struct token *token, return -1; if (!(ctx->objdata >> 16) && ctx->object) { action_rss_data = ctx->object; - action_rss_data->s.rss_conf.rss_hf = 0; + action_rss_data->rss_conf.rss_hf = 0; } if (!strcmp_partial("end", str, len)) { ctx->objdata &= 0xffff; @@ -2154,7 +2142,7 @@ parse_vc_action_rss_type(struct context *ctx, const struct token *token, if (!ctx->object) return len; action_rss_data = ctx->object; - action_rss_data->s.rss_conf.rss_hf |= rss_type_table[i].rss_type; + action_rss_data->rss_conf.rss_hf |= rss_type_table[i].rss_type; return len; } @@ -2169,7 +2157,7 @@ parse_vc_action_rss_queue(struct context *ctx, const struct token *token, void *buf, unsigned int size) { static const enum index next[] = NEXT_ENTRY(ACTION_RSS_QUEUE); - union action_rss_data *action_rss_data; + struct action_rss_data *action_rss_data; int ret; int i; @@ -2186,10 +2174,9 @@ parse_vc_action_rss_queue(struct context *ctx, const struct token *token, if (i >= ACTION_RSS_QUEUE_NUM) return -1; if (push_args(ctx, - ARGS_ENTRY_ARB(offsetof(struct rte_flow_action_rss, - queue) + - i * sizeof(action_rss_data->s.queue[i]), - sizeof(action_rss_data->s.queue[i])))) + ARGS_ENTRY_ARB(offsetof(struct action_rss_data, queue) + + i * sizeof(action_rss_data->queue[i]), + sizeof(action_rss_data->queue[i])))) return -1; ret = parse_int(ctx, token, str, len, NULL, 0); if (ret < 0) { @@ -2206,6 +2193,7 @@ parse_vc_action_rss_queue(struct context *ctx, const struct token *token, return len; action_rss_data = ctx->object; action_rss_data->conf.num = i; + action_rss_data->conf.queue = i ? action_rss_data->queue : NULL; return len; } @@ -2483,8 +2471,8 @@ parse_int(struct context *ctx, const struct token *token, /** * Parse a string. * - * Two arguments (ctx->args) are retrieved from the stack to store data and - * its length (in that order). + * Three arguments (ctx->args) are retrieved from the stack to store data, + * its actual length and address (in that order). */ static int parse_string(struct context *ctx, const struct token *token, @@ -2493,6 +2481,7 @@ parse_string(struct context *ctx, const struct token *token, { const struct arg *arg_data = pop_args(ctx); const struct arg *arg_len = pop_args(ctx); + const struct arg *arg_addr = pop_args(ctx); char tmp[16]; /* Ought to be enough. */ int ret; @@ -2503,6 +2492,11 @@ parse_string(struct context *ctx, const struct token *token, push_args(ctx, arg_data); return -1; } + if (!arg_addr) { + push_args(ctx, arg_len); + push_args(ctx, arg_data); + return -1; + } size = arg_data->size; /* Bit-mask fill is not supported. */ if (arg_data->mask || size < len) @@ -2525,8 +2519,23 @@ parse_string(struct context *ctx, const struct token *token, memset((uint8_t *)buf + len, 0x00, size - len); if (ctx->objmask) memset((uint8_t *)ctx->objmask + arg_data->offset, 0xff, len); + /* Save address if requested. */ + if (arg_addr->size) { + memcpy((uint8_t *)ctx->object + arg_addr->offset, + (void *[]){ + (uint8_t *)ctx->object + arg_data->offset + }, + arg_addr->size); + if (ctx->objmask) + memcpy((uint8_t *)ctx->objmask + arg_addr->offset, + (void *[]){ + (uint8_t *)ctx->objmask + arg_data->offset + }, + arg_addr->size); + } return len; error: + push_args(ctx, arg_addr); push_args(ctx, arg_len); push_args(ctx, arg_data); return -1; diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 9729177f8..eb7ac315e 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -994,7 +994,7 @@ static const struct { MK_FLOW_ITEM(PF, 0), MK_FLOW_ITEM(VF, sizeof(struct rte_flow_item_vf)), MK_FLOW_ITEM(PORT, sizeof(struct rte_flow_item_port)), - MK_FLOW_ITEM(RAW, sizeof(struct rte_flow_item_raw)), /* +pattern[] */ + MK_FLOW_ITEM(RAW, sizeof(struct rte_flow_item_raw)), MK_FLOW_ITEM(ETH, sizeof(struct rte_flow_item_eth)), MK_FLOW_ITEM(VLAN, sizeof(struct rte_flow_item_vlan)), MK_FLOW_ITEM(IPV4, sizeof(struct rte_flow_item_ipv4)), @@ -1043,14 +1043,20 @@ flow_item_spec_copy(void *buf, const struct rte_flow_item *item, union { struct rte_flow_item_raw *raw; } dst; + size_t off; case RTE_FLOW_ITEM_TYPE_RAW: src.raw = item_spec; dst.raw = buf; - size = offsetof(struct rte_flow_item_raw, pattern) + - src.raw->length * sizeof(*src.raw->pattern); - if (dst.raw) - memcpy(dst.raw, src.raw, size); + off = RTE_ALIGN_CEIL(sizeof(struct rte_flow_item_raw), + sizeof(*src.raw->pattern)); + size = off + src.raw->length * sizeof(*src.raw->pattern); + if (dst.raw) { + memcpy(dst.raw, src.raw, sizeof(*src.raw)); + dst.raw->pattern = memcpy((uint8_t *)dst.raw + off, + src.raw->pattern, + size - off); + } break; default: size = flow_item[item->type].size; @@ -1082,7 +1088,7 @@ static const struct { MK_FLOW_ACTION(QUEUE, sizeof(struct rte_flow_action_queue)), MK_FLOW_ACTION(DROP, 0), MK_FLOW_ACTION(COUNT, 0), - MK_FLOW_ACTION(RSS, sizeof(struct rte_flow_action_rss)), /* +queue[] */ + MK_FLOW_ACTION(RSS, sizeof(struct rte_flow_action_rss)), MK_FLOW_ACTION(PF, 0), MK_FLOW_ACTION(VF, sizeof(struct rte_flow_action_vf)), MK_FLOW_ACTION(METER, sizeof(struct rte_flow_action_meter)), @@ -1113,11 +1119,14 @@ flow_action_conf_copy(void *buf, const struct rte_flow_action *action) *dst.rss = (struct rte_flow_action_rss){ .num = src.rss->num, }; - off += offsetof(struct rte_flow_action_rss, queue); + off += sizeof(*src.rss); if (src.rss->num) { + off = RTE_ALIGN_CEIL(off, sizeof(double)); size = sizeof(*src.rss->queue) * src.rss->num; if (dst.rss) - memcpy(dst.rss->queue, src.rss->queue, size); + dst.rss->queue = memcpy + ((void *)((uintptr_t)dst.rss + off), + src.rss->queue, size); off += size; } off = RTE_ALIGN_CEIL(off, sizeof(double)); diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 80360d068..acbeaacbd 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -1309,15 +1309,15 @@ field only, both can be requested simultaneously. .. table:: RSS - +--------------+------------------------------+ - | Field | Value | - +==============+==============================+ - | ``rss_conf`` | RSS parameters | - +--------------+------------------------------+ - | ``num`` | number of entries in queue[] | - +--------------+------------------------------+ - | ``queue[]`` | queue indices to use | - +--------------+------------------------------+ + +--------------+--------------------------------+ + | Field | Value | + +==============+================================+ + | ``rss_conf`` | RSS parameters | + +--------------+--------------------------------+ + | ``num`` | number of entries in ``queue`` | + +--------------+--------------------------------+ + | ``queue`` | queue indices to use | + +--------------+--------------------------------+ Action: ``PF`` ^^^^^^^^^^^^^^ diff --git a/doc/guides/rel_notes/release_18_05.rst b/doc/guides/rel_notes/release_18_05.rst index 1db6c5257..ca173450c 100644 --- a/doc/guides/rel_notes/release_18_05.rst +++ b/doc/guides/rel_notes/release_18_05.rst @@ -252,6 +252,8 @@ API Changes properties anymore. * Flow rules are now always terminating unless a PASSTHRU action is present. + * C99-style flexible arrays were replaced with standard pointers in RSS + action and in RAW pattern item structures due to compatibility issues. ABI Changes @@ -299,8 +301,10 @@ ABI Changes ``rte_flow_destroy``, ``rte_flow_error_set``, ``rte_flow_flush``, ``rte_flow_isolate``, ``rte_flow_query`` and ``rte_flow_validate``, due to changes in error type definitions (``enum rte_flow_error_type``), removal - of the unused DUP action (``enum rte_flow_action_type``) and modified - behavior for flow rule actions (see API changes). + of the unused DUP action (``enum rte_flow_action_type``), modified + behavior for flow rule actions (see API changes) and removal of C99 + flexible arrays from RSS action (``struct rte_flow_action_rss``) and RAW + pattern item (``struct rte_flow_item_raw``). Removed Items diff --git a/drivers/net/mlx4/mlx4_flow.c b/drivers/net/mlx4/mlx4_flow.c index 15cdf07b7..8feb6ae31 100644 --- a/drivers/net/mlx4/mlx4_flow.c +++ b/drivers/net/mlx4/mlx4_flow.c @@ -1282,14 +1282,16 @@ mlx4_flow_internal(struct priv *priv, struct rte_flow_error *error) */ uint32_t queues = rte_align32pow2(priv->dev->data->nb_rx_queues + 1) >> 1; - alignas(struct rte_flow_action_rss) uint8_t rss_conf_data - [offsetof(struct rte_flow_action_rss, queue) + - sizeof(((struct rte_flow_action_rss *)0)->queue[0]) * queues]; - struct rte_flow_action_rss *rss_conf = (void *)rss_conf_data; + uint16_t queue[queues]; + struct rte_flow_action_rss action_rss = { + .rss_conf = NULL, /* Rely on default fallback settings. */ + .num = queues, + .queue = queue, + }; struct rte_flow_action actions[] = { { .type = RTE_FLOW_ACTION_TYPE_RSS, - .conf = rss_conf, + .conf = &action_rss, }, { .type = RTE_FLOW_ACTION_TYPE_END, @@ -1311,12 +1313,8 @@ mlx4_flow_internal(struct priv *priv, struct rte_flow_error *error) if (!queues) goto error; /* Prepare default RSS configuration. */ - *rss_conf = (struct rte_flow_action_rss){ - .rss_conf = NULL, /* Rely on default fallback settings. */ - .num = queues, - }; for (i = 0; i != queues; ++i) - rss_conf->queue[i] = i; + queue[i] = i; /* * Set up VLAN item if filtering is enabled and at least one VLAN * filter is configured. @@ -1375,7 +1373,7 @@ mlx4_flow_internal(struct priv *priv, struct rte_flow_error *error) if (j != sizeof(mac->addr_bytes)) continue; if (flow->rss->queues != queues || - memcmp(flow->rss->queue_id, rss_conf->queue, + memcmp(flow->rss->queue_id, action_rss.queue, queues * sizeof(flow->rss->queue_id[0]))) continue; break; @@ -1415,7 +1413,7 @@ mlx4_flow_internal(struct priv *priv, struct rte_flow_error *error) if (flow && flow->internal) { assert(flow->rss); if (flow->rss->queues != queues || - memcmp(flow->rss->queue_id, rss_conf->queue, + memcmp(flow->rss->queue_id, action_rss.queue, queues * sizeof(flow->rss->queue_id[0]))) flow = NULL; } diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 586e780c4..0c89bff45 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -2456,9 +2456,16 @@ mlx5_ctrl_flow_vlan(struct rte_eth_dev *dev, .type = RTE_FLOW_ITEM_TYPE_END, }, }; + uint16_t queue[priv->reta_idx_n]; + struct rte_flow_action_rss action_rss = { + .rss_conf = &priv->rss_conf, + .num = priv->reta_idx_n, + .queue = queue, + }; struct rte_flow_action actions[] = { { .type = RTE_FLOW_ACTION_TYPE_RSS, + .conf = &action_rss, }, { .type = RTE_FLOW_ACTION_TYPE_END, @@ -2467,24 +2474,13 @@ mlx5_ctrl_flow_vlan(struct rte_eth_dev *dev, struct rte_flow *flow; struct rte_flow_error error; unsigned int i; - union { - struct rte_flow_action_rss rss; - struct { - const struct rte_eth_rss_conf *rss_conf; - uint16_t num; - uint16_t queue[RTE_MAX_QUEUES_PER_PORT]; - } local; - } action_rss; if (!priv->reta_idx_n) { rte_errno = EINVAL; return -rte_errno; } for (i = 0; i != priv->reta_idx_n; ++i) - action_rss.local.queue[i] = (*priv->reta_idx)[i]; - action_rss.local.rss_conf = &priv->rss_conf; - action_rss.local.num = priv->reta_idx_n; - actions[0].conf = (const void *)&action_rss.rss; + queue[i] = (*priv->reta_idx)[i]; flow = mlx5_flow_list_create(dev, &priv->ctrl_flows, &attr, items, actions, &error); if (!flow) diff --git a/examples/ipsec-secgw/ipsec.c b/examples/ipsec-secgw/ipsec.c index acdd1898b..5971937cf 100644 --- a/examples/ipsec-secgw/ipsec.c +++ b/examples/ipsec-secgw/ipsec.c @@ -187,14 +187,8 @@ create_session(struct ipsec_ctx *ipsec_ctx, struct ipsec_sa *sa) .rss_key_len = 40, }; struct rte_eth_dev *eth_dev; - union { - struct rte_flow_action_rss rss; - struct { - const struct rte_eth_rss_conf *rss_conf; - uint16_t num; - uint16_t queue[RTE_MAX_QUEUES_PER_PORT]; - } local; - } action_rss; + uint16_t queue[RTE_MAX_QUEUES_PER_PORT]; + struct rte_flow_action_rss action_rss; unsigned int i; unsigned int j; @@ -208,9 +202,10 @@ create_session(struct ipsec_ctx *ipsec_ctx, struct ipsec_sa *sa) for (i = 0, j = 0; i < eth_dev->data->nb_rx_queues; ++i) if (eth_dev->data->rx_queues[i]) - action_rss.local.queue[j++] = i; - action_rss.local.num = j; - action_rss.local.rss_conf = &rss_conf; + queue[j++] = i; + action_rss.rss_conf = &rss_conf; + action_rss.num = j; + action_rss.queue = queue; ret = rte_flow_validate(sa->portid, &sa->attr, sa->pattern, sa->action, &err); diff --git a/lib/librte_ether/rte_flow.c b/lib/librte_ether/rte_flow.c index 80f9cb6cb..bb19e28c6 100644 --- a/lib/librte_ether/rte_flow.c +++ b/lib/librte_ether/rte_flow.c @@ -39,7 +39,7 @@ static const struct rte_flow_desc_data rte_flow_desc_item[] = { MK_FLOW_ITEM(PF, 0), MK_FLOW_ITEM(VF, sizeof(struct rte_flow_item_vf)), MK_FLOW_ITEM(PORT, sizeof(struct rte_flow_item_port)), - MK_FLOW_ITEM(RAW, sizeof(struct rte_flow_item_raw)), /* +pattern[] */ + MK_FLOW_ITEM(RAW, sizeof(struct rte_flow_item_raw)), MK_FLOW_ITEM(ETH, sizeof(struct rte_flow_item_eth)), MK_FLOW_ITEM(VLAN, sizeof(struct rte_flow_item_vlan)), MK_FLOW_ITEM(IPV4, sizeof(struct rte_flow_item_ipv4)), @@ -73,7 +73,7 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = { MK_FLOW_ACTION(QUEUE, sizeof(struct rte_flow_action_queue)), MK_FLOW_ACTION(DROP, 0), MK_FLOW_ACTION(COUNT, 0), - MK_FLOW_ACTION(RSS, sizeof(struct rte_flow_action_rss)), /* +queue[] */ + MK_FLOW_ACTION(RSS, sizeof(struct rte_flow_action_rss)), MK_FLOW_ACTION(PF, 0), MK_FLOW_ACTION(VF, sizeof(struct rte_flow_action_vf)), }; @@ -282,14 +282,20 @@ flow_item_spec_copy(void *buf, const struct rte_flow_item *item, union { struct rte_flow_item_raw *raw; } dst; + size_t off; case RTE_FLOW_ITEM_TYPE_RAW: src.raw = item_spec; dst.raw = buf; - size = offsetof(struct rte_flow_item_raw, pattern) + - src.raw->length * sizeof(*src.raw->pattern); - if (dst.raw) - memcpy(dst.raw, src.raw, size); + off = RTE_ALIGN_CEIL(sizeof(struct rte_flow_item_raw), + sizeof(*src.raw->pattern)); + size = off + src.raw->length * sizeof(*src.raw->pattern); + if (dst.raw) { + memcpy(dst.raw, src.raw, sizeof(*src.raw)); + dst.raw->pattern = memcpy((uint8_t *)dst.raw + off, + src.raw->pattern, + size - off); + } break; default: size = rte_flow_desc_item[item->type].size; @@ -326,11 +332,14 @@ flow_action_conf_copy(void *buf, const struct rte_flow_action *action) *dst.rss = (struct rte_flow_action_rss){ .num = src.rss->num, }; - off += offsetof(struct rte_flow_action_rss, queue); + off += sizeof(*src.rss); if (src.rss->num) { + off = RTE_ALIGN_CEIL(off, sizeof(double)); size = sizeof(*src.rss->queue) * src.rss->num; if (dst.rss) - memcpy(dst.rss->queue, src.rss->queue, size); + dst.rss->queue = memcpy + ((void *)((uintptr_t)dst.rss + off), + src.rss->queue, size); off += size; } off = RTE_ALIGN_CEIL(off, sizeof(double)); diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index 96184f030..ad2e55b8e 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -14,6 +14,7 @@ * associated actions in hardware through flow rules. */ +#include <stddef.h> #include <stdint.h> #include <rte_arp.h> @@ -432,7 +433,7 @@ struct rte_flow_item_raw { int32_t offset; /**< Absolute or relative offset for pattern. */ uint16_t limit; /**< Search area limit for start of pattern. */ uint16_t length; /**< Pattern length. */ - uint8_t pattern[]; /**< Byte string to look for. */ + const uint8_t *pattern; /**< Byte string to look for. */ }; /** Default mask for RTE_FLOW_ITEM_TYPE_RAW. */ @@ -444,6 +445,7 @@ static const struct rte_flow_item_raw rte_flow_item_raw_mask = { .offset = 0xffffffff, .limit = 0xffff, .length = 0xffff, + .pattern = NULL, }; #endif @@ -1037,8 +1039,8 @@ struct rte_flow_query_count { */ struct rte_flow_action_rss { const struct rte_eth_rss_conf *rss_conf; /**< RSS parameters. */ - uint16_t num; /**< Number of entries in queue[]. */ - uint16_t queue[]; /**< Queues indices to use. */ + uint16_t num; /**< Number of entries in @p queue. */ + const uint16_t *queue; /**< Queue indices to use. */ }; /** -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v6 07/16] ethdev: flatten RSS configuration in flow API 2018-04-25 15:27 ` [dpdk-dev] [PATCH v6 00/16] Flow API overhaul for switch offloads Adrien Mazarguil ` (5 preceding siblings ...) 2018-04-25 15:27 ` [dpdk-dev] [PATCH v6 06/16] ethdev: fix C99 flexible arrays from flow API Adrien Mazarguil @ 2018-04-25 15:27 ` Adrien Mazarguil 2018-04-28 3:46 ` Zhao1, Wei 2018-04-25 15:27 ` [dpdk-dev] [PATCH v6 08/16] ethdev: add hash function to RSS flow API action Adrien Mazarguil ` (9 subsequent siblings) 16 siblings, 1 reply; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-25 15:27 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev Cc: Xueming Li, Wenzhuo Lu, Jingjing Wu, Beilei Xing, Qi Zhang, Konstantin Ananyev, Nelio Laranjeiro, Yongseok Koh, Andrew Rybchenko, Pascal Mazon, Radu Nicolau, Akhil Goyal Since its inception, the rte_flow RSS action has been relying in part on external struct rte_eth_rss_conf for compatibility with the legacy RSS API. This structure lacks parameters such as the hash algorithm to use, and more recently, a method to tell which layer RSS should be performed on [1]. Given struct rte_eth_rss_conf will never be flexible enough to represent a complete RSS configuration (e.g. RETA table), this patch supersedes it by extending the rte_flow RSS action directly. A subsequent patch will add a field to use a non-default RSS hash algorithm. To that end, a field named "types" replaces the field formerly known as "rss_hf" and standing for "RSS hash functions" as it was confusing. Actual RSS hash function types are defined by enum rte_eth_hash_function. This patch updates all PMDs and example applications accordingly. It breaks ABI compatibility for the following public functions: - rte_flow_copy() - rte_flow_create() - rte_flow_query() - rte_flow_validate() [1] commit 676b605182a5 ("doc: announce ethdev API change for RSS configuration") Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Acked-by: Andrew Rybchenko <arybchenko@solarflare.com> Cc: Xueming Li <xuemingl@mellanox.com> Cc: Ferruh Yigit <ferruh.yigit@intel.com> Cc: Thomas Monjalon <thomas@monjalon.net> Cc: Wenzhuo Lu <wenzhuo.lu@intel.com> Cc: Jingjing Wu <jingjing.wu@intel.com> Cc: Beilei Xing <beilei.xing@intel.com> Cc: Qi Zhang <qi.z.zhang@intel.com> Cc: Konstantin Ananyev <konstantin.ananyev@intel.com> Cc: Nelio Laranjeiro <nelio.laranjeiro@6wind.com> Cc: Yongseok Koh <yskoh@mellanox.com> Cc: Andrew Rybchenko <arybchenko@solarflare.com> Cc: Pascal Mazon <pascal.mazon@6wind.com> Cc: Radu Nicolau <radu.nicolau@intel.com> Cc: Akhil Goyal <akhil.goyal@nxp.com> --- v6 changes: - Fixed QUEUE action support in mlx5 according to Nelio's comment [1]. This action relies on RSS to work and even though it targets a single Rx queue, a non-NULL hash key is required. - Updated API and ABI changes sections in release notes. [1] http://dpdk.org/ml/archives/dev/2018-April/098635.html v3 changes: Documentation update regarding the meaning of a 0 value for RSS types in flow rules. It used to implicitly mean "no RSS" but is redefined as requesting a kind of "best-effort" mode from PMDs, i.e. anything ranging from empty to all-inclusive RSS; what matters is it provides safe defaults that will work regardless of PMD capabilities. --- app/test-pmd/cmdline_flow.c | 48 +++--- app/test-pmd/config.c | 39 ++--- doc/guides/prog_guide/rte_flow.rst | 28 ++-- doc/guides/rel_notes/release_18_05.rst | 13 +- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 6 +- drivers/net/e1000/e1000_ethdev.h | 13 +- drivers/net/e1000/igb_ethdev.c | 4 +- drivers/net/e1000/igb_flow.c | 31 ++-- drivers/net/e1000/igb_rxtx.c | 51 +++++- drivers/net/i40e/i40e_ethdev.c | 53 +++++-- drivers/net/i40e/i40e_ethdev.h | 15 +- drivers/net/i40e/i40e_flow.c | 47 +++--- drivers/net/ixgbe/ixgbe_ethdev.c | 4 +- drivers/net/ixgbe/ixgbe_ethdev.h | 13 +- drivers/net/ixgbe/ixgbe_flow.c | 30 ++-- drivers/net/ixgbe/ixgbe_rxtx.c | 51 +++++- drivers/net/mlx4/mlx4.c | 2 +- drivers/net/mlx4/mlx4_flow.c | 61 +++---- drivers/net/mlx4/mlx4_flow.h | 2 +- drivers/net/mlx4/mlx4_rxq.c | 2 +- drivers/net/mlx4/mlx4_rxtx.h | 2 +- drivers/net/mlx5/mlx5_flow.c | 193 +++++++++++------------ drivers/net/mlx5/mlx5_rxq.c | 26 +-- drivers/net/mlx5/mlx5_rxtx.h | 26 +-- drivers/net/sfc/sfc_flow.c | 21 ++- drivers/net/tap/tap_flow.c | 8 +- examples/ipsec-secgw/ipsec.c | 10 +- lib/librte_ether/rte_flow.c | 39 ++--- lib/librte_ether/rte_flow.h | 12 +- 29 files changed, 492 insertions(+), 358 deletions(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 798b7948d..c9c2c3ad9 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -192,9 +192,8 @@ enum index { /** Storage for struct rte_flow_action_rss including external data. */ struct action_rss_data { struct rte_flow_action_rss conf; + uint8_t key[RSS_HASH_KEY_LENGTH]; uint16_t queue[ACTION_RSS_QUEUE_NUM]; - struct rte_eth_rss_conf rss_conf; - uint8_t rss_key[RSS_HASH_KEY_LENGTH]; }; /** Maximum number of subsequent tokens and arguments on the stack. */ @@ -1587,7 +1586,7 @@ static const struct token token_list[] = { }, [ACTION_RSS_TYPES] = { .name = "types", - .help = "RSS hash types", + .help = "specific RSS hash types", .next = NEXT(action_rss, NEXT_ENTRY(ACTION_RSS_TYPE)), }, [ACTION_RSS_TYPE] = { @@ -1602,21 +1601,21 @@ static const struct token token_list[] = { .next = NEXT(action_rss, NEXT_ENTRY(STRING)), .args = ARGS(ARGS_ENTRY_ARB(0, 0), ARGS_ENTRY_ARB - (offsetof(struct action_rss_data, rss_conf) + - offsetof(struct rte_eth_rss_conf, rss_key_len), - sizeof(((struct rte_eth_rss_conf *)0)-> - rss_key_len)), - ARGS_ENTRY(struct action_rss_data, rss_key)), + (offsetof(struct action_rss_data, conf) + + offsetof(struct rte_flow_action_rss, key_len), + sizeof(((struct rte_flow_action_rss *)0)-> + key_len)), + ARGS_ENTRY(struct action_rss_data, key)), }, [ACTION_RSS_KEY_LEN] = { .name = "key_len", .help = "RSS hash key length in bytes", .next = NEXT(action_rss, NEXT_ENTRY(UNSIGNED)), .args = ARGS(ARGS_ENTRY_ARB_BOUNDED - (offsetof(struct action_rss_data, rss_conf) + - offsetof(struct rte_eth_rss_conf, rss_key_len), - sizeof(((struct rte_eth_rss_conf *)0)-> - rss_key_len), + (offsetof(struct action_rss_data, conf) + + offsetof(struct rte_flow_action_rss, key_len), + sizeof(((struct rte_flow_action_rss *)0)-> + key_len), 0, RSS_HASH_KEY_LENGTH)), }, @@ -2075,27 +2074,24 @@ parse_vc_action_rss(struct context *ctx, const struct token *token, action_rss_data = ctx->object; *action_rss_data = (struct action_rss_data){ .conf = (struct rte_flow_action_rss){ - .rss_conf = &action_rss_data->rss_conf, - .num = RTE_MIN(nb_rxq, ACTION_RSS_QUEUE_NUM), + .types = rss_hf, + .key_len = sizeof(action_rss_data->key), + .queue_num = RTE_MIN(nb_rxq, ACTION_RSS_QUEUE_NUM), + .key = action_rss_data->key, .queue = action_rss_data->queue, }, + .key = "testpmd's default RSS hash key", .queue = { 0 }, - .rss_conf = (struct rte_eth_rss_conf){ - .rss_key = action_rss_data->rss_key, - .rss_key_len = sizeof(action_rss_data->rss_key), - .rss_hf = rss_hf, - }, - .rss_key = "testpmd's default RSS hash key", }; - for (i = 0; i < action_rss_data->conf.num; ++i) + for (i = 0; i < action_rss_data->conf.queue_num; ++i) action_rss_data->queue[i] = i; if (!port_id_is_invalid(ctx->port, DISABLED_WARN) && ctx->port != (portid_t)RTE_PORT_ALL) { struct rte_eth_dev_info info; rte_eth_dev_info_get(ctx->port, &info); - action_rss_data->rss_conf.rss_key_len = - RTE_MIN(sizeof(action_rss_data->rss_key), + action_rss_data->conf.key_len = + RTE_MIN(sizeof(action_rss_data->key), info.hash_key_size); } action->conf = &action_rss_data->conf; @@ -2123,7 +2119,7 @@ parse_vc_action_rss_type(struct context *ctx, const struct token *token, return -1; if (!(ctx->objdata >> 16) && ctx->object) { action_rss_data = ctx->object; - action_rss_data->rss_conf.rss_hf = 0; + action_rss_data->conf.types = 0; } if (!strcmp_partial("end", str, len)) { ctx->objdata &= 0xffff; @@ -2142,7 +2138,7 @@ parse_vc_action_rss_type(struct context *ctx, const struct token *token, if (!ctx->object) return len; action_rss_data = ctx->object; - action_rss_data->rss_conf.rss_hf |= rss_type_table[i].rss_type; + action_rss_data->conf.types |= rss_type_table[i].rss_type; return len; } @@ -2192,7 +2188,7 @@ parse_vc_action_rss_queue(struct context *ctx, const struct token *token, if (!ctx->object) return len; action_rss_data = ctx->object; - action_rss_data->conf.num = i; + action_rss_data->conf.queue_num = i; action_rss_data->conf.queue = i ? action_rss_data->queue : NULL; return len; } diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index eb7ac315e..4700dd674 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -1117,40 +1117,27 @@ flow_action_conf_copy(void *buf, const struct rte_flow_action *action) off = 0; if (dst.rss) *dst.rss = (struct rte_flow_action_rss){ - .num = src.rss->num, + .types = src.rss->types, + .key_len = src.rss->key_len, + .queue_num = src.rss->queue_num, }; off += sizeof(*src.rss); - if (src.rss->num) { + if (src.rss->key_len) { off = RTE_ALIGN_CEIL(off, sizeof(double)); - size = sizeof(*src.rss->queue) * src.rss->num; + size = sizeof(*src.rss->key) * src.rss->key_len; if (dst.rss) - dst.rss->queue = memcpy + dst.rss->key = memcpy ((void *)((uintptr_t)dst.rss + off), - src.rss->queue, size); + src.rss->key, size); off += size; } - off = RTE_ALIGN_CEIL(off, sizeof(double)); - if (dst.rss) { - dst.rss->rss_conf = (void *)((uintptr_t)dst.rss + off); - *(struct rte_eth_rss_conf *)(uintptr_t) - dst.rss->rss_conf = (struct rte_eth_rss_conf){ - .rss_key_len = src.rss->rss_conf->rss_key_len, - .rss_hf = src.rss->rss_conf->rss_hf, - }; - } - off += sizeof(*src.rss->rss_conf); - if (src.rss->rss_conf->rss_key_len) { + if (src.rss->queue_num) { off = RTE_ALIGN_CEIL(off, sizeof(double)); - size = sizeof(*src.rss->rss_conf->rss_key) * - src.rss->rss_conf->rss_key_len; - if (dst.rss) { - ((struct rte_eth_rss_conf *)(uintptr_t) - dst.rss->rss_conf)->rss_key = - (void *)((uintptr_t)dst.rss + off); - memcpy(dst.rss->rss_conf->rss_key, - src.rss->rss_conf->rss_key, - size); - } + size = sizeof(*src.rss->queue) * src.rss->queue_num; + if (dst.rss) + dst.rss->queue = memcpy + ((void *)((uintptr_t)dst.rss + off), + src.rss->queue, size); off += size; } size = off; diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index acbeaacbd..cf252eeba 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -1301,6 +1301,12 @@ Action: ``RSS`` Similar to QUEUE, except RSS is additionally performed on packets to spread them among several queues according to the provided parameters. +Unlike global RSS settings used by other DPDK APIs, unsetting the ``types`` +field does not disable RSS in a flow rule. Doing so instead requests safe +unspecified "best-effort" settings from the underlying PMD, which depending +on the flow rule, may result in anything ranging from empty (single queue) +to all-inclusive RSS. + Note: RSS hash result is stored in the ``hash.rss`` mbuf field which overlaps ``hash.fdir.lo``. Since `Action: MARK`_ sets the ``hash.fdir.hi`` field only, both can be requested simultaneously. @@ -1309,15 +1315,19 @@ field only, both can be requested simultaneously. .. table:: RSS - +--------------+--------------------------------+ - | Field | Value | - +==============+================================+ - | ``rss_conf`` | RSS parameters | - +--------------+--------------------------------+ - | ``num`` | number of entries in ``queue`` | - +--------------+--------------------------------+ - | ``queue`` | queue indices to use | - +--------------+--------------------------------+ + +---------------+---------------------------------------------+ + | Field | Value | + +===============+=============================================+ + | ``types`` | specific RSS hash types (see ``ETH_RSS_*``) | + +---------------+---------------------------------------------+ + | ``key_len`` | hash key length in bytes | + +---------------+---------------------------------------------+ + | ``queue_num`` | number of entries in ``queue`` | + +---------------+---------------------------------------------+ + | ``key`` | hash key | + +---------------+---------------------------------------------+ + | ``queue`` | queue indices to use | + +---------------+---------------------------------------------+ Action: ``PF`` ^^^^^^^^^^^^^^ diff --git a/doc/guides/rel_notes/release_18_05.rst b/doc/guides/rel_notes/release_18_05.rst index ca173450c..b702ac66a 100644 --- a/doc/guides/rel_notes/release_18_05.rst +++ b/doc/guides/rel_notes/release_18_05.rst @@ -254,6 +254,13 @@ API Changes present. * C99-style flexible arrays were replaced with standard pointers in RSS action and in RAW pattern item structures due to compatibility issues. + * The RSS action was modified to not rely on external + ``struct rte_eth_rss_conf`` anymore to instead expose its own and more + appropriately named configuration fields directly + (``rss_conf->rss_key`` => ``key``, + ``rss_conf->rss_key_len`` => ``key_len``, + ``rss_conf->rss_hf`` => ``types``, + ``num`` => ``queue_num``). ABI Changes @@ -302,9 +309,9 @@ ABI Changes ``rte_flow_isolate``, ``rte_flow_query`` and ``rte_flow_validate``, due to changes in error type definitions (``enum rte_flow_error_type``), removal of the unused DUP action (``enum rte_flow_action_type``), modified - behavior for flow rule actions (see API changes) and removal of C99 - flexible arrays from RSS action (``struct rte_flow_action_rss``) and RAW - pattern item (``struct rte_flow_item_raw``). + behavior for flow rule actions (see API changes), removal of C99 flexible + array from RAW pattern item (``struct rte_flow_item_raw``) and complete + rework of the RSS action definition (``struct rte_flow_action_rss``). Removed Items diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index 68c286bd4..a12e0267a 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3422,8 +3422,10 @@ This section lists supported actions and their attributes, if any. - ``rss``: spread packets among several queues. - - ``types [{RSS hash type} [...]] end``: RSS hash types, allowed tokens - are the same as `set_hash_input_set`_, an empty list means none (0). + - ``types [{RSS hash type} [...]] end``: specific RSS hash types, allowed + tokens are the same as `set_hash_input_set`_, except that an empty list + does not disable RSS but instead requests unspecified "best-effort" + settings. - ``key {string}``: RSS hash key, overrides ``key_len``. diff --git a/drivers/net/e1000/e1000_ethdev.h b/drivers/net/e1000/e1000_ethdev.h index 6354b894a..902001f36 100644 --- a/drivers/net/e1000/e1000_ethdev.h +++ b/drivers/net/e1000/e1000_ethdev.h @@ -4,6 +4,10 @@ #ifndef _E1000_ETHDEV_H_ #define _E1000_ETHDEV_H_ + +#include <stdint.h> + +#include <rte_flow.h> #include <rte_time.h> #include <rte_pci.h> @@ -27,6 +31,7 @@ #define E1000_CTRL_EXT_EXTEND_VLAN (1<<26) /* EXTENDED VLAN */ #define IGB_VFTA_SIZE 128 +#define IGB_HKEY_MAX_INDEX 10 #define IGB_MAX_RX_QUEUE_NUM 8 #define IGB_MAX_RX_QUEUE_NUM_82576 16 @@ -229,8 +234,8 @@ struct igb_ethertype_filter { }; struct igb_rte_flow_rss_conf { - struct rte_eth_rss_conf rss_conf; /**< RSS parameters. */ - uint16_t num; /**< Number of entries in queue[]. */ + struct rte_flow_action_rss conf; /**< RSS parameters. */ + uint8_t key[IGB_HKEY_MAX_INDEX * sizeof(uint32_t)]; /* Hash key. */ uint16_t queue[IGB_MAX_RX_QUEUE_NUM]; /**< Queues indices to use. */ }; @@ -501,6 +506,10 @@ int eth_igb_syn_filter_set(struct rte_eth_dev *dev, int eth_igb_add_del_flex_filter(struct rte_eth_dev *dev, struct rte_eth_flex_filter *filter, bool add); +int igb_rss_conf_init(struct igb_rte_flow_rss_conf *out, + const struct rte_flow_action_rss *in); +int igb_action_rss_same(const struct rte_flow_action_rss *comp, + const struct rte_flow_action_rss *with); int igb_config_rss_filter(struct rte_eth_dev *dev, struct igb_rte_flow_rss_conf *conf, bool add); diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c index c35c9352a..140334772 100644 --- a/drivers/net/e1000/igb_ethdev.c +++ b/drivers/net/e1000/igb_ethdev.c @@ -41,8 +41,6 @@ #define IGB_DEFAULT_TX_HTHRESH 1 #define IGB_DEFAULT_TX_WTHRESH ((hw->mac.type == e1000_82576) ? 1 : 16) -#define IGB_HKEY_MAX_INDEX 10 - /* Bit shift and mask */ #define IGB_4_BIT_WIDTH (CHAR_BIT / 2) #define IGB_4_BIT_MASK RTE_LEN2MASK(IGB_4_BIT_WIDTH, uint8_t) @@ -5662,7 +5660,7 @@ igb_rss_filter_restore(struct rte_eth_dev *dev) struct e1000_filter_info *filter_info = E1000_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private); - if (filter_info->rss_info.num) + if (filter_info->rss_info.conf.queue_num) igb_config_rss_filter(dev, &filter_info->rss_info, TRUE); } diff --git a/drivers/net/e1000/igb_flow.c b/drivers/net/e1000/igb_flow.c index c0f5b5190..8dc5f75f2 100644 --- a/drivers/net/e1000/igb_flow.c +++ b/drivers/net/e1000/igb_flow.c @@ -1292,7 +1292,7 @@ igb_parse_rss_filter(struct rte_eth_dev *dev, rss = (const struct rte_flow_action_rss *)act->conf; - if (!rss || !rss->num) { + if (!rss || !rss->queue_num) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, act, @@ -1300,7 +1300,7 @@ igb_parse_rss_filter(struct rte_eth_dev *dev, return -rte_errno; } - for (n = 0; n < rss->num; n++) { + for (n = 0; n < rss->queue_num; n++) { if (rss->queue[n] >= dev->data->nb_rx_queues) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, @@ -1310,14 +1310,18 @@ igb_parse_rss_filter(struct rte_eth_dev *dev, } } - if (rss->rss_conf) - rss_conf->rss_conf = *rss->rss_conf; - else - rss_conf->rss_conf.rss_hf = IGB_RSS_OFFLOAD_ALL; - - for (n = 0; n < rss->num; ++n) - rss_conf->queue[n] = rss->queue[n]; - rss_conf->num = rss->num; + if (rss->key_len && rss->key_len != RTE_DIM(rss_conf->key)) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, + "RSS hash key must be exactly 40 bytes"); + if (rss->queue_num > RTE_DIM(rss_conf->queue)) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, + "too many queues for RSS context"); + if (igb_rss_conf_init(rss_conf, rss)) + return rte_flow_error_set + (error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, act, + "RSS context initialization failure"); /* check if the next not void item is END */ index++; @@ -1518,9 +1522,8 @@ igb_flow_create(struct rte_eth_dev *dev, PMD_DRV_LOG(ERR, "failed to allocate memory"); goto out; } - rte_memcpy(&rss_filter_ptr->filter_info, - &rss_conf, - sizeof(struct igb_rte_flow_rss_conf)); + igb_rss_conf_init(&rss_filter_ptr->filter_info, + &rss_conf.conf); TAILQ_INSERT_TAIL(&igb_filter_rss_list, rss_filter_ptr, entries); flow->rule = rss_filter_ptr; @@ -1757,7 +1760,7 @@ igb_clear_rss_filter(struct rte_eth_dev *dev) struct e1000_filter_info *filter = E1000_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private); - if (filter->rss_info.num) + if (filter->rss_info.conf.queue_num) igb_config_rss_filter(dev, &filter->rss_info, FALSE); } diff --git a/drivers/net/e1000/igb_rxtx.c b/drivers/net/e1000/igb_rxtx.c index 323913f0d..45bb3455c 100644 --- a/drivers/net/e1000/igb_rxtx.c +++ b/drivers/net/e1000/igb_rxtx.c @@ -2898,12 +2898,47 @@ igb_txq_info_get(struct rte_eth_dev *dev, uint16_t queue_id, } int +igb_rss_conf_init(struct igb_rte_flow_rss_conf *out, + const struct rte_flow_action_rss *in) +{ + if (in->key_len > RTE_DIM(out->key) || + in->queue_num > RTE_DIM(out->queue)) + return -EINVAL; + out->conf = (struct rte_flow_action_rss){ + .types = in->types, + .key_len = in->key_len, + .queue_num = in->queue_num, + .key = memcpy(out->key, in->key, in->key_len), + .queue = memcpy(out->queue, in->queue, + sizeof(*in->queue) * in->queue_num), + }; + return 0; +} + +int +igb_action_rss_same(const struct rte_flow_action_rss *comp, + const struct rte_flow_action_rss *with) +{ + return (comp->types == with->types && + comp->key_len == with->key_len && + comp->queue_num == with->queue_num && + !memcmp(comp->key, with->key, with->key_len) && + !memcmp(comp->queue, with->queue, + sizeof(*with->queue) * with->queue_num)); +} + +int igb_config_rss_filter(struct rte_eth_dev *dev, struct igb_rte_flow_rss_conf *conf, bool add) { uint32_t shift; uint16_t i, j; - struct rte_eth_rss_conf rss_conf = conf->rss_conf; + struct rte_eth_rss_conf rss_conf = { + .rss_key = conf->conf.key_len ? + (void *)(uintptr_t)conf->conf.key : NULL, + .rss_key_len = conf->conf.key_len, + .rss_hf = conf->conf.types, + }; struct e1000_filter_info *filter_info = E1000_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private); struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private); @@ -2911,8 +2946,8 @@ igb_config_rss_filter(struct rte_eth_dev *dev, hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private); if (!add) { - if (memcmp(conf, &filter_info->rss_info, - sizeof(struct igb_rte_flow_rss_conf)) == 0) { + if (igb_action_rss_same(&filter_info->rss_info.conf, + &conf->conf)) { igb_rss_disable(dev); memset(&filter_info->rss_info, 0, sizeof(struct igb_rte_flow_rss_conf)); @@ -2921,7 +2956,7 @@ igb_config_rss_filter(struct rte_eth_dev *dev, return -EINVAL; } - if (filter_info->rss_info.num) + if (filter_info->rss_info.conf.queue_num) return -EINVAL; /* Fill in redirection table. */ @@ -2933,9 +2968,9 @@ igb_config_rss_filter(struct rte_eth_dev *dev, } reta; uint8_t q_idx; - if (j == conf->num) + if (j == conf->conf.queue_num) j = 0; - q_idx = conf->queue[j]; + q_idx = conf->conf.queue[j]; reta.bytes[i & 3] = (uint8_t)(q_idx << shift); if ((i & 3) == 3) E1000_WRITE_REG(hw, E1000_RETA(i >> 2), reta.dword); @@ -2952,8 +2987,8 @@ igb_config_rss_filter(struct rte_eth_dev *dev, rss_conf.rss_key = rss_intel_key; /* Default hash key */ igb_hw_rss_hash_set(hw, &rss_conf); - rte_memcpy(&filter_info->rss_info, - conf, sizeof(struct igb_rte_flow_rss_conf)); + if (igb_rss_conf_init(&filter_info->rss_info, &conf->conf)) + return -EINVAL; return 0; } diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index 78f2be7da..50e77901c 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c @@ -11,6 +11,7 @@ #include <inttypes.h> #include <assert.h> +#include <rte_common.h> #include <rte_eal.h> #include <rte_string_fns.h> #include <rte_pci.h> @@ -11650,7 +11651,7 @@ i40e_rss_filter_restore(struct i40e_pf *pf) { struct i40e_rte_flow_rss_conf *conf = &pf->rss_info; - if (conf->num) + if (conf->conf.queue_num) i40e_config_rss_filter(pf, conf, TRUE); } @@ -12182,18 +12183,52 @@ i40e_cloud_filter_qinq_create(struct i40e_pf *pf) } int +i40e_rss_conf_init(struct i40e_rte_flow_rss_conf *out, + const struct rte_flow_action_rss *in) +{ + if (in->key_len > RTE_DIM(out->key) || + in->queue_num > RTE_DIM(out->queue)) + return -EINVAL; + out->conf = (struct rte_flow_action_rss){ + .types = in->types, + .key_len = in->key_len, + .queue_num = in->queue_num, + .key = memcpy(out->key, in->key, in->key_len), + .queue = memcpy(out->queue, in->queue, + sizeof(*in->queue) * in->queue_num), + }; + return 0; +} + +int +i40e_action_rss_same(const struct rte_flow_action_rss *comp, + const struct rte_flow_action_rss *with) +{ + return (comp->types == with->types && + comp->key_len == with->key_len && + comp->queue_num == with->queue_num && + !memcmp(comp->key, with->key, with->key_len) && + !memcmp(comp->queue, with->queue, + sizeof(*with->queue) * with->queue_num)); +} + +int i40e_config_rss_filter(struct i40e_pf *pf, struct i40e_rte_flow_rss_conf *conf, bool add) { struct i40e_hw *hw = I40E_PF_TO_HW(pf); uint32_t i, lut = 0; uint16_t j, num; - struct rte_eth_rss_conf rss_conf = conf->rss_conf; + struct rte_eth_rss_conf rss_conf = { + .rss_key = conf->conf.key_len ? + (void *)(uintptr_t)conf->conf.key : NULL, + .rss_key_len = conf->conf.key_len, + .rss_hf = conf->conf.types, + }; struct i40e_rte_flow_rss_conf *rss_info = &pf->rss_info; if (!add) { - if (memcmp(conf, rss_info, - sizeof(struct i40e_rte_flow_rss_conf)) == 0) { + if (i40e_action_rss_same(&rss_info->conf, &conf->conf)) { i40e_pf_disable_rss(pf); memset(rss_info, 0, sizeof(struct i40e_rte_flow_rss_conf)); @@ -12202,7 +12237,7 @@ i40e_config_rss_filter(struct i40e_pf *pf, return -EINVAL; } - if (rss_info->num) + if (rss_info->conf.queue_num) return -EINVAL; /* If both VMDQ and RSS enabled, not all of PF queues are configured. @@ -12213,7 +12248,7 @@ i40e_config_rss_filter(struct i40e_pf *pf, else num = pf->dev_data->nb_rx_queues; - num = RTE_MIN(num, conf->num); + num = RTE_MIN(num, conf->conf.queue_num); PMD_DRV_LOG(INFO, "Max of contiguous %u PF queues are configured", num); @@ -12226,7 +12261,7 @@ i40e_config_rss_filter(struct i40e_pf *pf, for (i = 0, j = 0; i < hw->func_caps.rss_table_size; i++, j++) { if (j == num) j = 0; - lut = (lut << 8) | (conf->queue[j] & ((0x1 << + lut = (lut << 8) | (conf->conf.queue[j] & ((0x1 << hw->func_caps.rss_table_entry_width) - 1)); if ((i & 3) == 3) I40E_WRITE_REG(hw, I40E_PFQF_HLUT(i >> 2), lut); @@ -12251,8 +12286,8 @@ i40e_config_rss_filter(struct i40e_pf *pf, i40e_hw_rss_hash_set(pf, &rss_conf); - rte_memcpy(rss_info, - conf, sizeof(struct i40e_rte_flow_rss_conf)); + if (i40e_rss_conf_init(rss_info, &conf->conf)) + return -EINVAL; return 0; } diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h index d33b255e7..a0569d4ae 100644 --- a/drivers/net/i40e/i40e_ethdev.h +++ b/drivers/net/i40e/i40e_ethdev.h @@ -5,14 +5,19 @@ #ifndef _I40E_ETHDEV_H_ #define _I40E_ETHDEV_H_ +#include <stdint.h> + #include <rte_eth_ctrl.h> #include <rte_time.h> #include <rte_kvargs.h> #include <rte_hash.h> +#include <rte_flow.h> #include <rte_flow_driver.h> #include <rte_tm_driver.h> #include "rte_pmd_i40e.h" +#include "base/i40e_register.h" + #define I40E_VLAN_TAG_SIZE 4 #define I40E_AQ_LEN 32 @@ -878,9 +883,11 @@ struct i40e_customized_pctype { }; struct i40e_rte_flow_rss_conf { - struct rte_eth_rss_conf rss_conf; /**< RSS parameters. */ + struct rte_flow_action_rss conf; /**< RSS parameters. */ uint16_t queue_region_conf; /**< Queue region config flag */ - uint16_t num; /**< Number of entries in queue[]. */ + uint8_t key[(I40E_VFQF_HKEY_MAX_INDEX > I40E_PFQF_HKEY_MAX_INDEX ? + I40E_VFQF_HKEY_MAX_INDEX : I40E_PFQF_HKEY_MAX_INDEX) + 1 * + sizeof(uint32_t)]; /* Hash key. */ uint16_t queue[I40E_MAX_Q_PER_TC]; /**< Queues indices to use. */ }; @@ -1219,6 +1226,10 @@ void i40e_init_queue_region_conf(struct rte_eth_dev *dev); void i40e_flex_payload_reg_set_default(struct i40e_hw *hw); int i40e_set_rss_key(struct i40e_vsi *vsi, uint8_t *key, uint8_t key_len); int i40e_set_rss_lut(struct i40e_vsi *vsi, uint8_t *lut, uint16_t lut_size); +int i40e_rss_conf_init(struct i40e_rte_flow_rss_conf *out, + const struct rte_flow_action_rss *in); +int i40e_action_rss_same(const struct rte_flow_action_rss *comp, + const struct rte_flow_action_rss *with); int i40e_config_rss_filter(struct i40e_pf *pf, struct i40e_rte_flow_rss_conf *conf, bool add); diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c index d6f5e9923..ec6231003 100644 --- a/drivers/net/i40e/i40e_flow.c +++ b/drivers/net/i40e/i40e_flow.c @@ -4220,7 +4220,7 @@ i40e_flow_parse_rss_action(struct rte_eth_dev *dev, if (action_flag) { for (n = 0; n < 64; n++) { - if (rss->rss_conf->rss_hf & (hf_bit << n)) { + if (rss->types & (hf_bit << n)) { conf_info->region[0].hw_flowtype[0] = n; conf_info->region[0].flowtype_num = 1; conf_info->queue_region_number = 1; @@ -4236,12 +4236,12 @@ i40e_flow_parse_rss_action(struct rte_eth_dev *dev, * queue index for this port. */ if (conf_info->queue_region_number) { - for (i = 0; i < rss->num; i++) { - for (j = 0; j < rss_info->num; j++) { - if (rss->queue[i] == rss_info->queue[j]) + for (i = 0; i < rss->queue_num; i++) { + for (j = 0; j < rss_info->conf.queue_num; j++) { + if (rss->queue[i] == rss_info->conf.queue[j]) break; } - if (j == rss_info->num) { + if (j == rss_info->conf.queue_num) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, act, @@ -4250,7 +4250,7 @@ i40e_flow_parse_rss_action(struct rte_eth_dev *dev, } } - for (i = 0; i < rss->num - 1; i++) { + for (i = 0; i < rss->queue_num - 1; i++) { if (rss->queue[i + 1] != rss->queue[i] + 1) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, @@ -4265,8 +4265,8 @@ i40e_flow_parse_rss_action(struct rte_eth_dev *dev, for (n = 0; n < conf_info->queue_region_number; n++) { if (conf_info->region[n].user_priority_num || conf_info->region[n].flowtype_num) { - if (!((rte_is_power_of_2(rss->num)) && - rss->num <= 64)) { + if (!((rte_is_power_of_2(rss->queue_num)) && + rss->queue_num <= 64)) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, act, @@ -4294,7 +4294,8 @@ i40e_flow_parse_rss_action(struct rte_eth_dev *dev, } for (i = 0; i < info->queue_region_number; i++) { - if (info->region[i].queue_num == rss->num && + if (info->region[i].queue_num == + rss->queue_num && info->region[i].queue_start_index == rss->queue[0]) break; @@ -4310,7 +4311,7 @@ i40e_flow_parse_rss_action(struct rte_eth_dev *dev, } info->region[i].queue_num = - rss->num; + rss->queue_num; info->region[i].queue_start_index = rss->queue[0]; info->region[i].region_id = @@ -4356,7 +4357,7 @@ i40e_flow_parse_rss_action(struct rte_eth_dev *dev, if (rss_config->queue_region_conf) return 0; - if (!rss || !rss->num) { + if (!rss || !rss->queue_num) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, act, @@ -4364,7 +4365,7 @@ i40e_flow_parse_rss_action(struct rte_eth_dev *dev, return -rte_errno; } - for (n = 0; n < rss->num; n++) { + for (n = 0; n < rss->queue_num; n++) { if (rss->queue[n] >= dev->data->nb_rx_queues) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, @@ -4375,15 +4376,19 @@ i40e_flow_parse_rss_action(struct rte_eth_dev *dev, } /* Parse RSS related parameters from configuration */ - if (rss->rss_conf) - rss_config->rss_conf = *rss->rss_conf; - else - rss_config->rss_conf.rss_hf = - pf->adapter->flow_types_mask; + if (rss->key_len && rss->key_len > RTE_DIM(rss_config->key)) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, + "RSS hash key too large"); + if (rss->queue_num > RTE_DIM(rss_config->queue)) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, + "too many queues for RSS context"); + if (i40e_rss_conf_init(rss_config, rss)) + return rte_flow_error_set + (error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, act, + "RSS context initialization failure"); - for (n = 0; n < rss->num; ++n) - rss_config->queue[n] = rss->queue[n]; - rss_config->num = rss->num; index++; /* check if the next not void action is END */ @@ -4903,7 +4908,7 @@ i40e_flow_flush_rss_filter(struct rte_eth_dev *dev) ret = i40e_flush_queue_region_all_conf(dev, hw, pf, 0); - if (rss_info->num) + if (rss_info->conf.queue_num) ret = i40e_config_rss_filter(pf, rss_info, FALSE); return ret; } diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c index 92434809c..c00bdae3d 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.c +++ b/drivers/net/ixgbe/ixgbe_ethdev.c @@ -100,8 +100,6 @@ #define IXGBE_QUEUE_STAT_COUNTERS (sizeof(hw_stats->qprc) / sizeof(hw_stats->qprc[0])) -#define IXGBE_HKEY_MAX_INDEX 10 - /* Additional timesync values. */ #define NSEC_PER_SEC 1000000000L #define IXGBE_INCVAL_10GB 0x66666666 @@ -8371,7 +8369,7 @@ ixgbe_rss_filter_restore(struct rte_eth_dev *dev) struct ixgbe_filter_info *filter_info = IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private); - if (filter_info->rss_info.num) + if (filter_info->rss_info.conf.queue_num) ixgbe_config_rss_filter(dev, &filter_info->rss_info, TRUE); } diff --git a/drivers/net/ixgbe/ixgbe_ethdev.h b/drivers/net/ixgbe/ixgbe_ethdev.h index 655077700..9491b03f4 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.h +++ b/drivers/net/ixgbe/ixgbe_ethdev.h @@ -4,6 +4,9 @@ #ifndef _IXGBE_ETHDEV_H_ #define _IXGBE_ETHDEV_H_ + +#include <stdint.h> + #include "base/ixgbe_type.h" #include "base/ixgbe_dcb.h" #include "base/ixgbe_dcb_82599.h" @@ -12,6 +15,7 @@ #ifdef RTE_LIBRTE_SECURITY #include "ixgbe_ipsec.h" #endif +#include <rte_flow.h> #include <rte_time.h> #include <rte_hash.h> #include <rte_pci.h> @@ -39,6 +43,7 @@ #define IXGBE_EXTENDED_VLAN (uint32_t)(1 << 26) /* EXTENDED VLAN ENABLE */ #define IXGBE_VFTA_SIZE 128 #define IXGBE_VLAN_TAG_SIZE 4 +#define IXGBE_HKEY_MAX_INDEX 10 #define IXGBE_MAX_RX_QUEUE_NUM 128 #define IXGBE_MAX_INTR_QUEUE_NUM 15 #define IXGBE_VMDQ_DCB_NB_QUEUES IXGBE_MAX_RX_QUEUE_NUM @@ -196,8 +201,8 @@ struct ixgbe_hw_fdir_info { }; struct ixgbe_rte_flow_rss_conf { - struct rte_eth_rss_conf rss_conf; /**< RSS parameters. */ - uint16_t num; /**< Number of entries in queue[]. */ + struct rte_flow_action_rss conf; /**< RSS parameters. */ + uint8_t key[IXGBE_HKEY_MAX_INDEX * sizeof(uint32_t)]; /* Hash key. */ uint16_t queue[IXGBE_MAX_RX_QUEUE_NUM]; /**< Queues indices to use. */ }; @@ -696,6 +701,10 @@ void ixgbe_tm_conf_init(struct rte_eth_dev *dev); void ixgbe_tm_conf_uninit(struct rte_eth_dev *dev); int ixgbe_set_queue_rate_limit(struct rte_eth_dev *dev, uint16_t queue_idx, uint16_t tx_rate); +int ixgbe_rss_conf_init(struct ixgbe_rte_flow_rss_conf *out, + const struct rte_flow_action_rss *in); +int ixgbe_action_rss_same(const struct rte_flow_action_rss *comp, + const struct rte_flow_action_rss *with); int ixgbe_config_rss_filter(struct rte_eth_dev *dev, struct ixgbe_rte_flow_rss_conf *conf, bool add); diff --git a/drivers/net/ixgbe/ixgbe_flow.c b/drivers/net/ixgbe/ixgbe_flow.c index abdeac28b..4e31c7c56 100644 --- a/drivers/net/ixgbe/ixgbe_flow.c +++ b/drivers/net/ixgbe/ixgbe_flow.c @@ -2761,7 +2761,7 @@ ixgbe_parse_rss_filter(struct rte_eth_dev *dev, rss = (const struct rte_flow_action_rss *)act->conf; - if (!rss || !rss->num) { + if (!rss || !rss->queue_num) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, act, @@ -2769,7 +2769,7 @@ ixgbe_parse_rss_filter(struct rte_eth_dev *dev, return -rte_errno; } - for (n = 0; n < rss->num; n++) { + for (n = 0; n < rss->queue_num; n++) { if (rss->queue[n] >= dev->data->nb_rx_queues) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, @@ -2778,14 +2778,19 @@ ixgbe_parse_rss_filter(struct rte_eth_dev *dev, return -rte_errno; } } - if (rss->rss_conf) - rss_conf->rss_conf = *rss->rss_conf; - else - rss_conf->rss_conf.rss_hf = IXGBE_RSS_OFFLOAD_ALL; - for (n = 0; n < rss->num; ++n) - rss_conf->queue[n] = rss->queue[n]; - rss_conf->num = rss->num; + if (rss->key_len && rss->key_len != RTE_DIM(rss_conf->key)) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, + "RSS hash key must be exactly 40 bytes"); + if (rss->queue_num > RTE_DIM(rss_conf->queue)) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, + "too many queues for RSS context"); + if (ixgbe_rss_conf_init(rss_conf, rss)) + return rte_flow_error_set + (error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, act, + "RSS context initialization failure"); /* check if the next not void item is END */ act = next_no_void_action(actions, act); @@ -2834,7 +2839,7 @@ ixgbe_clear_rss_filter(struct rte_eth_dev *dev) struct ixgbe_filter_info *filter_info = IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private); - if (filter_info->rss_info.num) + if (filter_info->rss_info.conf.queue_num) ixgbe_config_rss_filter(dev, &filter_info->rss_info, FALSE); } @@ -3153,9 +3158,8 @@ ixgbe_flow_create(struct rte_eth_dev *dev, PMD_DRV_LOG(ERR, "failed to allocate memory"); goto out; } - rte_memcpy(&rss_filter_ptr->filter_info, - &rss_conf, - sizeof(struct ixgbe_rte_flow_rss_conf)); + ixgbe_rss_conf_init(&rss_filter_ptr->filter_info, + &rss_conf.conf); TAILQ_INSERT_TAIL(&filter_rss_list, rss_filter_ptr, entries); flow->rule = rss_filter_ptr; diff --git a/drivers/net/ixgbe/ixgbe_rxtx.c b/drivers/net/ixgbe/ixgbe_rxtx.c index aed3f5a9a..9fbd7dbd7 100644 --- a/drivers/net/ixgbe/ixgbe_rxtx.c +++ b/drivers/net/ixgbe/ixgbe_rxtx.c @@ -5676,6 +5676,36 @@ ixgbevf_dev_rxtx_start(struct rte_eth_dev *dev) } int +ixgbe_rss_conf_init(struct ixgbe_rte_flow_rss_conf *out, + const struct rte_flow_action_rss *in) +{ + if (in->key_len > RTE_DIM(out->key) || + in->queue_num > RTE_DIM(out->queue)) + return -EINVAL; + out->conf = (struct rte_flow_action_rss){ + .types = in->types, + .key_len = in->key_len, + .queue_num = in->queue_num, + .key = memcpy(out->key, in->key, in->key_len), + .queue = memcpy(out->queue, in->queue, + sizeof(*in->queue) * in->queue_num), + }; + return 0; +} + +int +ixgbe_action_rss_same(const struct rte_flow_action_rss *comp, + const struct rte_flow_action_rss *with) +{ + return (comp->types == with->types && + comp->key_len == with->key_len && + comp->queue_num == with->queue_num && + !memcmp(comp->key, with->key, with->key_len) && + !memcmp(comp->queue, with->queue, + sizeof(*with->queue) * with->queue_num)); +} + +int ixgbe_config_rss_filter(struct rte_eth_dev *dev, struct ixgbe_rte_flow_rss_conf *conf, bool add) { @@ -5685,7 +5715,12 @@ ixgbe_config_rss_filter(struct rte_eth_dev *dev, uint16_t j; uint16_t sp_reta_size; uint32_t reta_reg; - struct rte_eth_rss_conf rss_conf = conf->rss_conf; + struct rte_eth_rss_conf rss_conf = { + .rss_key = conf->conf.key_len ? + (void *)(uintptr_t)conf->conf.key : NULL, + .rss_key_len = conf->conf.key_len, + .rss_hf = conf->conf.types, + }; struct ixgbe_filter_info *filter_info = IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private); @@ -5695,8 +5730,8 @@ ixgbe_config_rss_filter(struct rte_eth_dev *dev, sp_reta_size = ixgbe_reta_size_get(hw->mac.type); if (!add) { - if (memcmp(conf, &filter_info->rss_info, - sizeof(struct ixgbe_rte_flow_rss_conf)) == 0) { + if (ixgbe_action_rss_same(&filter_info->rss_info.conf, + &conf->conf)) { ixgbe_rss_disable(dev); memset(&filter_info->rss_info, 0, sizeof(struct ixgbe_rte_flow_rss_conf)); @@ -5705,7 +5740,7 @@ ixgbe_config_rss_filter(struct rte_eth_dev *dev, return -EINVAL; } - if (filter_info->rss_info.num) + if (filter_info->rss_info.conf.queue_num) return -EINVAL; /* Fill in redirection table * The byte-swap is needed because NIC registers are in @@ -5715,9 +5750,9 @@ ixgbe_config_rss_filter(struct rte_eth_dev *dev, for (i = 0, j = 0; i < sp_reta_size; i++, j++) { reta_reg = ixgbe_reta_reg_get(hw->mac.type, i); - if (j == conf->num) + if (j == conf->conf.queue_num) j = 0; - reta = (reta << 8) | conf->queue[j]; + reta = (reta << 8) | conf->conf.queue[j]; if ((i & 3) == 3) IXGBE_WRITE_REG(hw, reta_reg, rte_bswap32(reta)); @@ -5734,8 +5769,8 @@ ixgbe_config_rss_filter(struct rte_eth_dev *dev, rss_conf.rss_key = rss_intel_key; /* Default hash key */ ixgbe_hw_rss_hash_set(hw, &rss_conf); - rte_memcpy(&filter_info->rss_info, - conf, sizeof(struct ixgbe_rte_flow_rss_conf)); + if (ixgbe_rss_conf_init(&filter_info->rss_info, &conf->conf)) + return -EINVAL; return 0; } diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c index 937074a4f..3dd72dbf5 100644 --- a/drivers/net/mlx4/mlx4.c +++ b/drivers/net/mlx4/mlx4.c @@ -571,7 +571,7 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev) " for UDP RSS and inner VXLAN RSS"); /* Fake support for all possible RSS hash fields. */ priv->hw_rss_sup = ~UINT64_C(0); - priv->hw_rss_sup = mlx4_conv_rss_hf(priv, -1); + priv->hw_rss_sup = mlx4_conv_rss_types(priv, -1); /* Filter out known unsupported fields. */ priv->hw_rss_sup &= ~(uint64_t)(IBV_RX_HASH_SRC_PORT_UDP | diff --git a/drivers/net/mlx4/mlx4_flow.c b/drivers/net/mlx4/mlx4_flow.c index 8feb6ae31..dd86e4ce7 100644 --- a/drivers/net/mlx4/mlx4_flow.c +++ b/drivers/net/mlx4/mlx4_flow.c @@ -76,22 +76,22 @@ struct mlx4_drop { }; /** - * Convert DPDK RSS hash fields to their Verbs equivalent. + * Convert DPDK RSS hash types to their Verbs equivalent. * - * This function returns the supported (default) set when @p rss_hf has + * This function returns the supported (default) set when @p types has * special value (uint64_t)-1. * * @param priv * Pointer to private structure. - * @param rss_hf - * Hash fields in DPDK format (see struct rte_eth_rss_conf). + * @param types + * Hash types in DPDK format (see struct rte_eth_rss_conf). * * @return * A valid Verbs RSS hash fields mask for mlx4 on success, (uint64_t)-1 * otherwise and rte_errno is set. */ uint64_t -mlx4_conv_rss_hf(struct priv *priv, uint64_t rss_hf) +mlx4_conv_rss_types(struct priv *priv, uint64_t types) { enum { IPV4, IPV6, TCP, UDP, }; const uint64_t in[] = { @@ -126,17 +126,17 @@ mlx4_conv_rss_hf(struct priv *priv, uint64_t rss_hf) unsigned int i; for (i = 0; i != RTE_DIM(in); ++i) - if (rss_hf & in[i]) { - seen |= rss_hf & in[i]; + if (types & in[i]) { + seen |= types & in[i]; conv |= out[i]; } if ((conv & priv->hw_rss_sup) == conv) { - if (rss_hf == (uint64_t)-1) { + if (types == (uint64_t)-1) { /* Include inner RSS by default if supported. */ conv |= priv->hw_rss_sup & IBV_RX_HASH_INNER; return conv; } - if (!(rss_hf & ~seen)) + if (!(types & ~seen)) return conv; } rte_errno = ENOTSUP; @@ -717,7 +717,8 @@ mlx4_flow_prepare(struct priv *priv, switch (action->type) { const struct rte_flow_action_queue *queue; const struct rte_flow_action_rss *rss; - const struct rte_eth_rss_conf *rss_conf; + const uint8_t *rss_key; + uint32_t rss_key_len; uint64_t fields; unsigned int i; @@ -747,58 +748,56 @@ mlx4_flow_prepare(struct priv *priv, break; rss = action->conf; /* Default RSS configuration if none is provided. */ - rss_conf = - rss->rss_conf ? - rss->rss_conf : - &(struct rte_eth_rss_conf){ - .rss_key = mlx4_rss_hash_key_default, - .rss_key_len = MLX4_RSS_HASH_KEY_SIZE, - .rss_hf = -1, - }; + if (rss->key_len) { + rss_key = rss->key; + rss_key_len = rss->key_len; + } else { + rss_key = mlx4_rss_hash_key_default; + rss_key_len = MLX4_RSS_HASH_KEY_SIZE; + } /* Sanity checks. */ - for (i = 0; i < rss->num; ++i) + for (i = 0; i < rss->queue_num; ++i) if (rss->queue[i] >= priv->dev->data->nb_rx_queues) break; - if (i != rss->num) { + if (i != rss->queue_num) { msg = "queue index target beyond number of" " configured Rx queues"; goto exit_action_not_supported; } - if (!rte_is_power_of_2(rss->num)) { + if (!rte_is_power_of_2(rss->queue_num)) { msg = "for RSS, mlx4 requires the number of" " queues to be a power of two"; goto exit_action_not_supported; } - if (rss_conf->rss_key_len != - sizeof(flow->rss->key)) { + if (rss_key_len != sizeof(flow->rss->key)) { msg = "mlx4 supports exactly one RSS hash key" " length: " MLX4_STR_EXPAND(MLX4_RSS_HASH_KEY_SIZE); goto exit_action_not_supported; } - for (i = 1; i < rss->num; ++i) + for (i = 1; i < rss->queue_num; ++i) if (rss->queue[i] - rss->queue[i - 1] != 1) break; - if (i != rss->num) { + if (i != rss->queue_num) { msg = "mlx4 requires RSS contexts to use" " consecutive queue indices only"; goto exit_action_not_supported; } - if (rss->queue[0] % rss->num) { + if (rss->queue[0] % rss->queue_num) { msg = "mlx4 requires the first queue of a RSS" " context to be aligned on a multiple" " of the context size"; goto exit_action_not_supported; } rte_errno = 0; - fields = mlx4_conv_rss_hf(priv, rss_conf->rss_hf); + fields = mlx4_conv_rss_types(priv, rss->types); if (fields == (uint64_t)-1 && rte_errno) { msg = "unsupported RSS hash type requested"; goto exit_action_not_supported; } flow->rss = mlx4_rss_get - (priv, fields, rss_conf->rss_key, rss->num, + (priv, fields, rss_key, rss->queue_num, rss->queue); if (!flow->rss) { msg = "either invalid parameters or not enough" @@ -1284,8 +1283,10 @@ mlx4_flow_internal(struct priv *priv, struct rte_flow_error *error) rte_align32pow2(priv->dev->data->nb_rx_queues + 1) >> 1; uint16_t queue[queues]; struct rte_flow_action_rss action_rss = { - .rss_conf = NULL, /* Rely on default fallback settings. */ - .num = queues, + .types = -1, + .key_len = MLX4_RSS_HASH_KEY_SIZE, + .queue_num = queues, + .key = mlx4_rss_hash_key_default, .queue = queue, }; struct rte_flow_action actions[] = { diff --git a/drivers/net/mlx4/mlx4_flow.h b/drivers/net/mlx4/mlx4_flow.h index 4e3889e67..7b83d74b0 100644 --- a/drivers/net/mlx4/mlx4_flow.h +++ b/drivers/net/mlx4/mlx4_flow.h @@ -47,7 +47,7 @@ struct rte_flow { /* mlx4_flow.c */ -uint64_t mlx4_conv_rss_hf(struct priv *priv, uint64_t rss_hf); +uint64_t mlx4_conv_rss_types(struct priv *priv, uint64_t rss_hf); int mlx4_flow_sync(struct priv *priv, struct rte_flow_error *error); void mlx4_flow_clean(struct priv *priv); int mlx4_filter_ctrl(struct rte_eth_dev *dev, diff --git a/drivers/net/mlx4/mlx4_rxq.c b/drivers/net/mlx4/mlx4_rxq.c index a7acc047b..65f099423 100644 --- a/drivers/net/mlx4/mlx4_rxq.c +++ b/drivers/net/mlx4/mlx4_rxq.c @@ -88,7 +88,7 @@ mlx4_rss_hash_key_default[MLX4_RSS_HASH_KEY_SIZE] = { */ struct mlx4_rss * mlx4_rss_get(struct priv *priv, uint64_t fields, - uint8_t key[MLX4_RSS_HASH_KEY_SIZE], + const uint8_t key[MLX4_RSS_HASH_KEY_SIZE], uint16_t queues, const uint16_t queue_id[]) { struct mlx4_rss *rss; diff --git a/drivers/net/mlx4/mlx4_rxtx.h b/drivers/net/mlx4/mlx4_rxtx.h index b1af86110..2dfee957f 100644 --- a/drivers/net/mlx4/mlx4_rxtx.h +++ b/drivers/net/mlx4/mlx4_rxtx.h @@ -127,7 +127,7 @@ uint8_t mlx4_rss_hash_key_default[MLX4_RSS_HASH_KEY_SIZE]; int mlx4_rss_init(struct priv *priv); void mlx4_rss_deinit(struct priv *priv); struct mlx4_rss *mlx4_rss_get(struct priv *priv, uint64_t fields, - uint8_t key[MLX4_RSS_HASH_KEY_SIZE], + const uint8_t key[MLX4_RSS_HASH_KEY_SIZE], uint16_t queues, const uint16_t queue_id[]); void mlx4_rss_put(struct mlx4_rss *rss); int mlx4_rss_attach(struct mlx4_rss *rss); diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 0c89bff45..af8853e09 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -214,9 +214,8 @@ struct rte_flow { TAILQ_ENTRY(rte_flow) next; /**< Pointer to the next flow structure. */ uint32_t mark:1; /**< Set if the flow is marked. */ uint32_t drop:1; /**< Drop queue. */ - uint16_t queues_n; /**< Number of entries in queue[]. */ + struct rte_flow_action_rss rss_conf; /**< RSS configuration */ uint16_t (*queues)[]; /**< Queues indexes to use. */ - struct rte_eth_rss_conf rss_conf; /**< RSS configuration */ uint8_t rss_key[40]; /**< copy of the RSS key. */ struct ibv_counter_set *cs; /**< Holds the counters for the rule. */ struct mlx5_flow_counter_stats counter_stats;/**<The counter stats. */ @@ -406,9 +405,8 @@ struct mlx5_flow_parse { uint32_t mark:1; /**< Mark is present in the flow. */ uint32_t count:1; /**< Count is present in the flow. */ uint32_t mark_id; /**< Mark identifier. */ + struct rte_flow_action_rss rss_conf; /**< RSS configuration */ uint16_t queues[RTE_MAX_QUEUES_PER_PORT]; /**< Queues indexes to use. */ - uint16_t queues_n; /**< Number of entries in queue[]. */ - struct rte_eth_rss_conf rss_conf; /**< RSS configuration */ uint8_t rss_key[40]; /**< copy of the RSS key. */ enum hash_rxq_type layer; /**< Last pattern layer detected. */ struct ibv_counter_set *cs; /**< Holds the counter set for the rule */ @@ -540,47 +538,6 @@ mlx5_flow_item_validate(const struct rte_flow_item *item, } /** - * Copy the RSS configuration from the user ones, of the rss_conf is null, - * uses the driver one. - * - * @param parser - * Internal parser structure. - * @param rss_conf - * User RSS configuration to save. - * - * @return - * 0 on success, a negative errno value otherwise and rte_errno is set. - */ -static int -mlx5_flow_convert_rss_conf(struct mlx5_flow_parse *parser, - const struct rte_eth_rss_conf *rss_conf) -{ - /* - * This function is also called at the beginning of - * mlx5_flow_convert_actions() to initialize the parser with the - * device default RSS configuration. - */ - if (rss_conf) { - if (rss_conf->rss_hf & MLX5_RSS_HF_MASK) { - rte_errno = EINVAL; - return -rte_errno; - } - if (rss_conf->rss_key_len != 40) { - rte_errno = EINVAL; - return -rte_errno; - } - if (rss_conf->rss_key_len && rss_conf->rss_key) { - parser->rss_conf.rss_key_len = rss_conf->rss_key_len; - memcpy(parser->rss_key, rss_conf->rss_key, - rss_conf->rss_key_len); - parser->rss_conf.rss_key = parser->rss_key; - } - parser->rss_conf.rss_hf = rss_conf->rss_hf; - } - return 0; -} - -/** * Extract attribute to the parser. * * @param[in] attr @@ -650,17 +607,7 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, enum { FATE = 1, MARK = 2, COUNT = 4, }; uint32_t overlap = 0; struct priv *priv = dev->data->dev_private; - int ret; - /* - * Add default RSS configuration necessary for Verbs to create QP even - * if no RSS is necessary. - */ - ret = mlx5_flow_convert_rss_conf(parser, - (const struct rte_eth_rss_conf *) - &priv->rss_conf); - if (ret) - return ret; for (; actions->type != RTE_FLOW_ACTION_TYPE_END; ++actions) { if (actions->type == RTE_FLOW_ACTION_TYPE_VOID) { continue; @@ -679,25 +626,53 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, overlap |= FATE; if (!queue || (queue->index > (priv->rxqs_n - 1))) goto exit_action_not_supported; - parser->queues_n = 1; parser->queues[0] = queue->index; + parser->rss_conf = (struct rte_flow_action_rss){ + .queue_num = 1, + .queue = parser->queues, + }; } else if (actions->type == RTE_FLOW_ACTION_TYPE_RSS) { const struct rte_flow_action_rss *rss = (const struct rte_flow_action_rss *) actions->conf; + const uint8_t *rss_key; + uint32_t rss_key_len; uint16_t n; if (overlap & FATE) goto exit_action_overlap; overlap |= FATE; - if (!rss || !rss->num) { + if (rss->types & MLX5_RSS_HF_MASK) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION, + actions, + "unsupported RSS type" + " requested"); + return -rte_errno; + } + if (rss->key_len) { + rss_key_len = rss->key_len; + rss_key = rss->key; + } else { + rss_key_len = rss_hash_default_key_len; + rss_key = rss_hash_default_key; + } + if (rss_key_len != RTE_DIM(parser->rss_key)) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION, + actions, + "RSS hash key must be" + " exactly 40 bytes long"); + return -rte_errno; + } + if (!rss->queue_num) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, actions, "no valid queues"); return -rte_errno; } - if (rss->num > RTE_DIM(parser->queues)) { + if (rss->queue_num > RTE_DIM(parser->queues)) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, actions, @@ -705,7 +680,7 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, " context"); return -rte_errno; } - for (n = 0; n < rss->num; ++n) { + for (n = 0; n < rss->queue_num; ++n) { if (rss->queue[n] >= priv->rxqs_n) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, @@ -715,16 +690,16 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, return -rte_errno; } } - for (n = 0; n < rss->num; ++n) - parser->queues[n] = rss->queue[n]; - parser->queues_n = rss->num; - if (mlx5_flow_convert_rss_conf(parser, rss->rss_conf)) { - rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ACTION, - actions, - "wrong RSS configuration"); - return -rte_errno; - } + parser->rss_conf = (struct rte_flow_action_rss){ + .types = rss->types, + .key_len = rss_key_len, + .queue_num = rss->queue_num, + .key = memcpy(parser->rss_key, rss_key, + sizeof(*rss_key) * rss_key_len), + .queue = memcpy(parser->queues, rss->queue, + sizeof(*rss->queue) * + rss->queue_num), + }; } else if (actions->type == RTE_FLOW_ACTION_TYPE_MARK) { const struct rte_flow_action_mark *mark = (const struct rte_flow_action_mark *) @@ -769,7 +744,7 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, parser->drop = 1; if (parser->drop && parser->mark) parser->mark = 0; - if (!parser->queues_n && !parser->drop) { + if (!parser->rss_conf.queue_num && !parser->drop) { rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_HANDLE, NULL, "no valid action"); return -rte_errno; @@ -951,7 +926,7 @@ mlx5_flow_convert_finalise(struct mlx5_flow_parse *parser) unsigned int i; /* Remove any other flow not matching the pattern. */ - if (parser->queues_n == 1 && !parser->rss_conf.rss_hf) { + if (parser->rss_conf.queue_num == 1 && !parser->rss_conf.types) { for (i = 0; i != hash_rxq_init_n; ++i) { if (i == HASH_RXQ_ETH) continue; @@ -979,7 +954,7 @@ mlx5_flow_convert_finalise(struct mlx5_flow_parse *parser) } /* Remove impossible flow according to the RSS configuration. */ if (hash_rxq_init[parser->layer].dpdk_rss_hf & - parser->rss_conf.rss_hf) { + parser->rss_conf.types) { /* Remove any other flow. */ for (i = hmin; i != (hmax + 1); ++i) { if ((i == parser->layer) || @@ -990,7 +965,7 @@ mlx5_flow_convert_finalise(struct mlx5_flow_parse *parser) } } else if (!parser->queue[ip].ibv_attr) { /* no RSS possible with the current configuration. */ - parser->queues_n = 1; + parser->rss_conf.queue_num = 1; return; } fill: @@ -1119,7 +1094,7 @@ mlx5_flow_convert(struct rte_eth_dev *dev, for (i = 0; i != hash_rxq_init_n; ++i) { unsigned int offset; - if (!(parser->rss_conf.rss_hf & + if (!(parser->rss_conf.types & hash_rxq_init[i].dpdk_rss_hf) && (i != HASH_RXQ_ETH)) continue; @@ -1787,20 +1762,20 @@ mlx5_flow_create_action_queue_rss(struct rte_eth_dev *dev, continue; flow->frxq[i].hrxq = mlx5_hrxq_get(dev, - parser->rss_conf.rss_key, - parser->rss_conf.rss_key_len, + parser->rss_conf.key, + parser->rss_conf.key_len, hash_fields, - parser->queues, - parser->queues_n); + parser->rss_conf.queue, + parser->rss_conf.queue_num); if (flow->frxq[i].hrxq) continue; flow->frxq[i].hrxq = mlx5_hrxq_new(dev, - parser->rss_conf.rss_key, - parser->rss_conf.rss_key_len, + parser->rss_conf.key, + parser->rss_conf.key_len, hash_fields, - parser->queues, - parser->queues_n); + parser->rss_conf.queue, + parser->rss_conf.queue_num); if (!flow->frxq[i].hrxq) { return rte_flow_error_set(error, ENOMEM, RTE_FLOW_ERROR_TYPE_HANDLE, @@ -1871,9 +1846,9 @@ mlx5_flow_create_action_queue(struct rte_eth_dev *dev, NULL, "internal error in flow creation"); goto error; } - for (i = 0; i != parser->queues_n; ++i) { + for (i = 0; i != parser->rss_conf.queue_num; ++i) { struct mlx5_rxq_data *q = - (*priv->rxqs)[parser->queues[i]]; + (*priv->rxqs)[parser->rss_conf.queue[i]]; q->mark |= parser->mark; } @@ -1937,7 +1912,8 @@ mlx5_flow_list_create(struct rte_eth_dev *dev, if (ret) goto exit; flow = rte_calloc(__func__, 1, - sizeof(*flow) + parser.queues_n * sizeof(uint16_t), + sizeof(*flow) + + parser.rss_conf.queue_num * sizeof(uint16_t), 0); if (!flow) { rte_flow_error_set(error, ENOMEM, @@ -1946,15 +1922,20 @@ mlx5_flow_list_create(struct rte_eth_dev *dev, "cannot allocate flow memory"); return NULL; } - /* Copy queues configuration. */ + /* Copy configuration. */ flow->queues = (uint16_t (*)[])(flow + 1); - memcpy(flow->queues, parser.queues, parser.queues_n * sizeof(uint16_t)); - flow->queues_n = parser.queues_n; + flow->rss_conf = (struct rte_flow_action_rss){ + .types = parser.rss_conf.types, + .key_len = parser.rss_conf.key_len, + .queue_num = parser.rss_conf.queue_num, + .key = memcpy(flow->rss_key, parser.rss_conf.key, + sizeof(*parser.rss_conf.key) * + parser.rss_conf.key_len), + .queue = memcpy(flow->queues, parser.rss_conf.queue, + sizeof(*parser.rss_conf.queue) * + parser.rss_conf.queue_num), + }; flow->mark = parser.mark; - /* Copy RSS configuration. */ - flow->rss_conf = parser.rss_conf; - flow->rss_conf.rss_key = flow->rss_key; - memcpy(flow->rss_key, parser.rss_key, parser.rss_conf.rss_key_len); /* finalise the flow. */ if (parser.drop) ret = mlx5_flow_create_action_queue_drop(dev, &parser, flow, @@ -2034,7 +2015,7 @@ mlx5_flow_list_destroy(struct rte_eth_dev *dev, struct mlx5_flows *list, if (flow->drop || !flow->mark) goto free; - for (i = 0; i != flow->queues_n; ++i) { + for (i = 0; i != flow->rss_conf.queue_num; ++i) { struct rte_flow *tmp; int mark = 0; @@ -2344,19 +2325,19 @@ mlx5_flow_start(struct rte_eth_dev *dev, struct mlx5_flows *list) if (!flow->frxq[i].ibv_attr) continue; flow->frxq[i].hrxq = - mlx5_hrxq_get(dev, flow->rss_conf.rss_key, - flow->rss_conf.rss_key_len, + mlx5_hrxq_get(dev, flow->rss_conf.key, + flow->rss_conf.key_len, hash_rxq_init[i].hash_fields, - (*flow->queues), - flow->queues_n); + flow->rss_conf.queue, + flow->rss_conf.queue_num); if (flow->frxq[i].hrxq) goto flow_create; flow->frxq[i].hrxq = - mlx5_hrxq_new(dev, flow->rss_conf.rss_key, - flow->rss_conf.rss_key_len, + mlx5_hrxq_new(dev, flow->rss_conf.key, + flow->rss_conf.key_len, hash_rxq_init[i].hash_fields, - (*flow->queues), - flow->queues_n); + flow->rss_conf.queue, + flow->rss_conf.queue_num); if (!flow->frxq[i].hrxq) { DRV_LOG(DEBUG, "port %u flow %p cannot be applied", @@ -2380,8 +2361,8 @@ mlx5_flow_start(struct rte_eth_dev *dev, struct mlx5_flows *list) } if (!flow->mark) continue; - for (i = 0; i != flow->queues_n; ++i) - (*priv->rxqs)[(*flow->queues)[i]]->mark = 1; + for (i = 0; i != flow->rss_conf.queue_num; ++i) + (*priv->rxqs)[flow->rss_conf.queue[i]]->mark = 1; } return 0; } @@ -2458,8 +2439,10 @@ mlx5_ctrl_flow_vlan(struct rte_eth_dev *dev, }; uint16_t queue[priv->reta_idx_n]; struct rte_flow_action_rss action_rss = { - .rss_conf = &priv->rss_conf, - .num = priv->reta_idx_n, + .types = priv->rss_conf.rss_hf, + .key_len = priv->rss_conf.rss_key_len, + .queue_num = priv->reta_idx_n, + .key = priv->rss_conf.rss_key, .queue = queue, }; struct rte_flow_action actions[] = { diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c index eda3ba3d5..d2b25e8e8 100644 --- a/drivers/net/mlx5/mlx5_rxq.c +++ b/drivers/net/mlx5/mlx5_rxq.c @@ -1218,8 +1218,8 @@ mlx5_rxq_verify(struct rte_eth_dev *dev) * The Verbs object initialised, NULL otherwise and rte_errno is set. */ struct mlx5_ind_table_ibv * -mlx5_ind_table_ibv_new(struct rte_eth_dev *dev, uint16_t queues[], - uint16_t queues_n) +mlx5_ind_table_ibv_new(struct rte_eth_dev *dev, const uint16_t *queues, + uint32_t queues_n) { struct priv *priv = dev->data->dev_private; struct mlx5_ind_table_ibv *ind_tbl; @@ -1286,8 +1286,8 @@ mlx5_ind_table_ibv_new(struct rte_eth_dev *dev, uint16_t queues[], * An indirection table if found. */ struct mlx5_ind_table_ibv * -mlx5_ind_table_ibv_get(struct rte_eth_dev *dev, uint16_t queues[], - uint16_t queues_n) +mlx5_ind_table_ibv_get(struct rte_eth_dev *dev, const uint16_t *queues, + uint32_t queues_n) { struct priv *priv = dev->data->dev_private; struct mlx5_ind_table_ibv *ind_tbl; @@ -1391,8 +1391,10 @@ mlx5_ind_table_ibv_verify(struct rte_eth_dev *dev) * The Verbs object initialised, NULL otherwise and rte_errno is set. */ struct mlx5_hrxq * -mlx5_hrxq_new(struct rte_eth_dev *dev, uint8_t *rss_key, uint8_t rss_key_len, - uint64_t hash_fields, uint16_t queues[], uint16_t queues_n) +mlx5_hrxq_new(struct rte_eth_dev *dev, + const uint8_t *rss_key, uint32_t rss_key_len, + uint64_t hash_fields, + const uint16_t *queues, uint32_t queues_n) { struct priv *priv = dev->data->dev_private; struct mlx5_hrxq *hrxq; @@ -1408,6 +1410,10 @@ mlx5_hrxq_new(struct rte_eth_dev *dev, uint8_t *rss_key, uint8_t rss_key_len, rte_errno = ENOMEM; return NULL; } + if (!rss_key_len) { + rss_key_len = rss_hash_default_key_len; + rss_key = rss_hash_default_key; + } qp = mlx5_glue->create_qp_ex (priv->ctx, &(struct ibv_qp_init_attr_ex){ @@ -1419,7 +1425,7 @@ mlx5_hrxq_new(struct rte_eth_dev *dev, uint8_t *rss_key, uint8_t rss_key_len, .rx_hash_conf = (struct ibv_rx_hash_conf){ .rx_hash_function = IBV_RX_HASH_FUNC_TOEPLITZ, .rx_hash_key_len = rss_key_len, - .rx_hash_key = rss_key, + .rx_hash_key = (void *)(uintptr_t)rss_key, .rx_hash_fields_mask = hash_fields, }, .rwq_ind_tbl = ind_tbl->ind_table, @@ -1469,8 +1475,10 @@ mlx5_hrxq_new(struct rte_eth_dev *dev, uint8_t *rss_key, uint8_t rss_key_len, * An hash Rx queue on success. */ struct mlx5_hrxq * -mlx5_hrxq_get(struct rte_eth_dev *dev, uint8_t *rss_key, uint8_t rss_key_len, - uint64_t hash_fields, uint16_t queues[], uint16_t queues_n) +mlx5_hrxq_get(struct rte_eth_dev *dev, + const uint8_t *rss_key, uint32_t rss_key_len, + uint64_t hash_fields, + const uint16_t *queues, uint32_t queues_n) { struct priv *priv = dev->data->dev_private; struct mlx5_hrxq *hrxq; diff --git a/drivers/net/mlx5/mlx5_rxtx.h b/drivers/net/mlx5/mlx5_rxtx.h index 14d4418d9..c3a1ae213 100644 --- a/drivers/net/mlx5/mlx5_rxtx.h +++ b/drivers/net/mlx5/mlx5_rxtx.h @@ -134,7 +134,7 @@ struct mlx5_ind_table_ibv { LIST_ENTRY(mlx5_ind_table_ibv) next; /* Pointer to the next element. */ rte_atomic32_t refcnt; /* Reference counter. */ struct ibv_rwq_ind_table *ind_table; /**< Indirection table. */ - uint16_t queues_n; /**< Number of queues in the list. */ + uint32_t queues_n; /**< Number of queues in the list. */ uint16_t queues[]; /**< Queue list. */ }; @@ -145,7 +145,7 @@ struct mlx5_hrxq { struct mlx5_ind_table_ibv *ind_table; /* Indirection table. */ struct ibv_qp *qp; /* Verbs queue pair. */ uint64_t hash_fields; /* Verbs Hash fields. */ - uint8_t rss_key_len; /* Hash key length in bytes. */ + uint32_t rss_key_len; /* Hash key length in bytes. */ uint8_t rss_key[]; /* Hash key. */ }; @@ -238,20 +238,22 @@ int mlx5_rxq_releasable(struct rte_eth_dev *dev, uint16_t idx); int mlx5_rxq_verify(struct rte_eth_dev *dev); int rxq_alloc_elts(struct mlx5_rxq_ctrl *rxq_ctrl); struct mlx5_ind_table_ibv *mlx5_ind_table_ibv_new(struct rte_eth_dev *dev, - uint16_t queues[], - uint16_t queues_n); + const uint16_t *queues, + uint32_t queues_n); struct mlx5_ind_table_ibv *mlx5_ind_table_ibv_get(struct rte_eth_dev *dev, - uint16_t queues[], - uint16_t queues_n); + const uint16_t *queues, + uint32_t queues_n); int mlx5_ind_table_ibv_release(struct rte_eth_dev *dev, struct mlx5_ind_table_ibv *ind_tbl); int mlx5_ind_table_ibv_verify(struct rte_eth_dev *dev); -struct mlx5_hrxq *mlx5_hrxq_new(struct rte_eth_dev *dev, uint8_t *rss_key, - uint8_t rss_key_len, uint64_t hash_fields, - uint16_t queues[], uint16_t queues_n); -struct mlx5_hrxq *mlx5_hrxq_get(struct rte_eth_dev *dev, uint8_t *rss_key, - uint8_t rss_key_len, uint64_t hash_fields, - uint16_t queues[], uint16_t queues_n); +struct mlx5_hrxq *mlx5_hrxq_new(struct rte_eth_dev *dev, + const uint8_t *rss_key, uint32_t rss_key_len, + uint64_t hash_fields, + const uint16_t *queues, uint32_t queues_n); +struct mlx5_hrxq *mlx5_hrxq_get(struct rte_eth_dev *dev, + const uint8_t *rss_key, uint32_t rss_key_len, + uint64_t hash_fields, + const uint16_t *queues, uint32_t queues_n); int mlx5_hrxq_release(struct rte_eth_dev *dev, struct mlx5_hrxq *hxrq); int mlx5_hrxq_ibv_verify(struct rte_eth_dev *dev); uint64_t mlx5_get_rx_port_offloads(void); diff --git a/drivers/net/sfc/sfc_flow.c b/drivers/net/sfc/sfc_flow.c index 056405515..1a2c0299c 100644 --- a/drivers/net/sfc/sfc_flow.c +++ b/drivers/net/sfc/sfc_flow.c @@ -1234,13 +1234,11 @@ sfc_flow_parse_rss(struct sfc_adapter *sa, struct sfc_rxq *rxq; unsigned int rxq_hw_index_min; unsigned int rxq_hw_index_max; - const struct rte_eth_rss_conf *rss_conf = rss->rss_conf; - uint64_t rss_hf; - uint8_t *rss_key = NULL; + const uint8_t *rss_key; struct sfc_flow_rss *sfc_rss_conf = &flow->rss_conf; unsigned int i; - if (rss->num == 0) + if (rss->queue_num == 0) return -EINVAL; rxq_sw_index = sa->rxq_count - 1; @@ -1248,7 +1246,7 @@ sfc_flow_parse_rss(struct sfc_adapter *sa, rxq_hw_index_min = rxq->hw_index; rxq_hw_index_max = 0; - for (i = 0; i < rss->num; ++i) { + for (i = 0; i < rss->queue_num; ++i) { rxq_sw_index = rss->queue[i]; if (rxq_sw_index >= sa->rxq_count) @@ -1263,15 +1261,14 @@ sfc_flow_parse_rss(struct sfc_adapter *sa, rxq_hw_index_max = rxq->hw_index; } - rss_hf = (rss_conf != NULL) ? rss_conf->rss_hf : SFC_RSS_OFFLOADS; - if ((rss_hf & ~SFC_RSS_OFFLOADS) != 0) + if ((rss->types & ~SFC_RSS_OFFLOADS) != 0) return -EINVAL; - if (rss_conf != NULL) { - if (rss_conf->rss_key_len != sizeof(sa->rss_key)) + if (rss->key_len) { + if (rss->key_len != sizeof(sa->rss_key)) return -EINVAL; - rss_key = rss_conf->rss_key; + rss_key = rss->key; } else { rss_key = sa->rss_key; } @@ -1280,11 +1277,11 @@ sfc_flow_parse_rss(struct sfc_adapter *sa, sfc_rss_conf->rxq_hw_index_min = rxq_hw_index_min; sfc_rss_conf->rxq_hw_index_max = rxq_hw_index_max; - sfc_rss_conf->rss_hash_types = sfc_rte_to_efx_hash_type(rss_hf); + sfc_rss_conf->rss_hash_types = sfc_rte_to_efx_hash_type(rss->types); rte_memcpy(sfc_rss_conf->rss_key, rss_key, sizeof(sa->rss_key)); for (i = 0; i < RTE_DIM(sfc_rss_conf->rss_tbl); ++i) { - unsigned int rxq_sw_index = rss->queue[i % rss->num]; + unsigned int rxq_sw_index = rss->queue[i % rss->queue_num]; struct sfc_rxq *rxq = sa->rxq_info[rxq_sw_index].rxq; sfc_rss_conf->rss_tbl[i] = rxq->hw_index - rxq_hw_index_min; diff --git a/drivers/net/tap/tap_flow.c b/drivers/net/tap/tap_flow.c index fe2f94010..67146aaba 100644 --- a/drivers/net/tap/tap_flow.c +++ b/drivers/net/tap/tap_flow.c @@ -1215,7 +1215,7 @@ priv_flow_process(struct pmd_internals *pmd, if (err) goto exit_action_not_supported; } - if (flow && rss) + if (flow) err = rss_add_actions(flow, pmd, rss, error); } else { goto exit_action_not_supported; @@ -2050,7 +2050,7 @@ static int rss_add_actions(struct rte_flow *flow, struct pmd_internals *pmd, struct rte_flow_error *error) { /* 4096 is the maximum number of instructions for a BPF program */ - int i; + unsigned int i; int err; struct rss_key rss_entry = { .hash_fields = 0, .key_size = 0 }; @@ -2066,8 +2066,8 @@ static int rss_add_actions(struct rte_flow *flow, struct pmd_internals *pmd, } /* Update RSS map entry with queues */ - rss_entry.nb_queues = rss->num; - for (i = 0; i < rss->num; i++) + rss_entry.nb_queues = rss->queue_num; + for (i = 0; i < rss->queue_num; i++) rss_entry.queues[i] = rss->queue[i]; rss_entry.hash_fields = (1 << HASH_FIELD_IPV4_L3_L4) | (1 << HASH_FIELD_IPV6_L3_L4); diff --git a/examples/ipsec-secgw/ipsec.c b/examples/ipsec-secgw/ipsec.c index 5971937cf..ee2497352 100644 --- a/examples/ipsec-secgw/ipsec.c +++ b/examples/ipsec-secgw/ipsec.c @@ -203,9 +203,13 @@ create_session(struct ipsec_ctx *ipsec_ctx, struct ipsec_sa *sa) i < eth_dev->data->nb_rx_queues; ++i) if (eth_dev->data->rx_queues[i]) queue[j++] = i; - action_rss.rss_conf = &rss_conf; - action_rss.num = j; - action_rss.queue = queue; + action_rss = (struct rte_flow_action_rss){ + .types = rss_conf.rss_hf, + .key_len = rss_conf.rss_key_len, + .queue_num = j, + .key = rss_key, + .queue = queue, + }; ret = rte_flow_validate(sa->portid, &sa->attr, sa->pattern, sa->action, &err); diff --git a/lib/librte_ether/rte_flow.c b/lib/librte_ether/rte_flow.c index bb19e28c6..cc7819b6a 100644 --- a/lib/librte_ether/rte_flow.c +++ b/lib/librte_ether/rte_flow.c @@ -330,40 +330,27 @@ flow_action_conf_copy(void *buf, const struct rte_flow_action *action) off = 0; if (dst.rss) *dst.rss = (struct rte_flow_action_rss){ - .num = src.rss->num, + .types = src.rss->types, + .key_len = src.rss->key_len, + .queue_num = src.rss->queue_num, }; off += sizeof(*src.rss); - if (src.rss->num) { + if (src.rss->key_len) { off = RTE_ALIGN_CEIL(off, sizeof(double)); - size = sizeof(*src.rss->queue) * src.rss->num; + size = sizeof(*src.rss->key) * src.rss->key_len; if (dst.rss) - dst.rss->queue = memcpy + dst.rss->key = memcpy ((void *)((uintptr_t)dst.rss + off), - src.rss->queue, size); + src.rss->key, size); off += size; } - off = RTE_ALIGN_CEIL(off, sizeof(double)); - if (dst.rss) { - dst.rss->rss_conf = (void *)((uintptr_t)dst.rss + off); - *(struct rte_eth_rss_conf *)(uintptr_t) - dst.rss->rss_conf = (struct rte_eth_rss_conf){ - .rss_key_len = src.rss->rss_conf->rss_key_len, - .rss_hf = src.rss->rss_conf->rss_hf, - }; - } - off += sizeof(*src.rss->rss_conf); - if (src.rss->rss_conf->rss_key_len) { + if (src.rss->queue_num) { off = RTE_ALIGN_CEIL(off, sizeof(double)); - size = sizeof(*src.rss->rss_conf->rss_key) * - src.rss->rss_conf->rss_key_len; - if (dst.rss) { - ((struct rte_eth_rss_conf *)(uintptr_t) - dst.rss->rss_conf)->rss_key = - (void *)((uintptr_t)dst.rss + off); - memcpy(dst.rss->rss_conf->rss_key, - src.rss->rss_conf->rss_key, - size); - } + size = sizeof(*src.rss->queue) * src.rss->queue_num; + if (dst.rss) + dst.rss->queue = memcpy + ((void *)((uintptr_t)dst.rss + off), + src.rss->queue, size); off += size; } size = off; diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index ad2e55b8e..bbc408fa6 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -1033,13 +1033,21 @@ struct rte_flow_query_count { * Similar to QUEUE, except RSS is additionally performed on packets to * spread them among several queues according to the provided parameters. * + * Unlike global RSS settings used by other DPDK APIs, unsetting the + * @p types field does not disable RSS in a flow rule. Doing so instead + * requests safe unspecified "best-effort" settings from the underlying PMD, + * which depending on the flow rule, may result in anything ranging from + * empty (single queue) to all-inclusive RSS. + * * Note: RSS hash result is stored in the hash.rss mbuf field which overlaps * hash.fdir.lo. Since the MARK action sets the hash.fdir.hi field only, * both can be requested simultaneously. */ struct rte_flow_action_rss { - const struct rte_eth_rss_conf *rss_conf; /**< RSS parameters. */ - uint16_t num; /**< Number of entries in @p queue. */ + uint64_t types; /**< Specific RSS hash types (see ETH_RSS_*). */ + uint32_t key_len; /**< Hash key length in bytes. */ + uint32_t queue_num; /**< Number of entries in @p queue. */ + const uint8_t *key; /**< Hash key. */ const uint16_t *queue; /**< Queue indices to use. */ }; -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [dpdk-dev] [PATCH v6 07/16] ethdev: flatten RSS configuration in flow API 2018-04-25 15:27 ` [dpdk-dev] [PATCH v6 07/16] ethdev: flatten RSS configuration in " Adrien Mazarguil @ 2018-04-28 3:46 ` Zhao1, Wei 2018-04-28 5:28 ` Peng, Yuan 0 siblings, 1 reply; 157+ messages in thread From: Zhao1, Wei @ 2018-04-28 3:46 UTC (permalink / raw) To: Adrien Mazarguil, dev Cc: Peng, Yuan, Xu, Qian Q, Liu, Yu Y, Lu, Wenzhuo, Wu, Jingjing Hi,Adrien Mazarguil We have just use new RC.1 code on the feature of flow RSS API, but we find some abnormal phenomenon. After that I check code again, I find that it is introduced in this patch: SHA-1: ac8d22de2394e03ba4a77d8fd24381147aafb1d3 * ethdev: flatten RSS configuration in flow API Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> This abnormal phenomenon include i40e and ixgbe 2 NIC, it do not has these 2 bug before merge this patch. It is first find out by yuan.peng@intel.com, she can tell you how to reappear these abnormal phenomenon on RSS flow API. Thank you. > -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Adrien Mazarguil > Sent: Wednesday, April 25, 2018 11:28 PM > To: Thomas Monjalon <thomas@monjalon.net>; Yigit, Ferruh > <ferruh.yigit@intel.com>; dev@dpdk.org > Cc: Xueming Li <xuemingl@mellanox.com>; Lu, Wenzhuo > <wenzhuo.lu@intel.com>; Wu, Jingjing <jingjing.wu@intel.com>; Xing, Beilei > <beilei.xing@intel.com>; Zhang, Qi Z <qi.z.zhang@intel.com>; Ananyev, > Konstantin <konstantin.ananyev@intel.com>; Nelio Laranjeiro > <nelio.laranjeiro@6wind.com>; Yongseok Koh <yskoh@mellanox.com>; > Andrew Rybchenko <arybchenko@solarflare.com>; Pascal Mazon > <pascal.mazon@6wind.com>; Nicolau, Radu <radu.nicolau@intel.com>; Akhil > Goyal <akhil.goyal@nxp.com> > Subject: [dpdk-dev] [PATCH v6 07/16] ethdev: flatten RSS configuration in > flow API > > Since its inception, the rte_flow RSS action has been relying in part on > external struct rte_eth_rss_conf for compatibility with the legacy RSS API. > This structure lacks parameters such as the hash algorithm to use, and more > recently, a method to tell which layer RSS should be performed on [1]. > > Given struct rte_eth_rss_conf will never be flexible enough to represent a > complete RSS configuration (e.g. RETA table), this patch supersedes it by > extending the rte_flow RSS action directly. > > A subsequent patch will add a field to use a non-default RSS hash > algorithm. To that end, a field named "types" replaces the field formerly > known as "rss_hf" and standing for "RSS hash functions" as it was > confusing. Actual RSS hash function types are defined by enum > rte_eth_hash_function. > > This patch updates all PMDs and example applications accordingly. > > It breaks ABI compatibility for the following public functions: > > - rte_flow_copy() > - rte_flow_create() > - rte_flow_query() > - rte_flow_validate() > > [1] commit 676b605182a5 ("doc: announce ethdev API change for RSS > configuration") > > Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> > Acked-by: Andrew Rybchenko <arybchenko@solarflare.com> > Cc: Xueming Li <xuemingl@mellanox.com> > Cc: Ferruh Yigit <ferruh.yigit@intel.com> > Cc: Thomas Monjalon <thomas@monjalon.net> > Cc: Wenzhuo Lu <wenzhuo.lu@intel.com> > Cc: Jingjing Wu <jingjing.wu@intel.com> > Cc: Beilei Xing <beilei.xing@intel.com> > Cc: Qi Zhang <qi.z.zhang@intel.com> > Cc: Konstantin Ananyev <konstantin.ananyev@intel.com> > Cc: Nelio Laranjeiro <nelio.laranjeiro@6wind.com> > Cc: Yongseok Koh <yskoh@mellanox.com> > Cc: Andrew Rybchenko <arybchenko@solarflare.com> > Cc: Pascal Mazon <pascal.mazon@6wind.com> > Cc: Radu Nicolau <radu.nicolau@intel.com> > Cc: Akhil Goyal <akhil.goyal@nxp.com> > > --- > > v6 changes: > > - Fixed QUEUE action support in mlx5 according to Nelio's comment [1]. > This action relies on RSS to work and even though it targets a single Rx > queue, a non-NULL hash key is required. > - Updated API and ABI changes sections in release notes. > > [1] http://dpdk.org/ml/archives/dev/2018-April/098635.html > > v3 changes: > > Documentation update regarding the meaning of a 0 value for RSS types in > flow rules. > > It used to implicitly mean "no RSS" but is redefined as requesting a kind > of "best-effort" mode from PMDs, i.e. anything ranging from empty to > all-inclusive RSS; what matters is it provides safe defaults that will work > regardless of PMD capabilities. > --- > app/test-pmd/cmdline_flow.c | 48 +++--- > app/test-pmd/config.c | 39 ++--- > doc/guides/prog_guide/rte_flow.rst | 28 ++-- > doc/guides/rel_notes/release_18_05.rst | 13 +- > doc/guides/testpmd_app_ug/testpmd_funcs.rst | 6 +- > drivers/net/e1000/e1000_ethdev.h | 13 +- > drivers/net/e1000/igb_ethdev.c | 4 +- > drivers/net/e1000/igb_flow.c | 31 ++-- > drivers/net/e1000/igb_rxtx.c | 51 +++++- > drivers/net/i40e/i40e_ethdev.c | 53 +++++-- > drivers/net/i40e/i40e_ethdev.h | 15 +- > drivers/net/i40e/i40e_flow.c | 47 +++--- > drivers/net/ixgbe/ixgbe_ethdev.c | 4 +- > drivers/net/ixgbe/ixgbe_ethdev.h | 13 +- > drivers/net/ixgbe/ixgbe_flow.c | 30 ++-- > drivers/net/ixgbe/ixgbe_rxtx.c | 51 +++++- > drivers/net/mlx4/mlx4.c | 2 +- > drivers/net/mlx4/mlx4_flow.c | 61 +++---- > drivers/net/mlx4/mlx4_flow.h | 2 +- > drivers/net/mlx4/mlx4_rxq.c | 2 +- > drivers/net/mlx4/mlx4_rxtx.h | 2 +- > drivers/net/mlx5/mlx5_flow.c | 193 +++++++++++------------ > drivers/net/mlx5/mlx5_rxq.c | 26 +-- > drivers/net/mlx5/mlx5_rxtx.h | 26 +-- > drivers/net/sfc/sfc_flow.c | 21 ++- > drivers/net/tap/tap_flow.c | 8 +- > examples/ipsec-secgw/ipsec.c | 10 +- > lib/librte_ether/rte_flow.c | 39 ++--- > lib/librte_ether/rte_flow.h | 12 +- > 29 files changed, 492 insertions(+), 358 deletions(-) > > diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c > index 798b7948d..c9c2c3ad9 100644 > --- a/app/test-pmd/cmdline_flow.c > +++ b/app/test-pmd/cmdline_flow.c > @@ -192,9 +192,8 @@ enum index { > /** Storage for struct rte_flow_action_rss including external data. */ > struct action_rss_data { > struct rte_flow_action_rss conf; > + uint8_t key[RSS_HASH_KEY_LENGTH]; > uint16_t queue[ACTION_RSS_QUEUE_NUM]; > - struct rte_eth_rss_conf rss_conf; > - uint8_t rss_key[RSS_HASH_KEY_LENGTH]; > }; > > /** Maximum number of subsequent tokens and arguments on the stack. > */ > @@ -1587,7 +1586,7 @@ static const struct token token_list[] = { > }, > [ACTION_RSS_TYPES] = { > .name = "types", > - .help = "RSS hash types", > + .help = "specific RSS hash types", > .next = NEXT(action_rss, NEXT_ENTRY(ACTION_RSS_TYPE)), > }, > [ACTION_RSS_TYPE] = { > @@ -1602,21 +1601,21 @@ static const struct token token_list[] = { > .next = NEXT(action_rss, NEXT_ENTRY(STRING)), > .args = ARGS(ARGS_ENTRY_ARB(0, 0), > ARGS_ENTRY_ARB > - (offsetof(struct action_rss_data, rss_conf) + > - offsetof(struct rte_eth_rss_conf, rss_key_len), > - sizeof(((struct rte_eth_rss_conf *)0)-> > - rss_key_len)), > - ARGS_ENTRY(struct action_rss_data, rss_key)), > + (offsetof(struct action_rss_data, conf) + > + offsetof(struct rte_flow_action_rss, key_len), > + sizeof(((struct rte_flow_action_rss *)0)-> > + key_len)), > + ARGS_ENTRY(struct action_rss_data, key)), > }, > [ACTION_RSS_KEY_LEN] = { > .name = "key_len", > .help = "RSS hash key length in bytes", > .next = NEXT(action_rss, NEXT_ENTRY(UNSIGNED)), > .args = ARGS(ARGS_ENTRY_ARB_BOUNDED > - (offsetof(struct action_rss_data, rss_conf) + > - offsetof(struct rte_eth_rss_conf, rss_key_len), > - sizeof(((struct rte_eth_rss_conf *)0)-> > - rss_key_len), > + (offsetof(struct action_rss_data, conf) + > + offsetof(struct rte_flow_action_rss, key_len), > + sizeof(((struct rte_flow_action_rss *)0)-> > + key_len), > 0, > RSS_HASH_KEY_LENGTH)), > }, > @@ -2075,27 +2074,24 @@ parse_vc_action_rss(struct context *ctx, const > struct token *token, > action_rss_data = ctx->object; > *action_rss_data = (struct action_rss_data){ > .conf = (struct rte_flow_action_rss){ > - .rss_conf = &action_rss_data->rss_conf, > - .num = RTE_MIN(nb_rxq, > ACTION_RSS_QUEUE_NUM), > + .types = rss_hf, > + .key_len = sizeof(action_rss_data->key), > + .queue_num = RTE_MIN(nb_rxq, > ACTION_RSS_QUEUE_NUM), > + .key = action_rss_data->key, > .queue = action_rss_data->queue, > }, > + .key = "testpmd's default RSS hash key", > .queue = { 0 }, > - .rss_conf = (struct rte_eth_rss_conf){ > - .rss_key = action_rss_data->rss_key, > - .rss_key_len = sizeof(action_rss_data->rss_key), > - .rss_hf = rss_hf, > - }, > - .rss_key = "testpmd's default RSS hash key", > }; > - for (i = 0; i < action_rss_data->conf.num; ++i) > + for (i = 0; i < action_rss_data->conf.queue_num; ++i) > action_rss_data->queue[i] = i; > if (!port_id_is_invalid(ctx->port, DISABLED_WARN) && > ctx->port != (portid_t)RTE_PORT_ALL) { > struct rte_eth_dev_info info; > > rte_eth_dev_info_get(ctx->port, &info); > - action_rss_data->rss_conf.rss_key_len = > - RTE_MIN(sizeof(action_rss_data->rss_key), > + action_rss_data->conf.key_len = > + RTE_MIN(sizeof(action_rss_data->key), > info.hash_key_size); > } > action->conf = &action_rss_data->conf; > @@ -2123,7 +2119,7 @@ parse_vc_action_rss_type(struct context *ctx, > const struct token *token, > return -1; > if (!(ctx->objdata >> 16) && ctx->object) { > action_rss_data = ctx->object; > - action_rss_data->rss_conf.rss_hf = 0; > + action_rss_data->conf.types = 0; > } > if (!strcmp_partial("end", str, len)) { > ctx->objdata &= 0xffff; > @@ -2142,7 +2138,7 @@ parse_vc_action_rss_type(struct context *ctx, > const struct token *token, > if (!ctx->object) > return len; > action_rss_data = ctx->object; > - action_rss_data->rss_conf.rss_hf |= rss_type_table[i].rss_type; > + action_rss_data->conf.types |= rss_type_table[i].rss_type; > return len; > } > > @@ -2192,7 +2188,7 @@ parse_vc_action_rss_queue(struct context *ctx, > const struct token *token, > if (!ctx->object) > return len; > action_rss_data = ctx->object; > - action_rss_data->conf.num = i; > + action_rss_data->conf.queue_num = i; > action_rss_data->conf.queue = i ? action_rss_data->queue : NULL; > return len; > } > diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c > index eb7ac315e..4700dd674 100644 > --- a/app/test-pmd/config.c > +++ b/app/test-pmd/config.c > @@ -1117,40 +1117,27 @@ flow_action_conf_copy(void *buf, const struct > rte_flow_action *action) > off = 0; > if (dst.rss) > *dst.rss = (struct rte_flow_action_rss){ > - .num = src.rss->num, > + .types = src.rss->types, > + .key_len = src.rss->key_len, > + .queue_num = src.rss->queue_num, > }; > off += sizeof(*src.rss); > - if (src.rss->num) { > + if (src.rss->key_len) { > off = RTE_ALIGN_CEIL(off, sizeof(double)); > - size = sizeof(*src.rss->queue) * src.rss->num; > + size = sizeof(*src.rss->key) * src.rss->key_len; > if (dst.rss) > - dst.rss->queue = memcpy > + dst.rss->key = memcpy > ((void *)((uintptr_t)dst.rss + off), > - src.rss->queue, size); > + src.rss->key, size); > off += size; > } > - off = RTE_ALIGN_CEIL(off, sizeof(double)); > - if (dst.rss) { > - dst.rss->rss_conf = (void *)((uintptr_t)dst.rss + off); > - *(struct rte_eth_rss_conf *)(uintptr_t) > - dst.rss->rss_conf = (struct > rte_eth_rss_conf){ > - .rss_key_len = src.rss->rss_conf- > >rss_key_len, > - .rss_hf = src.rss->rss_conf->rss_hf, > - }; > - } > - off += sizeof(*src.rss->rss_conf); > - if (src.rss->rss_conf->rss_key_len) { > + if (src.rss->queue_num) { > off = RTE_ALIGN_CEIL(off, sizeof(double)); > - size = sizeof(*src.rss->rss_conf->rss_key) * > - src.rss->rss_conf->rss_key_len; > - if (dst.rss) { > - ((struct rte_eth_rss_conf *)(uintptr_t) > - dst.rss->rss_conf)->rss_key = > - (void *)((uintptr_t)dst.rss + off); > - memcpy(dst.rss->rss_conf->rss_key, > - src.rss->rss_conf->rss_key, > - size); > - } > + size = sizeof(*src.rss->queue) * src.rss->queue_num; > + if (dst.rss) > + dst.rss->queue = memcpy > + ((void *)((uintptr_t)dst.rss + off), > + src.rss->queue, size); > off += size; > } > size = off; > diff --git a/doc/guides/prog_guide/rte_flow.rst > b/doc/guides/prog_guide/rte_flow.rst > index acbeaacbd..cf252eeba 100644 > --- a/doc/guides/prog_guide/rte_flow.rst > +++ b/doc/guides/prog_guide/rte_flow.rst > @@ -1301,6 +1301,12 @@ Action: ``RSS`` > Similar to QUEUE, except RSS is additionally performed on packets to spread > them among several queues according to the provided parameters. > > +Unlike global RSS settings used by other DPDK APIs, unsetting the ``types`` > +field does not disable RSS in a flow rule. Doing so instead requests safe > +unspecified "best-effort" settings from the underlying PMD, which > depending > +on the flow rule, may result in anything ranging from empty (single queue) > +to all-inclusive RSS. > + > Note: RSS hash result is stored in the ``hash.rss`` mbuf field which > overlaps ``hash.fdir.lo``. Since `Action: MARK`_ sets the ``hash.fdir.hi`` > field only, both can be requested simultaneously. > @@ -1309,15 +1315,19 @@ field only, both can be requested simultaneously. > > .. table:: RSS > > - +--------------+--------------------------------+ > - | Field | Value | > - +==============+================================+ > - | ``rss_conf`` | RSS parameters | > - +--------------+--------------------------------+ > - | ``num`` | number of entries in ``queue`` | > - +--------------+--------------------------------+ > - | ``queue`` | queue indices to use | > - +--------------+--------------------------------+ > + +---------------+---------------------------------------------+ > + | Field | Value | > + > +===============+========================================= > ====+ > + | ``types`` | specific RSS hash types (see ``ETH_RSS_*``) | > + +---------------+---------------------------------------------+ > + | ``key_len`` | hash key length in bytes | > + +---------------+---------------------------------------------+ > + | ``queue_num`` | number of entries in ``queue`` | > + +---------------+---------------------------------------------+ > + | ``key`` | hash key | > + +---------------+---------------------------------------------+ > + | ``queue`` | queue indices to use | > + +---------------+---------------------------------------------+ > > Action: ``PF`` > ^^^^^^^^^^^^^^ > diff --git a/doc/guides/rel_notes/release_18_05.rst > b/doc/guides/rel_notes/release_18_05.rst > index ca173450c..b702ac66a 100644 > --- a/doc/guides/rel_notes/release_18_05.rst > +++ b/doc/guides/rel_notes/release_18_05.rst > @@ -254,6 +254,13 @@ API Changes > present. > * C99-style flexible arrays were replaced with standard pointers in RSS > action and in RAW pattern item structures due to compatibility issues. > + * The RSS action was modified to not rely on external > + ``struct rte_eth_rss_conf`` anymore to instead expose its own and more > + appropriately named configuration fields directly > + (``rss_conf->rss_key`` => ``key``, > + ``rss_conf->rss_key_len`` => ``key_len``, > + ``rss_conf->rss_hf`` => ``types``, > + ``num`` => ``queue_num``). > > > ABI Changes > @@ -302,9 +309,9 @@ ABI Changes > ``rte_flow_isolate``, ``rte_flow_query`` and ``rte_flow_validate``, due to > changes in error type definitions (``enum rte_flow_error_type``), removal > of the unused DUP action (``enum rte_flow_action_type``), modified > - behavior for flow rule actions (see API changes) and removal of C99 > - flexible arrays from RSS action (``struct rte_flow_action_rss``) and RAW > - pattern item (``struct rte_flow_item_raw``). > + behavior for flow rule actions (see API changes), removal of C99 flexible > + array from RAW pattern item (``struct rte_flow_item_raw``) and complete > + rework of the RSS action definition (``struct rte_flow_action_rss``). > > > Removed Items > diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst > b/doc/guides/testpmd_app_ug/testpmd_funcs.rst > index 68c286bd4..a12e0267a 100644 > --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst > +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst > @@ -3422,8 +3422,10 @@ This section lists supported actions and their > attributes, if any. > > - ``rss``: spread packets among several queues. > > - - ``types [{RSS hash type} [...]] end``: RSS hash types, allowed tokens > - are the same as `set_hash_input_set`_, an empty list means none (0). > + - ``types [{RSS hash type} [...]] end``: specific RSS hash types, allowed > + tokens are the same as `set_hash_input_set`_, except that an empty list > + does not disable RSS but instead requests unspecified "best-effort" > + settings. > > - ``key {string}``: RSS hash key, overrides ``key_len``. > > diff --git a/drivers/net/e1000/e1000_ethdev.h > b/drivers/net/e1000/e1000_ethdev.h > index 6354b894a..902001f36 100644 > --- a/drivers/net/e1000/e1000_ethdev.h > +++ b/drivers/net/e1000/e1000_ethdev.h > @@ -4,6 +4,10 @@ > > #ifndef _E1000_ETHDEV_H_ > #define _E1000_ETHDEV_H_ > + > +#include <stdint.h> > + > +#include <rte_flow.h> > #include <rte_time.h> > #include <rte_pci.h> > > @@ -27,6 +31,7 @@ > #define E1000_CTRL_EXT_EXTEND_VLAN (1<<26) /* EXTENDED VLAN */ > #define IGB_VFTA_SIZE 128 > > +#define IGB_HKEY_MAX_INDEX 10 > #define IGB_MAX_RX_QUEUE_NUM 8 > #define IGB_MAX_RX_QUEUE_NUM_82576 16 > > @@ -229,8 +234,8 @@ struct igb_ethertype_filter { > }; > > struct igb_rte_flow_rss_conf { > - struct rte_eth_rss_conf rss_conf; /**< RSS parameters. */ > - uint16_t num; /**< Number of entries in queue[]. */ > + struct rte_flow_action_rss conf; /**< RSS parameters. */ > + uint8_t key[IGB_HKEY_MAX_INDEX * sizeof(uint32_t)]; /* Hash key. > */ > uint16_t queue[IGB_MAX_RX_QUEUE_NUM]; /**< Queues indices > to use. */ > }; > > @@ -501,6 +506,10 @@ int eth_igb_syn_filter_set(struct rte_eth_dev *dev, > int eth_igb_add_del_flex_filter(struct rte_eth_dev *dev, > struct rte_eth_flex_filter *filter, > bool add); > +int igb_rss_conf_init(struct igb_rte_flow_rss_conf *out, > + const struct rte_flow_action_rss *in); > +int igb_action_rss_same(const struct rte_flow_action_rss *comp, > + const struct rte_flow_action_rss *with); > int igb_config_rss_filter(struct rte_eth_dev *dev, > struct igb_rte_flow_rss_conf *conf, > bool add); > diff --git a/drivers/net/e1000/igb_ethdev.c > b/drivers/net/e1000/igb_ethdev.c > index c35c9352a..140334772 100644 > --- a/drivers/net/e1000/igb_ethdev.c > +++ b/drivers/net/e1000/igb_ethdev.c > @@ -41,8 +41,6 @@ > #define IGB_DEFAULT_TX_HTHRESH 1 > #define IGB_DEFAULT_TX_WTHRESH ((hw->mac.type == e1000_82576) ? > 1 : 16) > > -#define IGB_HKEY_MAX_INDEX 10 > - > /* Bit shift and mask */ > #define IGB_4_BIT_WIDTH (CHAR_BIT / 2) > #define IGB_4_BIT_MASK RTE_LEN2MASK(IGB_4_BIT_WIDTH, uint8_t) > @@ -5662,7 +5660,7 @@ igb_rss_filter_restore(struct rte_eth_dev *dev) > struct e1000_filter_info *filter_info = > E1000_DEV_PRIVATE_TO_FILTER_INFO(dev->data- > >dev_private); > > - if (filter_info->rss_info.num) > + if (filter_info->rss_info.conf.queue_num) > igb_config_rss_filter(dev, &filter_info->rss_info, TRUE); > } > > diff --git a/drivers/net/e1000/igb_flow.c b/drivers/net/e1000/igb_flow.c > index c0f5b5190..8dc5f75f2 100644 > --- a/drivers/net/e1000/igb_flow.c > +++ b/drivers/net/e1000/igb_flow.c > @@ -1292,7 +1292,7 @@ igb_parse_rss_filter(struct rte_eth_dev *dev, > > rss = (const struct rte_flow_action_rss *)act->conf; > > - if (!rss || !rss->num) { > + if (!rss || !rss->queue_num) { > rte_flow_error_set(error, EINVAL, > RTE_FLOW_ERROR_TYPE_ACTION, > act, > @@ -1300,7 +1300,7 @@ igb_parse_rss_filter(struct rte_eth_dev *dev, > return -rte_errno; > } > > - for (n = 0; n < rss->num; n++) { > + for (n = 0; n < rss->queue_num; n++) { > if (rss->queue[n] >= dev->data->nb_rx_queues) { > rte_flow_error_set(error, EINVAL, > RTE_FLOW_ERROR_TYPE_ACTION, > @@ -1310,14 +1310,18 @@ igb_parse_rss_filter(struct rte_eth_dev *dev, > } > } > > - if (rss->rss_conf) > - rss_conf->rss_conf = *rss->rss_conf; > - else > - rss_conf->rss_conf.rss_hf = IGB_RSS_OFFLOAD_ALL; > - > - for (n = 0; n < rss->num; ++n) > - rss_conf->queue[n] = rss->queue[n]; > - rss_conf->num = rss->num; > + if (rss->key_len && rss->key_len != RTE_DIM(rss_conf->key)) > + return rte_flow_error_set > + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, > act, > + "RSS hash key must be exactly 40 bytes"); > + if (rss->queue_num > RTE_DIM(rss_conf->queue)) > + return rte_flow_error_set > + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, > act, > + "too many queues for RSS context"); > + if (igb_rss_conf_init(rss_conf, rss)) > + return rte_flow_error_set > + (error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, > act, > + "RSS context initialization failure"); > > /* check if the next not void item is END */ > index++; > @@ -1518,9 +1522,8 @@ igb_flow_create(struct rte_eth_dev *dev, > PMD_DRV_LOG(ERR, "failed to allocate > memory"); > goto out; > } > - rte_memcpy(&rss_filter_ptr->filter_info, > - &rss_conf, > - sizeof(struct igb_rte_flow_rss_conf)); > + igb_rss_conf_init(&rss_filter_ptr->filter_info, > + &rss_conf.conf); > TAILQ_INSERT_TAIL(&igb_filter_rss_list, > rss_filter_ptr, entries); > flow->rule = rss_filter_ptr; > @@ -1757,7 +1760,7 @@ igb_clear_rss_filter(struct rte_eth_dev *dev) > struct e1000_filter_info *filter = > E1000_DEV_PRIVATE_TO_FILTER_INFO(dev->data- > >dev_private); > > - if (filter->rss_info.num) > + if (filter->rss_info.conf.queue_num) > igb_config_rss_filter(dev, &filter->rss_info, FALSE); > } > > diff --git a/drivers/net/e1000/igb_rxtx.c b/drivers/net/e1000/igb_rxtx.c > index 323913f0d..45bb3455c 100644 > --- a/drivers/net/e1000/igb_rxtx.c > +++ b/drivers/net/e1000/igb_rxtx.c > @@ -2898,12 +2898,47 @@ igb_txq_info_get(struct rte_eth_dev *dev, > uint16_t queue_id, > } > > int > +igb_rss_conf_init(struct igb_rte_flow_rss_conf *out, > + const struct rte_flow_action_rss *in) > +{ > + if (in->key_len > RTE_DIM(out->key) || > + in->queue_num > RTE_DIM(out->queue)) > + return -EINVAL; > + out->conf = (struct rte_flow_action_rss){ > + .types = in->types, > + .key_len = in->key_len, > + .queue_num = in->queue_num, > + .key = memcpy(out->key, in->key, in->key_len), > + .queue = memcpy(out->queue, in->queue, > + sizeof(*in->queue) * in->queue_num), > + }; > + return 0; > +} > + > +int > +igb_action_rss_same(const struct rte_flow_action_rss *comp, > + const struct rte_flow_action_rss *with) > +{ > + return (comp->types == with->types && > + comp->key_len == with->key_len && > + comp->queue_num == with->queue_num && > + !memcmp(comp->key, with->key, with->key_len) && > + !memcmp(comp->queue, with->queue, > + sizeof(*with->queue) * with->queue_num)); > +} > + > +int > igb_config_rss_filter(struct rte_eth_dev *dev, > struct igb_rte_flow_rss_conf *conf, bool add) > { > uint32_t shift; > uint16_t i, j; > - struct rte_eth_rss_conf rss_conf = conf->rss_conf; > + struct rte_eth_rss_conf rss_conf = { > + .rss_key = conf->conf.key_len ? > + (void *)(uintptr_t)conf->conf.key : NULL, > + .rss_key_len = conf->conf.key_len, > + .rss_hf = conf->conf.types, > + }; > struct e1000_filter_info *filter_info = > E1000_DEV_PRIVATE_TO_FILTER_INFO(dev->data- > >dev_private); > struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data- > >dev_private); > @@ -2911,8 +2946,8 @@ igb_config_rss_filter(struct rte_eth_dev *dev, > hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private); > > if (!add) { > - if (memcmp(conf, &filter_info->rss_info, > - sizeof(struct igb_rte_flow_rss_conf)) == 0) { > + if (igb_action_rss_same(&filter_info->rss_info.conf, > + &conf->conf)) { > igb_rss_disable(dev); > memset(&filter_info->rss_info, 0, > sizeof(struct igb_rte_flow_rss_conf)); > @@ -2921,7 +2956,7 @@ igb_config_rss_filter(struct rte_eth_dev *dev, > return -EINVAL; > } > > - if (filter_info->rss_info.num) > + if (filter_info->rss_info.conf.queue_num) > return -EINVAL; > > /* Fill in redirection table. */ > @@ -2933,9 +2968,9 @@ igb_config_rss_filter(struct rte_eth_dev *dev, > } reta; > uint8_t q_idx; > > - if (j == conf->num) > + if (j == conf->conf.queue_num) > j = 0; > - q_idx = conf->queue[j]; > + q_idx = conf->conf.queue[j]; > reta.bytes[i & 3] = (uint8_t)(q_idx << shift); > if ((i & 3) == 3) > E1000_WRITE_REG(hw, E1000_RETA(i >> 2), > reta.dword); > @@ -2952,8 +2987,8 @@ igb_config_rss_filter(struct rte_eth_dev *dev, > rss_conf.rss_key = rss_intel_key; /* Default hash key */ > igb_hw_rss_hash_set(hw, &rss_conf); > > - rte_memcpy(&filter_info->rss_info, > - conf, sizeof(struct igb_rte_flow_rss_conf)); > + if (igb_rss_conf_init(&filter_info->rss_info, &conf->conf)) > + return -EINVAL; > > return 0; > } > diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c > index 78f2be7da..50e77901c 100644 > --- a/drivers/net/i40e/i40e_ethdev.c > +++ b/drivers/net/i40e/i40e_ethdev.c > @@ -11,6 +11,7 @@ > #include <inttypes.h> > #include <assert.h> > > +#include <rte_common.h> > #include <rte_eal.h> > #include <rte_string_fns.h> > #include <rte_pci.h> > @@ -11650,7 +11651,7 @@ i40e_rss_filter_restore(struct i40e_pf *pf) > { > struct i40e_rte_flow_rss_conf *conf = > &pf->rss_info; > - if (conf->num) > + if (conf->conf.queue_num) > i40e_config_rss_filter(pf, conf, TRUE); > } > > @@ -12182,18 +12183,52 @@ i40e_cloud_filter_qinq_create(struct i40e_pf > *pf) > } > > int > +i40e_rss_conf_init(struct i40e_rte_flow_rss_conf *out, > + const struct rte_flow_action_rss *in) > +{ > + if (in->key_len > RTE_DIM(out->key) || > + in->queue_num > RTE_DIM(out->queue)) > + return -EINVAL; > + out->conf = (struct rte_flow_action_rss){ > + .types = in->types, > + .key_len = in->key_len, > + .queue_num = in->queue_num, > + .key = memcpy(out->key, in->key, in->key_len), > + .queue = memcpy(out->queue, in->queue, > + sizeof(*in->queue) * in->queue_num), > + }; > + return 0; > +} > + > +int > +i40e_action_rss_same(const struct rte_flow_action_rss *comp, > + const struct rte_flow_action_rss *with) > +{ > + return (comp->types == with->types && > + comp->key_len == with->key_len && > + comp->queue_num == with->queue_num && > + !memcmp(comp->key, with->key, with->key_len) && > + !memcmp(comp->queue, with->queue, > + sizeof(*with->queue) * with->queue_num)); > +} > + > +int > i40e_config_rss_filter(struct i40e_pf *pf, > struct i40e_rte_flow_rss_conf *conf, bool add) > { > struct i40e_hw *hw = I40E_PF_TO_HW(pf); > uint32_t i, lut = 0; > uint16_t j, num; > - struct rte_eth_rss_conf rss_conf = conf->rss_conf; > + struct rte_eth_rss_conf rss_conf = { > + .rss_key = conf->conf.key_len ? > + (void *)(uintptr_t)conf->conf.key : NULL, > + .rss_key_len = conf->conf.key_len, > + .rss_hf = conf->conf.types, > + }; > struct i40e_rte_flow_rss_conf *rss_info = &pf->rss_info; > > if (!add) { > - if (memcmp(conf, rss_info, > - sizeof(struct i40e_rte_flow_rss_conf)) == 0) { > + if (i40e_action_rss_same(&rss_info->conf, &conf->conf)) { > i40e_pf_disable_rss(pf); > memset(rss_info, 0, > sizeof(struct i40e_rte_flow_rss_conf)); > @@ -12202,7 +12237,7 @@ i40e_config_rss_filter(struct i40e_pf *pf, > return -EINVAL; > } > > - if (rss_info->num) > + if (rss_info->conf.queue_num) > return -EINVAL; > > /* If both VMDQ and RSS enabled, not all of PF queues are > configured. > @@ -12213,7 +12248,7 @@ i40e_config_rss_filter(struct i40e_pf *pf, > else > num = pf->dev_data->nb_rx_queues; > > - num = RTE_MIN(num, conf->num); > + num = RTE_MIN(num, conf->conf.queue_num); > PMD_DRV_LOG(INFO, "Max of contiguous %u PF queues are > configured", > num); > > @@ -12226,7 +12261,7 @@ i40e_config_rss_filter(struct i40e_pf *pf, > for (i = 0, j = 0; i < hw->func_caps.rss_table_size; i++, j++) { > if (j == num) > j = 0; > - lut = (lut << 8) | (conf->queue[j] & ((0x1 << > + lut = (lut << 8) | (conf->conf.queue[j] & ((0x1 << > hw->func_caps.rss_table_entry_width) - 1)); > if ((i & 3) == 3) > I40E_WRITE_REG(hw, I40E_PFQF_HLUT(i >> 2), lut); > @@ -12251,8 +12286,8 @@ i40e_config_rss_filter(struct i40e_pf *pf, > > i40e_hw_rss_hash_set(pf, &rss_conf); > > - rte_memcpy(rss_info, > - conf, sizeof(struct i40e_rte_flow_rss_conf)); > + if (i40e_rss_conf_init(rss_info, &conf->conf)) > + return -EINVAL; > > return 0; > } > diff --git a/drivers/net/i40e/i40e_ethdev.h > b/drivers/net/i40e/i40e_ethdev.h > index d33b255e7..a0569d4ae 100644 > --- a/drivers/net/i40e/i40e_ethdev.h > +++ b/drivers/net/i40e/i40e_ethdev.h > @@ -5,14 +5,19 @@ > #ifndef _I40E_ETHDEV_H_ > #define _I40E_ETHDEV_H_ > > +#include <stdint.h> > + > #include <rte_eth_ctrl.h> > #include <rte_time.h> > #include <rte_kvargs.h> > #include <rte_hash.h> > +#include <rte_flow.h> > #include <rte_flow_driver.h> > #include <rte_tm_driver.h> > #include "rte_pmd_i40e.h" > > +#include "base/i40e_register.h" > + > #define I40E_VLAN_TAG_SIZE 4 > > #define I40E_AQ_LEN 32 > @@ -878,9 +883,11 @@ struct i40e_customized_pctype { > }; > > struct i40e_rte_flow_rss_conf { > - struct rte_eth_rss_conf rss_conf; /**< RSS parameters. */ > + struct rte_flow_action_rss conf; /**< RSS parameters. */ > uint16_t queue_region_conf; /**< Queue region config flag */ > - uint16_t num; /**< Number of entries in queue[]. */ > + uint8_t key[(I40E_VFQF_HKEY_MAX_INDEX > > I40E_PFQF_HKEY_MAX_INDEX ? > + I40E_VFQF_HKEY_MAX_INDEX : > I40E_PFQF_HKEY_MAX_INDEX) + 1 * > + sizeof(uint32_t)]; /* Hash key. */ > uint16_t queue[I40E_MAX_Q_PER_TC]; /**< Queues indices to use. > */ > }; > > @@ -1219,6 +1226,10 @@ void i40e_init_queue_region_conf(struct > rte_eth_dev *dev); > void i40e_flex_payload_reg_set_default(struct i40e_hw *hw); > int i40e_set_rss_key(struct i40e_vsi *vsi, uint8_t *key, uint8_t key_len); > int i40e_set_rss_lut(struct i40e_vsi *vsi, uint8_t *lut, uint16_t lut_size); > +int i40e_rss_conf_init(struct i40e_rte_flow_rss_conf *out, > + const struct rte_flow_action_rss *in); > +int i40e_action_rss_same(const struct rte_flow_action_rss *comp, > + const struct rte_flow_action_rss *with); > int i40e_config_rss_filter(struct i40e_pf *pf, > struct i40e_rte_flow_rss_conf *conf, bool add); > > diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c > index d6f5e9923..ec6231003 100644 > --- a/drivers/net/i40e/i40e_flow.c > +++ b/drivers/net/i40e/i40e_flow.c > @@ -4220,7 +4220,7 @@ i40e_flow_parse_rss_action(struct rte_eth_dev > *dev, > > if (action_flag) { > for (n = 0; n < 64; n++) { > - if (rss->rss_conf->rss_hf & (hf_bit << n)) { > + if (rss->types & (hf_bit << n)) { > conf_info->region[0].hw_flowtype[0] = n; > conf_info->region[0].flowtype_num = 1; > conf_info->queue_region_number = 1; > @@ -4236,12 +4236,12 @@ i40e_flow_parse_rss_action(struct rte_eth_dev > *dev, > * queue index for this port. > */ > if (conf_info->queue_region_number) { > - for (i = 0; i < rss->num; i++) { > - for (j = 0; j < rss_info->num; j++) { > - if (rss->queue[i] == rss_info->queue[j]) > + for (i = 0; i < rss->queue_num; i++) { > + for (j = 0; j < rss_info->conf.queue_num; j++) { > + if (rss->queue[i] == rss_info->conf.queue[j]) > break; > } > - if (j == rss_info->num) { > + if (j == rss_info->conf.queue_num) { > rte_flow_error_set(error, EINVAL, > RTE_FLOW_ERROR_TYPE_ACTION, > act, > @@ -4250,7 +4250,7 @@ i40e_flow_parse_rss_action(struct rte_eth_dev > *dev, > } > } > > - for (i = 0; i < rss->num - 1; i++) { > + for (i = 0; i < rss->queue_num - 1; i++) { > if (rss->queue[i + 1] != rss->queue[i] + 1) { > rte_flow_error_set(error, EINVAL, > RTE_FLOW_ERROR_TYPE_ACTION, > @@ -4265,8 +4265,8 @@ i40e_flow_parse_rss_action(struct rte_eth_dev > *dev, > for (n = 0; n < conf_info->queue_region_number; n++) { > if (conf_info->region[n].user_priority_num || > conf_info->region[n].flowtype_num) { > - if (!((rte_is_power_of_2(rss->num)) && > - rss->num <= 64)) { > + if (!((rte_is_power_of_2(rss->queue_num)) && > + rss->queue_num <= 64)) { > rte_flow_error_set(error, EINVAL, > RTE_FLOW_ERROR_TYPE_ACTION, > act, > @@ -4294,7 +4294,8 @@ i40e_flow_parse_rss_action(struct rte_eth_dev > *dev, > } > > for (i = 0; i < info->queue_region_number; i++) { > - if (info->region[i].queue_num == rss->num > && > + if (info->region[i].queue_num == > + rss->queue_num && > info->region[i].queue_start_index == > rss->queue[0]) > break; > @@ -4310,7 +4311,7 @@ i40e_flow_parse_rss_action(struct rte_eth_dev > *dev, > } > > info->region[i].queue_num = > - rss->num; > + rss->queue_num; > info->region[i].queue_start_index = > rss->queue[0]; > info->region[i].region_id = > @@ -4356,7 +4357,7 @@ i40e_flow_parse_rss_action(struct rte_eth_dev > *dev, > if (rss_config->queue_region_conf) > return 0; > > - if (!rss || !rss->num) { > + if (!rss || !rss->queue_num) { > rte_flow_error_set(error, EINVAL, > RTE_FLOW_ERROR_TYPE_ACTION, > act, > @@ -4364,7 +4365,7 @@ i40e_flow_parse_rss_action(struct rte_eth_dev > *dev, > return -rte_errno; > } > > - for (n = 0; n < rss->num; n++) { > + for (n = 0; n < rss->queue_num; n++) { > if (rss->queue[n] >= dev->data->nb_rx_queues) { > rte_flow_error_set(error, EINVAL, > RTE_FLOW_ERROR_TYPE_ACTION, > @@ -4375,15 +4376,19 @@ i40e_flow_parse_rss_action(struct rte_eth_dev > *dev, > } > > /* Parse RSS related parameters from configuration */ > - if (rss->rss_conf) > - rss_config->rss_conf = *rss->rss_conf; > - else > - rss_config->rss_conf.rss_hf = > - pf->adapter->flow_types_mask; > + if (rss->key_len && rss->key_len > RTE_DIM(rss_config->key)) > + return rte_flow_error_set > + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, > act, > + "RSS hash key too large"); > + if (rss->queue_num > RTE_DIM(rss_config->queue)) > + return rte_flow_error_set > + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, > act, > + "too many queues for RSS context"); > + if (i40e_rss_conf_init(rss_config, rss)) > + return rte_flow_error_set > + (error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, > act, > + "RSS context initialization failure"); > > - for (n = 0; n < rss->num; ++n) > - rss_config->queue[n] = rss->queue[n]; > - rss_config->num = rss->num; > index++; > > /* check if the next not void action is END */ > @@ -4903,7 +4908,7 @@ i40e_flow_flush_rss_filter(struct rte_eth_dev *dev) > > ret = i40e_flush_queue_region_all_conf(dev, hw, pf, 0); > > - if (rss_info->num) > + if (rss_info->conf.queue_num) > ret = i40e_config_rss_filter(pf, rss_info, FALSE); > return ret; > } > diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c > b/drivers/net/ixgbe/ixgbe_ethdev.c > index 92434809c..c00bdae3d 100644 > --- a/drivers/net/ixgbe/ixgbe_ethdev.c > +++ b/drivers/net/ixgbe/ixgbe_ethdev.c > @@ -100,8 +100,6 @@ > > #define IXGBE_QUEUE_STAT_COUNTERS (sizeof(hw_stats->qprc) / > sizeof(hw_stats->qprc[0])) > > -#define IXGBE_HKEY_MAX_INDEX 10 > - > /* Additional timesync values. */ > #define NSEC_PER_SEC 1000000000L > #define IXGBE_INCVAL_10GB 0x66666666 > @@ -8371,7 +8369,7 @@ ixgbe_rss_filter_restore(struct rte_eth_dev *dev) > struct ixgbe_filter_info *filter_info = > IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data- > >dev_private); > > - if (filter_info->rss_info.num) > + if (filter_info->rss_info.conf.queue_num) > ixgbe_config_rss_filter(dev, > &filter_info->rss_info, TRUE); > } > diff --git a/drivers/net/ixgbe/ixgbe_ethdev.h > b/drivers/net/ixgbe/ixgbe_ethdev.h > index 655077700..9491b03f4 100644 > --- a/drivers/net/ixgbe/ixgbe_ethdev.h > +++ b/drivers/net/ixgbe/ixgbe_ethdev.h > @@ -4,6 +4,9 @@ > > #ifndef _IXGBE_ETHDEV_H_ > #define _IXGBE_ETHDEV_H_ > + > +#include <stdint.h> > + > #include "base/ixgbe_type.h" > #include "base/ixgbe_dcb.h" > #include "base/ixgbe_dcb_82599.h" > @@ -12,6 +15,7 @@ > #ifdef RTE_LIBRTE_SECURITY > #include "ixgbe_ipsec.h" > #endif > +#include <rte_flow.h> > #include <rte_time.h> > #include <rte_hash.h> > #include <rte_pci.h> > @@ -39,6 +43,7 @@ > #define IXGBE_EXTENDED_VLAN (uint32_t)(1 << 26) /* EXTENDED > VLAN ENABLE */ > #define IXGBE_VFTA_SIZE 128 > #define IXGBE_VLAN_TAG_SIZE 4 > +#define IXGBE_HKEY_MAX_INDEX 10 > #define IXGBE_MAX_RX_QUEUE_NUM 128 > #define IXGBE_MAX_INTR_QUEUE_NUM 15 > #define IXGBE_VMDQ_DCB_NB_QUEUES IXGBE_MAX_RX_QUEUE_NUM > @@ -196,8 +201,8 @@ struct ixgbe_hw_fdir_info { > }; > > struct ixgbe_rte_flow_rss_conf { > - struct rte_eth_rss_conf rss_conf; /**< RSS parameters. */ > - uint16_t num; /**< Number of entries in queue[]. */ > + struct rte_flow_action_rss conf; /**< RSS parameters. */ > + uint8_t key[IXGBE_HKEY_MAX_INDEX * sizeof(uint32_t)]; /* Hash > key. */ > uint16_t queue[IXGBE_MAX_RX_QUEUE_NUM]; /**< Queues > indices to use. */ > }; > > @@ -696,6 +701,10 @@ void ixgbe_tm_conf_init(struct rte_eth_dev *dev); > void ixgbe_tm_conf_uninit(struct rte_eth_dev *dev); > int ixgbe_set_queue_rate_limit(struct rte_eth_dev *dev, uint16_t > queue_idx, > uint16_t tx_rate); > +int ixgbe_rss_conf_init(struct ixgbe_rte_flow_rss_conf *out, > + const struct rte_flow_action_rss *in); > +int ixgbe_action_rss_same(const struct rte_flow_action_rss *comp, > + const struct rte_flow_action_rss *with); > int ixgbe_config_rss_filter(struct rte_eth_dev *dev, > struct ixgbe_rte_flow_rss_conf *conf, bool add); > > diff --git a/drivers/net/ixgbe/ixgbe_flow.c b/drivers/net/ixgbe/ixgbe_flow.c > index abdeac28b..4e31c7c56 100644 > --- a/drivers/net/ixgbe/ixgbe_flow.c > +++ b/drivers/net/ixgbe/ixgbe_flow.c > @@ -2761,7 +2761,7 @@ ixgbe_parse_rss_filter(struct rte_eth_dev *dev, > > rss = (const struct rte_flow_action_rss *)act->conf; > > - if (!rss || !rss->num) { > + if (!rss || !rss->queue_num) { > rte_flow_error_set(error, EINVAL, > RTE_FLOW_ERROR_TYPE_ACTION, > act, > @@ -2769,7 +2769,7 @@ ixgbe_parse_rss_filter(struct rte_eth_dev *dev, > return -rte_errno; > } > > - for (n = 0; n < rss->num; n++) { > + for (n = 0; n < rss->queue_num; n++) { > if (rss->queue[n] >= dev->data->nb_rx_queues) { > rte_flow_error_set(error, EINVAL, > RTE_FLOW_ERROR_TYPE_ACTION, > @@ -2778,14 +2778,19 @@ ixgbe_parse_rss_filter(struct rte_eth_dev *dev, > return -rte_errno; > } > } > - if (rss->rss_conf) > - rss_conf->rss_conf = *rss->rss_conf; > - else > - rss_conf->rss_conf.rss_hf = IXGBE_RSS_OFFLOAD_ALL; > > - for (n = 0; n < rss->num; ++n) > - rss_conf->queue[n] = rss->queue[n]; > - rss_conf->num = rss->num; > + if (rss->key_len && rss->key_len != RTE_DIM(rss_conf->key)) > + return rte_flow_error_set > + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, > act, > + "RSS hash key must be exactly 40 bytes"); > + if (rss->queue_num > RTE_DIM(rss_conf->queue)) > + return rte_flow_error_set > + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, > act, > + "too many queues for RSS context"); > + if (ixgbe_rss_conf_init(rss_conf, rss)) > + return rte_flow_error_set > + (error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, > act, > + "RSS context initialization failure"); > > /* check if the next not void item is END */ > act = next_no_void_action(actions, act); > @@ -2834,7 +2839,7 @@ ixgbe_clear_rss_filter(struct rte_eth_dev *dev) > struct ixgbe_filter_info *filter_info = > IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data- > >dev_private); > > - if (filter_info->rss_info.num) > + if (filter_info->rss_info.conf.queue_num) > ixgbe_config_rss_filter(dev, &filter_info->rss_info, FALSE); > } > > @@ -3153,9 +3158,8 @@ ixgbe_flow_create(struct rte_eth_dev *dev, > PMD_DRV_LOG(ERR, "failed to allocate > memory"); > goto out; > } > - rte_memcpy(&rss_filter_ptr->filter_info, > - &rss_conf, > - sizeof(struct ixgbe_rte_flow_rss_conf)); > + ixgbe_rss_conf_init(&rss_filter_ptr->filter_info, > + &rss_conf.conf); > TAILQ_INSERT_TAIL(&filter_rss_list, > rss_filter_ptr, entries); > flow->rule = rss_filter_ptr; > diff --git a/drivers/net/ixgbe/ixgbe_rxtx.c b/drivers/net/ixgbe/ixgbe_rxtx.c > index aed3f5a9a..9fbd7dbd7 100644 > --- a/drivers/net/ixgbe/ixgbe_rxtx.c > +++ b/drivers/net/ixgbe/ixgbe_rxtx.c > @@ -5676,6 +5676,36 @@ ixgbevf_dev_rxtx_start(struct rte_eth_dev *dev) > } > > int > +ixgbe_rss_conf_init(struct ixgbe_rte_flow_rss_conf *out, > + const struct rte_flow_action_rss *in) > +{ > + if (in->key_len > RTE_DIM(out->key) || > + in->queue_num > RTE_DIM(out->queue)) > + return -EINVAL; > + out->conf = (struct rte_flow_action_rss){ > + .types = in->types, > + .key_len = in->key_len, > + .queue_num = in->queue_num, > + .key = memcpy(out->key, in->key, in->key_len), > + .queue = memcpy(out->queue, in->queue, > + sizeof(*in->queue) * in->queue_num), > + }; > + return 0; > +} > + > +int > +ixgbe_action_rss_same(const struct rte_flow_action_rss *comp, > + const struct rte_flow_action_rss *with) > +{ > + return (comp->types == with->types && > + comp->key_len == with->key_len && > + comp->queue_num == with->queue_num && > + !memcmp(comp->key, with->key, with->key_len) && > + !memcmp(comp->queue, with->queue, > + sizeof(*with->queue) * with->queue_num)); > +} > + > +int > ixgbe_config_rss_filter(struct rte_eth_dev *dev, > struct ixgbe_rte_flow_rss_conf *conf, bool add) > { > @@ -5685,7 +5715,12 @@ ixgbe_config_rss_filter(struct rte_eth_dev *dev, > uint16_t j; > uint16_t sp_reta_size; > uint32_t reta_reg; > - struct rte_eth_rss_conf rss_conf = conf->rss_conf; > + struct rte_eth_rss_conf rss_conf = { > + .rss_key = conf->conf.key_len ? > + (void *)(uintptr_t)conf->conf.key : NULL, > + .rss_key_len = conf->conf.key_len, > + .rss_hf = conf->conf.types, > + }; > struct ixgbe_filter_info *filter_info = > IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data- > >dev_private); > > @@ -5695,8 +5730,8 @@ ixgbe_config_rss_filter(struct rte_eth_dev *dev, > sp_reta_size = ixgbe_reta_size_get(hw->mac.type); > > if (!add) { > - if (memcmp(conf, &filter_info->rss_info, > - sizeof(struct ixgbe_rte_flow_rss_conf)) == 0) { > + if (ixgbe_action_rss_same(&filter_info->rss_info.conf, > + &conf->conf)) { > ixgbe_rss_disable(dev); > memset(&filter_info->rss_info, 0, > sizeof(struct ixgbe_rte_flow_rss_conf)); > @@ -5705,7 +5740,7 @@ ixgbe_config_rss_filter(struct rte_eth_dev *dev, > return -EINVAL; > } > > - if (filter_info->rss_info.num) > + if (filter_info->rss_info.conf.queue_num) > return -EINVAL; > /* Fill in redirection table > * The byte-swap is needed because NIC registers are in > @@ -5715,9 +5750,9 @@ ixgbe_config_rss_filter(struct rte_eth_dev *dev, > for (i = 0, j = 0; i < sp_reta_size; i++, j++) { > reta_reg = ixgbe_reta_reg_get(hw->mac.type, i); > > - if (j == conf->num) > + if (j == conf->conf.queue_num) > j = 0; > - reta = (reta << 8) | conf->queue[j]; > + reta = (reta << 8) | conf->conf.queue[j]; > if ((i & 3) == 3) > IXGBE_WRITE_REG(hw, reta_reg, > rte_bswap32(reta)); > @@ -5734,8 +5769,8 @@ ixgbe_config_rss_filter(struct rte_eth_dev *dev, > rss_conf.rss_key = rss_intel_key; /* Default hash key */ > ixgbe_hw_rss_hash_set(hw, &rss_conf); > > - rte_memcpy(&filter_info->rss_info, > - conf, sizeof(struct ixgbe_rte_flow_rss_conf)); > + if (ixgbe_rss_conf_init(&filter_info->rss_info, &conf->conf)) > + return -EINVAL; > > return 0; > } > diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c > index 937074a4f..3dd72dbf5 100644 > --- a/drivers/net/mlx4/mlx4.c > +++ b/drivers/net/mlx4/mlx4.c > @@ -571,7 +571,7 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct > rte_pci_device *pci_dev) > " for UDP RSS and inner VXLAN RSS"); > /* Fake support for all possible RSS hash fields. */ > priv->hw_rss_sup = ~UINT64_C(0); > - priv->hw_rss_sup = mlx4_conv_rss_hf(priv, -1); > + priv->hw_rss_sup = mlx4_conv_rss_types(priv, -1); > /* Filter out known unsupported fields. */ > priv->hw_rss_sup &= > ~(uint64_t)(IBV_RX_HASH_SRC_PORT_UDP | > diff --git a/drivers/net/mlx4/mlx4_flow.c b/drivers/net/mlx4/mlx4_flow.c > index 8feb6ae31..dd86e4ce7 100644 > --- a/drivers/net/mlx4/mlx4_flow.c > +++ b/drivers/net/mlx4/mlx4_flow.c > @@ -76,22 +76,22 @@ struct mlx4_drop { > }; > > /** > - * Convert DPDK RSS hash fields to their Verbs equivalent. > + * Convert DPDK RSS hash types to their Verbs equivalent. > * > - * This function returns the supported (default) set when @p rss_hf has > + * This function returns the supported (default) set when @p types has > * special value (uint64_t)-1. > * > * @param priv > * Pointer to private structure. > - * @param rss_hf > - * Hash fields in DPDK format (see struct rte_eth_rss_conf). > + * @param types > + * Hash types in DPDK format (see struct rte_eth_rss_conf). > * > * @return > * A valid Verbs RSS hash fields mask for mlx4 on success, (uint64_t)-1 > * otherwise and rte_errno is set. > */ > uint64_t > -mlx4_conv_rss_hf(struct priv *priv, uint64_t rss_hf) > +mlx4_conv_rss_types(struct priv *priv, uint64_t types) > { > enum { IPV4, IPV6, TCP, UDP, }; > const uint64_t in[] = { > @@ -126,17 +126,17 @@ mlx4_conv_rss_hf(struct priv *priv, uint64_t rss_hf) > unsigned int i; > > for (i = 0; i != RTE_DIM(in); ++i) > - if (rss_hf & in[i]) { > - seen |= rss_hf & in[i]; > + if (types & in[i]) { > + seen |= types & in[i]; > conv |= out[i]; > } > if ((conv & priv->hw_rss_sup) == conv) { > - if (rss_hf == (uint64_t)-1) { > + if (types == (uint64_t)-1) { > /* Include inner RSS by default if supported. */ > conv |= priv->hw_rss_sup & IBV_RX_HASH_INNER; > return conv; > } > - if (!(rss_hf & ~seen)) > + if (!(types & ~seen)) > return conv; > } > rte_errno = ENOTSUP; > @@ -717,7 +717,8 @@ mlx4_flow_prepare(struct priv *priv, > switch (action->type) { > const struct rte_flow_action_queue *queue; > const struct rte_flow_action_rss *rss; > - const struct rte_eth_rss_conf *rss_conf; > + const uint8_t *rss_key; > + uint32_t rss_key_len; > uint64_t fields; > unsigned int i; > > @@ -747,58 +748,56 @@ mlx4_flow_prepare(struct priv *priv, > break; > rss = action->conf; > /* Default RSS configuration if none is provided. */ > - rss_conf = > - rss->rss_conf ? > - rss->rss_conf : > - &(struct rte_eth_rss_conf){ > - .rss_key = > mlx4_rss_hash_key_default, > - .rss_key_len = > MLX4_RSS_HASH_KEY_SIZE, > - .rss_hf = -1, > - }; > + if (rss->key_len) { > + rss_key = rss->key; > + rss_key_len = rss->key_len; > + } else { > + rss_key = mlx4_rss_hash_key_default; > + rss_key_len = MLX4_RSS_HASH_KEY_SIZE; > + } > /* Sanity checks. */ > - for (i = 0; i < rss->num; ++i) > + for (i = 0; i < rss->queue_num; ++i) > if (rss->queue[i] >= > priv->dev->data->nb_rx_queues) > break; > - if (i != rss->num) { > + if (i != rss->queue_num) { > msg = "queue index target beyond number > of" > " configured Rx queues"; > goto exit_action_not_supported; > } > - if (!rte_is_power_of_2(rss->num)) { > + if (!rte_is_power_of_2(rss->queue_num)) { > msg = "for RSS, mlx4 requires the number of" > " queues to be a power of two"; > goto exit_action_not_supported; > } > - if (rss_conf->rss_key_len != > - sizeof(flow->rss->key)) { > + if (rss_key_len != sizeof(flow->rss->key)) { > msg = "mlx4 supports exactly one RSS hash > key" > " length: " > > MLX4_STR_EXPAND(MLX4_RSS_HASH_KEY_SIZE); > goto exit_action_not_supported; > } > - for (i = 1; i < rss->num; ++i) > + for (i = 1; i < rss->queue_num; ++i) > if (rss->queue[i] - rss->queue[i - 1] != 1) > break; > - if (i != rss->num) { > + if (i != rss->queue_num) { > msg = "mlx4 requires RSS contexts to use" > " consecutive queue indices only"; > goto exit_action_not_supported; > } > - if (rss->queue[0] % rss->num) { > + if (rss->queue[0] % rss->queue_num) { > msg = "mlx4 requires the first queue of a > RSS" > " context to be aligned on a multiple" > " of the context size"; > goto exit_action_not_supported; > } > rte_errno = 0; > - fields = mlx4_conv_rss_hf(priv, rss_conf->rss_hf); > + fields = mlx4_conv_rss_types(priv, rss->types); > if (fields == (uint64_t)-1 && rte_errno) { > msg = "unsupported RSS hash type > requested"; > goto exit_action_not_supported; > } > flow->rss = mlx4_rss_get > - (priv, fields, rss_conf->rss_key, rss->num, > + (priv, fields, rss_key, rss->queue_num, > rss->queue); > if (!flow->rss) { > msg = "either invalid parameters or not > enough" > @@ -1284,8 +1283,10 @@ mlx4_flow_internal(struct priv *priv, struct > rte_flow_error *error) > rte_align32pow2(priv->dev->data->nb_rx_queues + 1) >> 1; > uint16_t queue[queues]; > struct rte_flow_action_rss action_rss = { > - .rss_conf = NULL, /* Rely on default fallback settings. */ > - .num = queues, > + .types = -1, > + .key_len = MLX4_RSS_HASH_KEY_SIZE, > + .queue_num = queues, > + .key = mlx4_rss_hash_key_default, > .queue = queue, > }; > struct rte_flow_action actions[] = { > diff --git a/drivers/net/mlx4/mlx4_flow.h b/drivers/net/mlx4/mlx4_flow.h > index 4e3889e67..7b83d74b0 100644 > --- a/drivers/net/mlx4/mlx4_flow.h > +++ b/drivers/net/mlx4/mlx4_flow.h > @@ -47,7 +47,7 @@ struct rte_flow { > > /* mlx4_flow.c */ > > -uint64_t mlx4_conv_rss_hf(struct priv *priv, uint64_t rss_hf); > +uint64_t mlx4_conv_rss_types(struct priv *priv, uint64_t rss_hf); > int mlx4_flow_sync(struct priv *priv, struct rte_flow_error *error); > void mlx4_flow_clean(struct priv *priv); > int mlx4_filter_ctrl(struct rte_eth_dev *dev, > diff --git a/drivers/net/mlx4/mlx4_rxq.c b/drivers/net/mlx4/mlx4_rxq.c > index a7acc047b..65f099423 100644 > --- a/drivers/net/mlx4/mlx4_rxq.c > +++ b/drivers/net/mlx4/mlx4_rxq.c > @@ -88,7 +88,7 @@ > mlx4_rss_hash_key_default[MLX4_RSS_HASH_KEY_SIZE] = { > */ > struct mlx4_rss * > mlx4_rss_get(struct priv *priv, uint64_t fields, > - uint8_t key[MLX4_RSS_HASH_KEY_SIZE], > + const uint8_t key[MLX4_RSS_HASH_KEY_SIZE], > uint16_t queues, const uint16_t queue_id[]) > { > struct mlx4_rss *rss; > diff --git a/drivers/net/mlx4/mlx4_rxtx.h b/drivers/net/mlx4/mlx4_rxtx.h > index b1af86110..2dfee957f 100644 > --- a/drivers/net/mlx4/mlx4_rxtx.h > +++ b/drivers/net/mlx4/mlx4_rxtx.h > @@ -127,7 +127,7 @@ uint8_t > mlx4_rss_hash_key_default[MLX4_RSS_HASH_KEY_SIZE]; > int mlx4_rss_init(struct priv *priv); > void mlx4_rss_deinit(struct priv *priv); > struct mlx4_rss *mlx4_rss_get(struct priv *priv, uint64_t fields, > - uint8_t key[MLX4_RSS_HASH_KEY_SIZE], > + const uint8_t key[MLX4_RSS_HASH_KEY_SIZE], > uint16_t queues, const uint16_t queue_id[]); > void mlx4_rss_put(struct mlx4_rss *rss); > int mlx4_rss_attach(struct mlx4_rss *rss); > diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c > index 0c89bff45..af8853e09 100644 > --- a/drivers/net/mlx5/mlx5_flow.c > +++ b/drivers/net/mlx5/mlx5_flow.c > @@ -214,9 +214,8 @@ struct rte_flow { > TAILQ_ENTRY(rte_flow) next; /**< Pointer to the next flow structure. > */ > uint32_t mark:1; /**< Set if the flow is marked. */ > uint32_t drop:1; /**< Drop queue. */ > - uint16_t queues_n; /**< Number of entries in queue[]. */ > + struct rte_flow_action_rss rss_conf; /**< RSS configuration */ > uint16_t (*queues)[]; /**< Queues indexes to use. */ > - struct rte_eth_rss_conf rss_conf; /**< RSS configuration */ > uint8_t rss_key[40]; /**< copy of the RSS key. */ > struct ibv_counter_set *cs; /**< Holds the counters for the rule. */ > struct mlx5_flow_counter_stats counter_stats;/**<The counter > stats. */ > @@ -406,9 +405,8 @@ struct mlx5_flow_parse { > uint32_t mark:1; /**< Mark is present in the flow. */ > uint32_t count:1; /**< Count is present in the flow. */ > uint32_t mark_id; /**< Mark identifier. */ > + struct rte_flow_action_rss rss_conf; /**< RSS configuration */ > uint16_t queues[RTE_MAX_QUEUES_PER_PORT]; /**< Queues > indexes to use. */ > - uint16_t queues_n; /**< Number of entries in queue[]. */ > - struct rte_eth_rss_conf rss_conf; /**< RSS configuration */ > uint8_t rss_key[40]; /**< copy of the RSS key. */ > enum hash_rxq_type layer; /**< Last pattern layer detected. */ > struct ibv_counter_set *cs; /**< Holds the counter set for the rule */ > @@ -540,47 +538,6 @@ mlx5_flow_item_validate(const struct > rte_flow_item *item, > } > > /** > - * Copy the RSS configuration from the user ones, of the rss_conf is null, > - * uses the driver one. > - * > - * @param parser > - * Internal parser structure. > - * @param rss_conf > - * User RSS configuration to save. > - * > - * @return > - * 0 on success, a negative errno value otherwise and rte_errno is set. > - */ > -static int > -mlx5_flow_convert_rss_conf(struct mlx5_flow_parse *parser, > - const struct rte_eth_rss_conf *rss_conf) > -{ > - /* > - * This function is also called at the beginning of > - * mlx5_flow_convert_actions() to initialize the parser with the > - * device default RSS configuration. > - */ > - if (rss_conf) { > - if (rss_conf->rss_hf & MLX5_RSS_HF_MASK) { > - rte_errno = EINVAL; > - return -rte_errno; > - } > - if (rss_conf->rss_key_len != 40) { > - rte_errno = EINVAL; > - return -rte_errno; > - } > - if (rss_conf->rss_key_len && rss_conf->rss_key) { > - parser->rss_conf.rss_key_len = rss_conf- > >rss_key_len; > - memcpy(parser->rss_key, rss_conf->rss_key, > - rss_conf->rss_key_len); > - parser->rss_conf.rss_key = parser->rss_key; > - } > - parser->rss_conf.rss_hf = rss_conf->rss_hf; > - } > - return 0; > -} > - > -/** > * Extract attribute to the parser. > * > * @param[in] attr > @@ -650,17 +607,7 @@ mlx5_flow_convert_actions(struct rte_eth_dev > *dev, > enum { FATE = 1, MARK = 2, COUNT = 4, }; > uint32_t overlap = 0; > struct priv *priv = dev->data->dev_private; > - int ret; > > - /* > - * Add default RSS configuration necessary for Verbs to create QP > even > - * if no RSS is necessary. > - */ > - ret = mlx5_flow_convert_rss_conf(parser, > - (const struct rte_eth_rss_conf *) > - &priv->rss_conf); > - if (ret) > - return ret; > for (; actions->type != RTE_FLOW_ACTION_TYPE_END; ++actions) { > if (actions->type == RTE_FLOW_ACTION_TYPE_VOID) { > continue; > @@ -679,25 +626,53 @@ mlx5_flow_convert_actions(struct rte_eth_dev > *dev, > overlap |= FATE; > if (!queue || (queue->index > (priv->rxqs_n - 1))) > goto exit_action_not_supported; > - parser->queues_n = 1; > parser->queues[0] = queue->index; > + parser->rss_conf = (struct rte_flow_action_rss){ > + .queue_num = 1, > + .queue = parser->queues, > + }; > } else if (actions->type == RTE_FLOW_ACTION_TYPE_RSS) { > const struct rte_flow_action_rss *rss = > (const struct rte_flow_action_rss *) > actions->conf; > + const uint8_t *rss_key; > + uint32_t rss_key_len; > uint16_t n; > > if (overlap & FATE) > goto exit_action_overlap; > overlap |= FATE; > - if (!rss || !rss->num) { > + if (rss->types & MLX5_RSS_HF_MASK) { > + rte_flow_error_set(error, EINVAL, > + > RTE_FLOW_ERROR_TYPE_ACTION, > + actions, > + "unsupported RSS type" > + " requested"); > + return -rte_errno; > + } > + if (rss->key_len) { > + rss_key_len = rss->key_len; > + rss_key = rss->key; > + } else { > + rss_key_len = rss_hash_default_key_len; > + rss_key = rss_hash_default_key; > + } > + if (rss_key_len != RTE_DIM(parser->rss_key)) { > + rte_flow_error_set(error, EINVAL, > + > RTE_FLOW_ERROR_TYPE_ACTION, > + actions, > + "RSS hash key must be" > + " exactly 40 bytes long"); > + return -rte_errno; > + } > + if (!rss->queue_num) { > rte_flow_error_set(error, EINVAL, > > RTE_FLOW_ERROR_TYPE_ACTION, > actions, > "no valid queues"); > return -rte_errno; > } > - if (rss->num > RTE_DIM(parser->queues)) { > + if (rss->queue_num > RTE_DIM(parser->queues)) { > rte_flow_error_set(error, EINVAL, > > RTE_FLOW_ERROR_TYPE_ACTION, > actions, > @@ -705,7 +680,7 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, > " context"); > return -rte_errno; > } > - for (n = 0; n < rss->num; ++n) { > + for (n = 0; n < rss->queue_num; ++n) { > if (rss->queue[n] >= priv->rxqs_n) { > rte_flow_error_set(error, EINVAL, > > RTE_FLOW_ERROR_TYPE_ACTION, > @@ -715,16 +690,16 @@ mlx5_flow_convert_actions(struct rte_eth_dev > *dev, > return -rte_errno; > } > } > - for (n = 0; n < rss->num; ++n) > - parser->queues[n] = rss->queue[n]; > - parser->queues_n = rss->num; > - if (mlx5_flow_convert_rss_conf(parser, rss- > >rss_conf)) { > - rte_flow_error_set(error, EINVAL, > - > RTE_FLOW_ERROR_TYPE_ACTION, > - actions, > - "wrong RSS configuration"); > - return -rte_errno; > - } > + parser->rss_conf = (struct rte_flow_action_rss){ > + .types = rss->types, > + .key_len = rss_key_len, > + .queue_num = rss->queue_num, > + .key = memcpy(parser->rss_key, rss_key, > + sizeof(*rss_key) * rss_key_len), > + .queue = memcpy(parser->queues, rss- > >queue, > + sizeof(*rss->queue) * > + rss->queue_num), > + }; > } else if (actions->type == RTE_FLOW_ACTION_TYPE_MARK) > { > const struct rte_flow_action_mark *mark = > (const struct rte_flow_action_mark *) > @@ -769,7 +744,7 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, > parser->drop = 1; > if (parser->drop && parser->mark) > parser->mark = 0; > - if (!parser->queues_n && !parser->drop) { > + if (!parser->rss_conf.queue_num && !parser->drop) { > rte_flow_error_set(error, ENOTSUP, > RTE_FLOW_ERROR_TYPE_HANDLE, > NULL, "no valid action"); > return -rte_errno; > @@ -951,7 +926,7 @@ mlx5_flow_convert_finalise(struct mlx5_flow_parse > *parser) > unsigned int i; > > /* Remove any other flow not matching the pattern. */ > - if (parser->queues_n == 1 && !parser->rss_conf.rss_hf) { > + if (parser->rss_conf.queue_num == 1 && !parser->rss_conf.types) { > for (i = 0; i != hash_rxq_init_n; ++i) { > if (i == HASH_RXQ_ETH) > continue; > @@ -979,7 +954,7 @@ mlx5_flow_convert_finalise(struct mlx5_flow_parse > *parser) > } > /* Remove impossible flow according to the RSS configuration. */ > if (hash_rxq_init[parser->layer].dpdk_rss_hf & > - parser->rss_conf.rss_hf) { > + parser->rss_conf.types) { > /* Remove any other flow. */ > for (i = hmin; i != (hmax + 1); ++i) { > if ((i == parser->layer) || > @@ -990,7 +965,7 @@ mlx5_flow_convert_finalise(struct mlx5_flow_parse > *parser) > } > } else if (!parser->queue[ip].ibv_attr) { > /* no RSS possible with the current configuration. */ > - parser->queues_n = 1; > + parser->rss_conf.queue_num = 1; > return; > } > fill: > @@ -1119,7 +1094,7 @@ mlx5_flow_convert(struct rte_eth_dev *dev, > for (i = 0; i != hash_rxq_init_n; ++i) { > unsigned int offset; > > - if (!(parser->rss_conf.rss_hf & > + if (!(parser->rss_conf.types & > hash_rxq_init[i].dpdk_rss_hf) && > (i != HASH_RXQ_ETH)) > continue; > @@ -1787,20 +1762,20 @@ mlx5_flow_create_action_queue_rss(struct > rte_eth_dev *dev, > continue; > flow->frxq[i].hrxq = > mlx5_hrxq_get(dev, > - parser->rss_conf.rss_key, > - parser->rss_conf.rss_key_len, > + parser->rss_conf.key, > + parser->rss_conf.key_len, > hash_fields, > - parser->queues, > - parser->queues_n); > + parser->rss_conf.queue, > + parser->rss_conf.queue_num); > if (flow->frxq[i].hrxq) > continue; > flow->frxq[i].hrxq = > mlx5_hrxq_new(dev, > - parser->rss_conf.rss_key, > - parser->rss_conf.rss_key_len, > + parser->rss_conf.key, > + parser->rss_conf.key_len, > hash_fields, > - parser->queues, > - parser->queues_n); > + parser->rss_conf.queue, > + parser->rss_conf.queue_num); > if (!flow->frxq[i].hrxq) { > return rte_flow_error_set(error, ENOMEM, > > RTE_FLOW_ERROR_TYPE_HANDLE, > @@ -1871,9 +1846,9 @@ mlx5_flow_create_action_queue(struct > rte_eth_dev *dev, > NULL, "internal error in flow creation"); > goto error; > } > - for (i = 0; i != parser->queues_n; ++i) { > + for (i = 0; i != parser->rss_conf.queue_num; ++i) { > struct mlx5_rxq_data *q = > - (*priv->rxqs)[parser->queues[i]]; > + (*priv->rxqs)[parser->rss_conf.queue[i]]; > > q->mark |= parser->mark; > } > @@ -1937,7 +1912,8 @@ mlx5_flow_list_create(struct rte_eth_dev *dev, > if (ret) > goto exit; > flow = rte_calloc(__func__, 1, > - sizeof(*flow) + parser.queues_n * sizeof(uint16_t), > + sizeof(*flow) + > + parser.rss_conf.queue_num * sizeof(uint16_t), > 0); > if (!flow) { > rte_flow_error_set(error, ENOMEM, > @@ -1946,15 +1922,20 @@ mlx5_flow_list_create(struct rte_eth_dev *dev, > "cannot allocate flow memory"); > return NULL; > } > - /* Copy queues configuration. */ > + /* Copy configuration. */ > flow->queues = (uint16_t (*)[])(flow + 1); > - memcpy(flow->queues, parser.queues, parser.queues_n * > sizeof(uint16_t)); > - flow->queues_n = parser.queues_n; > + flow->rss_conf = (struct rte_flow_action_rss){ > + .types = parser.rss_conf.types, > + .key_len = parser.rss_conf.key_len, > + .queue_num = parser.rss_conf.queue_num, > + .key = memcpy(flow->rss_key, parser.rss_conf.key, > + sizeof(*parser.rss_conf.key) * > + parser.rss_conf.key_len), > + .queue = memcpy(flow->queues, parser.rss_conf.queue, > + sizeof(*parser.rss_conf.queue) * > + parser.rss_conf.queue_num), > + }; > flow->mark = parser.mark; > - /* Copy RSS configuration. */ > - flow->rss_conf = parser.rss_conf; > - flow->rss_conf.rss_key = flow->rss_key; > - memcpy(flow->rss_key, parser.rss_key, > parser.rss_conf.rss_key_len); > /* finalise the flow. */ > if (parser.drop) > ret = mlx5_flow_create_action_queue_drop(dev, &parser, > flow, > @@ -2034,7 +2015,7 @@ mlx5_flow_list_destroy(struct rte_eth_dev *dev, > struct mlx5_flows *list, > > if (flow->drop || !flow->mark) > goto free; > - for (i = 0; i != flow->queues_n; ++i) { > + for (i = 0; i != flow->rss_conf.queue_num; ++i) { > struct rte_flow *tmp; > int mark = 0; > > @@ -2344,19 +2325,19 @@ mlx5_flow_start(struct rte_eth_dev *dev, struct > mlx5_flows *list) > if (!flow->frxq[i].ibv_attr) > continue; > flow->frxq[i].hrxq = > - mlx5_hrxq_get(dev, flow->rss_conf.rss_key, > - flow->rss_conf.rss_key_len, > + mlx5_hrxq_get(dev, flow->rss_conf.key, > + flow->rss_conf.key_len, > hash_rxq_init[i].hash_fields, > - (*flow->queues), > - flow->queues_n); > + flow->rss_conf.queue, > + flow->rss_conf.queue_num); > if (flow->frxq[i].hrxq) > goto flow_create; > flow->frxq[i].hrxq = > - mlx5_hrxq_new(dev, flow->rss_conf.rss_key, > - flow->rss_conf.rss_key_len, > + mlx5_hrxq_new(dev, flow->rss_conf.key, > + flow->rss_conf.key_len, > hash_rxq_init[i].hash_fields, > - (*flow->queues), > - flow->queues_n); > + flow->rss_conf.queue, > + flow->rss_conf.queue_num); > if (!flow->frxq[i].hrxq) { > DRV_LOG(DEBUG, > "port %u flow %p cannot be applied", > @@ -2380,8 +2361,8 @@ mlx5_flow_start(struct rte_eth_dev *dev, struct > mlx5_flows *list) > } > if (!flow->mark) > continue; > - for (i = 0; i != flow->queues_n; ++i) > - (*priv->rxqs)[(*flow->queues)[i]]->mark = 1; > + for (i = 0; i != flow->rss_conf.queue_num; ++i) > + (*priv->rxqs)[flow->rss_conf.queue[i]]->mark = 1; > } > return 0; > } > @@ -2458,8 +2439,10 @@ mlx5_ctrl_flow_vlan(struct rte_eth_dev *dev, > }; > uint16_t queue[priv->reta_idx_n]; > struct rte_flow_action_rss action_rss = { > - .rss_conf = &priv->rss_conf, > - .num = priv->reta_idx_n, > + .types = priv->rss_conf.rss_hf, > + .key_len = priv->rss_conf.rss_key_len, > + .queue_num = priv->reta_idx_n, > + .key = priv->rss_conf.rss_key, > .queue = queue, > }; > struct rte_flow_action actions[] = { > diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c > index eda3ba3d5..d2b25e8e8 100644 > --- a/drivers/net/mlx5/mlx5_rxq.c > +++ b/drivers/net/mlx5/mlx5_rxq.c > @@ -1218,8 +1218,8 @@ mlx5_rxq_verify(struct rte_eth_dev *dev) > * The Verbs object initialised, NULL otherwise and rte_errno is set. > */ > struct mlx5_ind_table_ibv * > -mlx5_ind_table_ibv_new(struct rte_eth_dev *dev, uint16_t queues[], > - uint16_t queues_n) > +mlx5_ind_table_ibv_new(struct rte_eth_dev *dev, const uint16_t *queues, > + uint32_t queues_n) > { > struct priv *priv = dev->data->dev_private; > struct mlx5_ind_table_ibv *ind_tbl; > @@ -1286,8 +1286,8 @@ mlx5_ind_table_ibv_new(struct rte_eth_dev *dev, > uint16_t queues[], > * An indirection table if found. > */ > struct mlx5_ind_table_ibv * > -mlx5_ind_table_ibv_get(struct rte_eth_dev *dev, uint16_t queues[], > - uint16_t queues_n) > +mlx5_ind_table_ibv_get(struct rte_eth_dev *dev, const uint16_t *queues, > + uint32_t queues_n) > { > struct priv *priv = dev->data->dev_private; > struct mlx5_ind_table_ibv *ind_tbl; > @@ -1391,8 +1391,10 @@ mlx5_ind_table_ibv_verify(struct rte_eth_dev > *dev) > * The Verbs object initialised, NULL otherwise and rte_errno is set. > */ > struct mlx5_hrxq * > -mlx5_hrxq_new(struct rte_eth_dev *dev, uint8_t *rss_key, uint8_t > rss_key_len, > - uint64_t hash_fields, uint16_t queues[], uint16_t queues_n) > +mlx5_hrxq_new(struct rte_eth_dev *dev, > + const uint8_t *rss_key, uint32_t rss_key_len, > + uint64_t hash_fields, > + const uint16_t *queues, uint32_t queues_n) > { > struct priv *priv = dev->data->dev_private; > struct mlx5_hrxq *hrxq; > @@ -1408,6 +1410,10 @@ mlx5_hrxq_new(struct rte_eth_dev *dev, uint8_t > *rss_key, uint8_t rss_key_len, > rte_errno = ENOMEM; > return NULL; > } > + if (!rss_key_len) { > + rss_key_len = rss_hash_default_key_len; > + rss_key = rss_hash_default_key; > + } > qp = mlx5_glue->create_qp_ex > (priv->ctx, > &(struct ibv_qp_init_attr_ex){ > @@ -1419,7 +1425,7 @@ mlx5_hrxq_new(struct rte_eth_dev *dev, uint8_t > *rss_key, uint8_t rss_key_len, > .rx_hash_conf = (struct ibv_rx_hash_conf){ > .rx_hash_function = > IBV_RX_HASH_FUNC_TOEPLITZ, > .rx_hash_key_len = rss_key_len, > - .rx_hash_key = rss_key, > + .rx_hash_key = (void *)(uintptr_t)rss_key, > .rx_hash_fields_mask = hash_fields, > }, > .rwq_ind_tbl = ind_tbl->ind_table, > @@ -1469,8 +1475,10 @@ mlx5_hrxq_new(struct rte_eth_dev *dev, uint8_t > *rss_key, uint8_t rss_key_len, > * An hash Rx queue on success. > */ > struct mlx5_hrxq * > -mlx5_hrxq_get(struct rte_eth_dev *dev, uint8_t *rss_key, uint8_t > rss_key_len, > - uint64_t hash_fields, uint16_t queues[], uint16_t queues_n) > +mlx5_hrxq_get(struct rte_eth_dev *dev, > + const uint8_t *rss_key, uint32_t rss_key_len, > + uint64_t hash_fields, > + const uint16_t *queues, uint32_t queues_n) > { > struct priv *priv = dev->data->dev_private; > struct mlx5_hrxq *hrxq; > diff --git a/drivers/net/mlx5/mlx5_rxtx.h b/drivers/net/mlx5/mlx5_rxtx.h > index 14d4418d9..c3a1ae213 100644 > --- a/drivers/net/mlx5/mlx5_rxtx.h > +++ b/drivers/net/mlx5/mlx5_rxtx.h > @@ -134,7 +134,7 @@ struct mlx5_ind_table_ibv { > LIST_ENTRY(mlx5_ind_table_ibv) next; /* Pointer to the next > element. */ > rte_atomic32_t refcnt; /* Reference counter. */ > struct ibv_rwq_ind_table *ind_table; /**< Indirection table. */ > - uint16_t queues_n; /**< Number of queues in the list. */ > + uint32_t queues_n; /**< Number of queues in the list. */ > uint16_t queues[]; /**< Queue list. */ > }; > > @@ -145,7 +145,7 @@ struct mlx5_hrxq { > struct mlx5_ind_table_ibv *ind_table; /* Indirection table. */ > struct ibv_qp *qp; /* Verbs queue pair. */ > uint64_t hash_fields; /* Verbs Hash fields. */ > - uint8_t rss_key_len; /* Hash key length in bytes. */ > + uint32_t rss_key_len; /* Hash key length in bytes. */ > uint8_t rss_key[]; /* Hash key. */ > }; > > @@ -238,20 +238,22 @@ int mlx5_rxq_releasable(struct rte_eth_dev *dev, > uint16_t idx); > int mlx5_rxq_verify(struct rte_eth_dev *dev); > int rxq_alloc_elts(struct mlx5_rxq_ctrl *rxq_ctrl); > struct mlx5_ind_table_ibv *mlx5_ind_table_ibv_new(struct rte_eth_dev > *dev, > - uint16_t queues[], > - uint16_t queues_n); > + const uint16_t *queues, > + uint32_t queues_n); > struct mlx5_ind_table_ibv *mlx5_ind_table_ibv_get(struct rte_eth_dev > *dev, > - uint16_t queues[], > - uint16_t queues_n); > + const uint16_t *queues, > + uint32_t queues_n); > int mlx5_ind_table_ibv_release(struct rte_eth_dev *dev, > struct mlx5_ind_table_ibv *ind_tbl); > int mlx5_ind_table_ibv_verify(struct rte_eth_dev *dev); > -struct mlx5_hrxq *mlx5_hrxq_new(struct rte_eth_dev *dev, uint8_t > *rss_key, > - uint8_t rss_key_len, uint64_t hash_fields, > - uint16_t queues[], uint16_t queues_n); > -struct mlx5_hrxq *mlx5_hrxq_get(struct rte_eth_dev *dev, uint8_t > *rss_key, > - uint8_t rss_key_len, uint64_t hash_fields, > - uint16_t queues[], uint16_t queues_n); > +struct mlx5_hrxq *mlx5_hrxq_new(struct rte_eth_dev *dev, > + const uint8_t *rss_key, uint32_t rss_key_len, > + uint64_t hash_fields, > + const uint16_t *queues, uint32_t queues_n); > +struct mlx5_hrxq *mlx5_hrxq_get(struct rte_eth_dev *dev, > + const uint8_t *rss_key, uint32_t rss_key_len, > + uint64_t hash_fields, > + const uint16_t *queues, uint32_t queues_n); > int mlx5_hrxq_release(struct rte_eth_dev *dev, struct mlx5_hrxq *hxrq); > int mlx5_hrxq_ibv_verify(struct rte_eth_dev *dev); > uint64_t mlx5_get_rx_port_offloads(void); > diff --git a/drivers/net/sfc/sfc_flow.c b/drivers/net/sfc/sfc_flow.c > index 056405515..1a2c0299c 100644 > --- a/drivers/net/sfc/sfc_flow.c > +++ b/drivers/net/sfc/sfc_flow.c > @@ -1234,13 +1234,11 @@ sfc_flow_parse_rss(struct sfc_adapter *sa, > struct sfc_rxq *rxq; > unsigned int rxq_hw_index_min; > unsigned int rxq_hw_index_max; > - const struct rte_eth_rss_conf *rss_conf = rss->rss_conf; > - uint64_t rss_hf; > - uint8_t *rss_key = NULL; > + const uint8_t *rss_key; > struct sfc_flow_rss *sfc_rss_conf = &flow->rss_conf; > unsigned int i; > > - if (rss->num == 0) > + if (rss->queue_num == 0) > return -EINVAL; > > rxq_sw_index = sa->rxq_count - 1; > @@ -1248,7 +1246,7 @@ sfc_flow_parse_rss(struct sfc_adapter *sa, > rxq_hw_index_min = rxq->hw_index; > rxq_hw_index_max = 0; > > - for (i = 0; i < rss->num; ++i) { > + for (i = 0; i < rss->queue_num; ++i) { > rxq_sw_index = rss->queue[i]; > > if (rxq_sw_index >= sa->rxq_count) > @@ -1263,15 +1261,14 @@ sfc_flow_parse_rss(struct sfc_adapter *sa, > rxq_hw_index_max = rxq->hw_index; > } > > - rss_hf = (rss_conf != NULL) ? rss_conf->rss_hf : SFC_RSS_OFFLOADS; > - if ((rss_hf & ~SFC_RSS_OFFLOADS) != 0) > + if ((rss->types & ~SFC_RSS_OFFLOADS) != 0) > return -EINVAL; > > - if (rss_conf != NULL) { > - if (rss_conf->rss_key_len != sizeof(sa->rss_key)) > + if (rss->key_len) { > + if (rss->key_len != sizeof(sa->rss_key)) > return -EINVAL; > > - rss_key = rss_conf->rss_key; > + rss_key = rss->key; > } else { > rss_key = sa->rss_key; > } > @@ -1280,11 +1277,11 @@ sfc_flow_parse_rss(struct sfc_adapter *sa, > > sfc_rss_conf->rxq_hw_index_min = rxq_hw_index_min; > sfc_rss_conf->rxq_hw_index_max = rxq_hw_index_max; > - sfc_rss_conf->rss_hash_types = sfc_rte_to_efx_hash_type(rss_hf); > + sfc_rss_conf->rss_hash_types = sfc_rte_to_efx_hash_type(rss- > >types); > rte_memcpy(sfc_rss_conf->rss_key, rss_key, sizeof(sa->rss_key)); > > for (i = 0; i < RTE_DIM(sfc_rss_conf->rss_tbl); ++i) { > - unsigned int rxq_sw_index = rss->queue[i % rss->num]; > + unsigned int rxq_sw_index = rss->queue[i % rss- > >queue_num]; > struct sfc_rxq *rxq = sa->rxq_info[rxq_sw_index].rxq; > > sfc_rss_conf->rss_tbl[i] = rxq->hw_index - > rxq_hw_index_min; > diff --git a/drivers/net/tap/tap_flow.c b/drivers/net/tap/tap_flow.c > index fe2f94010..67146aaba 100644 > --- a/drivers/net/tap/tap_flow.c > +++ b/drivers/net/tap/tap_flow.c > @@ -1215,7 +1215,7 @@ priv_flow_process(struct pmd_internals *pmd, > if (err) > goto exit_action_not_supported; > } > - if (flow && rss) > + if (flow) > err = rss_add_actions(flow, pmd, rss, error); > } else { > goto exit_action_not_supported; > @@ -2050,7 +2050,7 @@ static int rss_add_actions(struct rte_flow *flow, > struct pmd_internals *pmd, > struct rte_flow_error *error) > { > /* 4096 is the maximum number of instructions for a BPF program */ > - int i; > + unsigned int i; > int err; > struct rss_key rss_entry = { .hash_fields = 0, > .key_size = 0 }; > @@ -2066,8 +2066,8 @@ static int rss_add_actions(struct rte_flow *flow, > struct pmd_internals *pmd, > } > > /* Update RSS map entry with queues */ > - rss_entry.nb_queues = rss->num; > - for (i = 0; i < rss->num; i++) > + rss_entry.nb_queues = rss->queue_num; > + for (i = 0; i < rss->queue_num; i++) > rss_entry.queues[i] = rss->queue[i]; > rss_entry.hash_fields = > (1 << HASH_FIELD_IPV4_L3_L4) | (1 << > HASH_FIELD_IPV6_L3_L4); > diff --git a/examples/ipsec-secgw/ipsec.c b/examples/ipsec-secgw/ipsec.c > index 5971937cf..ee2497352 100644 > --- a/examples/ipsec-secgw/ipsec.c > +++ b/examples/ipsec-secgw/ipsec.c > @@ -203,9 +203,13 @@ create_session(struct ipsec_ctx *ipsec_ctx, struct > ipsec_sa *sa) > i < eth_dev->data->nb_rx_queues; ++i) > if (eth_dev->data->rx_queues[i]) > queue[j++] = i; > - action_rss.rss_conf = &rss_conf; > - action_rss.num = j; > - action_rss.queue = queue; > + action_rss = (struct rte_flow_action_rss){ > + .types = rss_conf.rss_hf, > + .key_len = rss_conf.rss_key_len, > + .queue_num = j, > + .key = rss_key, > + .queue = queue, > + }; > ret = rte_flow_validate(sa->portid, &sa->attr, > sa->pattern, sa- > >action, > &err); > diff --git a/lib/librte_ether/rte_flow.c b/lib/librte_ether/rte_flow.c > index bb19e28c6..cc7819b6a 100644 > --- a/lib/librte_ether/rte_flow.c > +++ b/lib/librte_ether/rte_flow.c > @@ -330,40 +330,27 @@ flow_action_conf_copy(void *buf, const struct > rte_flow_action *action) > off = 0; > if (dst.rss) > *dst.rss = (struct rte_flow_action_rss){ > - .num = src.rss->num, > + .types = src.rss->types, > + .key_len = src.rss->key_len, > + .queue_num = src.rss->queue_num, > }; > off += sizeof(*src.rss); > - if (src.rss->num) { > + if (src.rss->key_len) { > off = RTE_ALIGN_CEIL(off, sizeof(double)); > - size = sizeof(*src.rss->queue) * src.rss->num; > + size = sizeof(*src.rss->key) * src.rss->key_len; > if (dst.rss) > - dst.rss->queue = memcpy > + dst.rss->key = memcpy > ((void *)((uintptr_t)dst.rss + off), > - src.rss->queue, size); > + src.rss->key, size); > off += size; > } > - off = RTE_ALIGN_CEIL(off, sizeof(double)); > - if (dst.rss) { > - dst.rss->rss_conf = (void *)((uintptr_t)dst.rss + off); > - *(struct rte_eth_rss_conf *)(uintptr_t) > - dst.rss->rss_conf = (struct > rte_eth_rss_conf){ > - .rss_key_len = src.rss->rss_conf- > >rss_key_len, > - .rss_hf = src.rss->rss_conf->rss_hf, > - }; > - } > - off += sizeof(*src.rss->rss_conf); > - if (src.rss->rss_conf->rss_key_len) { > + if (src.rss->queue_num) { > off = RTE_ALIGN_CEIL(off, sizeof(double)); > - size = sizeof(*src.rss->rss_conf->rss_key) * > - src.rss->rss_conf->rss_key_len; > - if (dst.rss) { > - ((struct rte_eth_rss_conf *)(uintptr_t) > - dst.rss->rss_conf)->rss_key = > - (void *)((uintptr_t)dst.rss + off); > - memcpy(dst.rss->rss_conf->rss_key, > - src.rss->rss_conf->rss_key, > - size); > - } > + size = sizeof(*src.rss->queue) * src.rss->queue_num; > + if (dst.rss) > + dst.rss->queue = memcpy > + ((void *)((uintptr_t)dst.rss + off), > + src.rss->queue, size); > off += size; > } > size = off; > diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h > index ad2e55b8e..bbc408fa6 100644 > --- a/lib/librte_ether/rte_flow.h > +++ b/lib/librte_ether/rte_flow.h > @@ -1033,13 +1033,21 @@ struct rte_flow_query_count { > * Similar to QUEUE, except RSS is additionally performed on packets to > * spread them among several queues according to the provided parameters. > * > + * Unlike global RSS settings used by other DPDK APIs, unsetting the > + * @p types field does not disable RSS in a flow rule. Doing so instead > + * requests safe unspecified "best-effort" settings from the underlying > PMD, > + * which depending on the flow rule, may result in anything ranging from > + * empty (single queue) to all-inclusive RSS. > + * > * Note: RSS hash result is stored in the hash.rss mbuf field which overlaps > * hash.fdir.lo. Since the MARK action sets the hash.fdir.hi field only, > * both can be requested simultaneously. > */ > struct rte_flow_action_rss { > - const struct rte_eth_rss_conf *rss_conf; /**< RSS parameters. */ > - uint16_t num; /**< Number of entries in @p queue. */ > + uint64_t types; /**< Specific RSS hash types (see ETH_RSS_*). */ > + uint32_t key_len; /**< Hash key length in bytes. */ > + uint32_t queue_num; /**< Number of entries in @p queue. */ > + const uint8_t *key; /**< Hash key. */ > const uint16_t *queue; /**< Queue indices to use. */ > }; > > -- > 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [dpdk-dev] [PATCH v6 07/16] ethdev: flatten RSS configuration in flow API 2018-04-28 3:46 ` Zhao1, Wei @ 2018-04-28 5:28 ` Peng, Yuan 2018-04-28 7:45 ` Peng, Yuan 0 siblings, 1 reply; 157+ messages in thread From: Peng, Yuan @ 2018-04-28 5:28 UTC (permalink / raw) To: Zhao1, Wei, Adrien Mazarguil, dev Cc: Xu, Qian Q, Liu, Yu Y, Lu, Wenzhuo, Wu, Jingjing Hi,Adrien Mazarguil There is a bug present with 18.05-rci when I test the feature "Move RSS to rte_flow" in i40e NIC The test steps are as below: ./usertools/dpdk-devbind.py -b igb_uio 05:00.0 05:00.1 ./x86_64-native-linuxapp-gcc/app/testpmd -c 0x1fffe -n 4 -- -i --nb-cores=8 --rxq=8 --txq=8 --port-topology=chained testpmd> set fwd rxonly Set rxonly packet forwarding mode testpmd> set verbose 1 Change verbose level from 0 to 1 testpmd> start testpmd> flow create 0 ingress pattern end actions rss queues 0 4 7 end / end Caught error type 16 (specific action): cause: 0x7fff84e33658, RSS hash key too large The rss rule can be set successfully when I test it yesterday with older dpdk version without this patch. The NIC information is: driver: i40e version: 2.4.3 firmware-version: 6.01 0x80003205 1.1691.0 There is another problem with ixgbe nic: ./usertools/dpdk-devbind.py -b igb_uio 07:00.0 07:00.1 ./x86_64-native-linuxapp-gcc/app/testpmd -c 0x1fffe -n 4 -- -i --nb-cores=8 --rxq=8 --txq=8 --disable-rss --port-topology=chained testpmd> flow create 0 ingress pattern end actions rss queues 5 6 7 end / end Caught error type 2 (flow rule (handle)): Failed to create flow. The rule setting command can be executed successfully with older dpdk version. Could you help to check if there is a relationship between the bugs and this patch? Thank you. Yuan. -----Original Message----- From: Zhao1, Wei Sent: Saturday, April 28, 2018 11:46 AM To: Adrien Mazarguil <adrien.mazarguil@6wind.com>; dev@dpdk.org Cc: Peng, Yuan <yuan.peng@intel.com>; Xu, Qian Q <qian.q.xu@intel.com>; Liu, Yu Y <yu.y.liu@intel.com>; Lu, Wenzhuo <wenzhuo.lu@intel.com>; Wu, Jingjing <jingjing.wu@intel.com> Subject: RE: [dpdk-dev] [PATCH v6 07/16] ethdev: flatten RSS configuration in flow API Hi,Adrien Mazarguil We have just use new RC.1 code on the feature of flow RSS API, but we find some abnormal phenomenon. After that I check code again, I find that it is introduced in this patch: SHA-1: ac8d22de2394e03ba4a77d8fd24381147aafb1d3 * ethdev: flatten RSS configuration in flow API Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> This abnormal phenomenon include i40e and ixgbe 2 NIC, it do not has these 2 bug before merge this patch. It is first find out by yuan.peng@intel.com, she can tell you how to reappear these abnormal phenomenon on RSS flow API. Thank you. > -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Adrien Mazarguil > Sent: Wednesday, April 25, 2018 11:28 PM > To: Thomas Monjalon <thomas@monjalon.net>; Yigit, Ferruh > <ferruh.yigit@intel.com>; dev@dpdk.org > Cc: Xueming Li <xuemingl@mellanox.com>; Lu, Wenzhuo > <wenzhuo.lu@intel.com>; Wu, Jingjing <jingjing.wu@intel.com>; Xing, Beilei > <beilei.xing@intel.com>; Zhang, Qi Z <qi.z.zhang@intel.com>; Ananyev, > Konstantin <konstantin.ananyev@intel.com>; Nelio Laranjeiro > <nelio.laranjeiro@6wind.com>; Yongseok Koh <yskoh@mellanox.com>; > Andrew Rybchenko <arybchenko@solarflare.com>; Pascal Mazon > <pascal.mazon@6wind.com>; Nicolau, Radu <radu.nicolau@intel.com>; Akhil > Goyal <akhil.goyal@nxp.com> > Subject: [dpdk-dev] [PATCH v6 07/16] ethdev: flatten RSS configuration in > flow API > > Since its inception, the rte_flow RSS action has been relying in part on > external struct rte_eth_rss_conf for compatibility with the legacy RSS API. > This structure lacks parameters such as the hash algorithm to use, and more > recently, a method to tell which layer RSS should be performed on [1]. > > Given struct rte_eth_rss_conf will never be flexible enough to represent a > complete RSS configuration (e.g. RETA table), this patch supersedes it by > extending the rte_flow RSS action directly. > > A subsequent patch will add a field to use a non-default RSS hash > algorithm. To that end, a field named "types" replaces the field formerly > known as "rss_hf" and standing for "RSS hash functions" as it was > confusing. Actual RSS hash function types are defined by enum > rte_eth_hash_function. > > This patch updates all PMDs and example applications accordingly. > > It breaks ABI compatibility for the following public functions: > > - rte_flow_copy() > - rte_flow_create() > - rte_flow_query() > - rte_flow_validate() > > [1] commit 676b605182a5 ("doc: announce ethdev API change for RSS > configuration") > > Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> > Acked-by: Andrew Rybchenko <arybchenko@solarflare.com> > Cc: Xueming Li <xuemingl@mellanox.com> > Cc: Ferruh Yigit <ferruh.yigit@intel.com> > Cc: Thomas Monjalon <thomas@monjalon.net> > Cc: Wenzhuo Lu <wenzhuo.lu@intel.com> > Cc: Jingjing Wu <jingjing.wu@intel.com> > Cc: Beilei Xing <beilei.xing@intel.com> > Cc: Qi Zhang <qi.z.zhang@intel.com> > Cc: Konstantin Ananyev <konstantin.ananyev@intel.com> > Cc: Nelio Laranjeiro <nelio.laranjeiro@6wind.com> > Cc: Yongseok Koh <yskoh@mellanox.com> > Cc: Andrew Rybchenko <arybchenko@solarflare.com> > Cc: Pascal Mazon <pascal.mazon@6wind.com> > Cc: Radu Nicolau <radu.nicolau@intel.com> > Cc: Akhil Goyal <akhil.goyal@nxp.com> > > --- > > v6 changes: > > - Fixed QUEUE action support in mlx5 according to Nelio's comment [1]. > This action relies on RSS to work and even though it targets a single Rx > queue, a non-NULL hash key is required. > - Updated API and ABI changes sections in release notes. > > [1] http://dpdk.org/ml/archives/dev/2018-April/098635.html > > v3 changes: > > Documentation update regarding the meaning of a 0 value for RSS types in > flow rules. > > It used to implicitly mean "no RSS" but is redefined as requesting a kind > of "best-effort" mode from PMDs, i.e. anything ranging from empty to > all-inclusive RSS; what matters is it provides safe defaults that will work > regardless of PMD capabilities. > --- > app/test-pmd/cmdline_flow.c | 48 +++--- > app/test-pmd/config.c | 39 ++--- > doc/guides/prog_guide/rte_flow.rst | 28 ++-- > doc/guides/rel_notes/release_18_05.rst | 13 +- > doc/guides/testpmd_app_ug/testpmd_funcs.rst | 6 +- > drivers/net/e1000/e1000_ethdev.h | 13 +- > drivers/net/e1000/igb_ethdev.c | 4 +- > drivers/net/e1000/igb_flow.c | 31 ++-- > drivers/net/e1000/igb_rxtx.c | 51 +++++- > drivers/net/i40e/i40e_ethdev.c | 53 +++++-- > drivers/net/i40e/i40e_ethdev.h | 15 +- > drivers/net/i40e/i40e_flow.c | 47 +++--- > drivers/net/ixgbe/ixgbe_ethdev.c | 4 +- > drivers/net/ixgbe/ixgbe_ethdev.h | 13 +- > drivers/net/ixgbe/ixgbe_flow.c | 30 ++-- > drivers/net/ixgbe/ixgbe_rxtx.c | 51 +++++- > drivers/net/mlx4/mlx4.c | 2 +- > drivers/net/mlx4/mlx4_flow.c | 61 +++---- > drivers/net/mlx4/mlx4_flow.h | 2 +- > drivers/net/mlx4/mlx4_rxq.c | 2 +- > drivers/net/mlx4/mlx4_rxtx.h | 2 +- > drivers/net/mlx5/mlx5_flow.c | 193 +++++++++++------------ > drivers/net/mlx5/mlx5_rxq.c | 26 +-- > drivers/net/mlx5/mlx5_rxtx.h | 26 +-- > drivers/net/sfc/sfc_flow.c | 21 ++- > drivers/net/tap/tap_flow.c | 8 +- > examples/ipsec-secgw/ipsec.c | 10 +- > lib/librte_ether/rte_flow.c | 39 ++--- > lib/librte_ether/rte_flow.h | 12 +- > 29 files changed, 492 insertions(+), 358 deletions(-) > > diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c > index 798b7948d..c9c2c3ad9 100644 > --- a/app/test-pmd/cmdline_flow.c > +++ b/app/test-pmd/cmdline_flow.c > @@ -192,9 +192,8 @@ enum index { > /** Storage for struct rte_flow_action_rss including external data. */ > struct action_rss_data { > struct rte_flow_action_rss conf; > + uint8_t key[RSS_HASH_KEY_LENGTH]; > uint16_t queue[ACTION_RSS_QUEUE_NUM]; > - struct rte_eth_rss_conf rss_conf; > - uint8_t rss_key[RSS_HASH_KEY_LENGTH]; > }; > > /** Maximum number of subsequent tokens and arguments on the stack. > */ > @@ -1587,7 +1586,7 @@ static const struct token token_list[] = { > }, > [ACTION_RSS_TYPES] = { > .name = "types", > - .help = "RSS hash types", > + .help = "specific RSS hash types", > .next = NEXT(action_rss, NEXT_ENTRY(ACTION_RSS_TYPE)), > }, > [ACTION_RSS_TYPE] = { > @@ -1602,21 +1601,21 @@ static const struct token token_list[] = { > .next = NEXT(action_rss, NEXT_ENTRY(STRING)), > .args = ARGS(ARGS_ENTRY_ARB(0, 0), > ARGS_ENTRY_ARB > - (offsetof(struct action_rss_data, rss_conf) + > - offsetof(struct rte_eth_rss_conf, rss_key_len), > - sizeof(((struct rte_eth_rss_conf *)0)-> > - rss_key_len)), > - ARGS_ENTRY(struct action_rss_data, rss_key)), > + (offsetof(struct action_rss_data, conf) + > + offsetof(struct rte_flow_action_rss, key_len), > + sizeof(((struct rte_flow_action_rss *)0)-> > + key_len)), > + ARGS_ENTRY(struct action_rss_data, key)), > }, > [ACTION_RSS_KEY_LEN] = { > .name = "key_len", > .help = "RSS hash key length in bytes", > .next = NEXT(action_rss, NEXT_ENTRY(UNSIGNED)), > .args = ARGS(ARGS_ENTRY_ARB_BOUNDED > - (offsetof(struct action_rss_data, rss_conf) + > - offsetof(struct rte_eth_rss_conf, rss_key_len), > - sizeof(((struct rte_eth_rss_conf *)0)-> > - rss_key_len), > + (offsetof(struct action_rss_data, conf) + > + offsetof(struct rte_flow_action_rss, key_len), > + sizeof(((struct rte_flow_action_rss *)0)-> > + key_len), > 0, > RSS_HASH_KEY_LENGTH)), > }, > @@ -2075,27 +2074,24 @@ parse_vc_action_rss(struct context *ctx, const > struct token *token, > action_rss_data = ctx->object; > *action_rss_data = (struct action_rss_data){ > .conf = (struct rte_flow_action_rss){ > - .rss_conf = &action_rss_data->rss_conf, > - .num = RTE_MIN(nb_rxq, > ACTION_RSS_QUEUE_NUM), > + .types = rss_hf, > + .key_len = sizeof(action_rss_data->key), > + .queue_num = RTE_MIN(nb_rxq, > ACTION_RSS_QUEUE_NUM), > + .key = action_rss_data->key, > .queue = action_rss_data->queue, > }, > + .key = "testpmd's default RSS hash key", > .queue = { 0 }, > - .rss_conf = (struct rte_eth_rss_conf){ > - .rss_key = action_rss_data->rss_key, > - .rss_key_len = sizeof(action_rss_data->rss_key), > - .rss_hf = rss_hf, > - }, > - .rss_key = "testpmd's default RSS hash key", > }; > - for (i = 0; i < action_rss_data->conf.num; ++i) > + for (i = 0; i < action_rss_data->conf.queue_num; ++i) > action_rss_data->queue[i] = i; > if (!port_id_is_invalid(ctx->port, DISABLED_WARN) && > ctx->port != (portid_t)RTE_PORT_ALL) { > struct rte_eth_dev_info info; > > rte_eth_dev_info_get(ctx->port, &info); > - action_rss_data->rss_conf.rss_key_len = > - RTE_MIN(sizeof(action_rss_data->rss_key), > + action_rss_data->conf.key_len = > + RTE_MIN(sizeof(action_rss_data->key), > info.hash_key_size); > } > action->conf = &action_rss_data->conf; > @@ -2123,7 +2119,7 @@ parse_vc_action_rss_type(struct context *ctx, > const struct token *token, > return -1; > if (!(ctx->objdata >> 16) && ctx->object) { > action_rss_data = ctx->object; > - action_rss_data->rss_conf.rss_hf = 0; > + action_rss_data->conf.types = 0; > } > if (!strcmp_partial("end", str, len)) { > ctx->objdata &= 0xffff; > @@ -2142,7 +2138,7 @@ parse_vc_action_rss_type(struct context *ctx, > const struct token *token, > if (!ctx->object) > return len; > action_rss_data = ctx->object; > - action_rss_data->rss_conf.rss_hf |= rss_type_table[i].rss_type; > + action_rss_data->conf.types |= rss_type_table[i].rss_type; > return len; > } > > @@ -2192,7 +2188,7 @@ parse_vc_action_rss_queue(struct context *ctx, > const struct token *token, > if (!ctx->object) > return len; > action_rss_data = ctx->object; > - action_rss_data->conf.num = i; > + action_rss_data->conf.queue_num = i; > action_rss_data->conf.queue = i ? action_rss_data->queue : NULL; > return len; > } > diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c > index eb7ac315e..4700dd674 100644 > --- a/app/test-pmd/config.c > +++ b/app/test-pmd/config.c > @@ -1117,40 +1117,27 @@ flow_action_conf_copy(void *buf, const struct > rte_flow_action *action) > off = 0; > if (dst.rss) > *dst.rss = (struct rte_flow_action_rss){ > - .num = src.rss->num, > + .types = src.rss->types, > + .key_len = src.rss->key_len, > + .queue_num = src.rss->queue_num, > }; > off += sizeof(*src.rss); > - if (src.rss->num) { > + if (src.rss->key_len) { > off = RTE_ALIGN_CEIL(off, sizeof(double)); > - size = sizeof(*src.rss->queue) * src.rss->num; > + size = sizeof(*src.rss->key) * src.rss->key_len; > if (dst.rss) > - dst.rss->queue = memcpy > + dst.rss->key = memcpy > ((void *)((uintptr_t)dst.rss + off), > - src.rss->queue, size); > + src.rss->key, size); > off += size; > } > - off = RTE_ALIGN_CEIL(off, sizeof(double)); > - if (dst.rss) { > - dst.rss->rss_conf = (void *)((uintptr_t)dst.rss + off); > - *(struct rte_eth_rss_conf *)(uintptr_t) > - dst.rss->rss_conf = (struct > rte_eth_rss_conf){ > - .rss_key_len = src.rss->rss_conf- > >rss_key_len, > - .rss_hf = src.rss->rss_conf->rss_hf, > - }; > - } > - off += sizeof(*src.rss->rss_conf); > - if (src.rss->rss_conf->rss_key_len) { > + if (src.rss->queue_num) { > off = RTE_ALIGN_CEIL(off, sizeof(double)); > - size = sizeof(*src.rss->rss_conf->rss_key) * > - src.rss->rss_conf->rss_key_len; > - if (dst.rss) { > - ((struct rte_eth_rss_conf *)(uintptr_t) > - dst.rss->rss_conf)->rss_key = > - (void *)((uintptr_t)dst.rss + off); > - memcpy(dst.rss->rss_conf->rss_key, > - src.rss->rss_conf->rss_key, > - size); > - } > + size = sizeof(*src.rss->queue) * src.rss->queue_num; > + if (dst.rss) > + dst.rss->queue = memcpy > + ((void *)((uintptr_t)dst.rss + off), > + src.rss->queue, size); > off += size; > } > size = off; > diff --git a/doc/guides/prog_guide/rte_flow.rst > b/doc/guides/prog_guide/rte_flow.rst > index acbeaacbd..cf252eeba 100644 > --- a/doc/guides/prog_guide/rte_flow.rst > +++ b/doc/guides/prog_guide/rte_flow.rst > @@ -1301,6 +1301,12 @@ Action: ``RSS`` > Similar to QUEUE, except RSS is additionally performed on packets to spread > them among several queues according to the provided parameters. > > +Unlike global RSS settings used by other DPDK APIs, unsetting the ``types`` > +field does not disable RSS in a flow rule. Doing so instead requests safe > +unspecified "best-effort" settings from the underlying PMD, which > depending > +on the flow rule, may result in anything ranging from empty (single queue) > +to all-inclusive RSS. > + > Note: RSS hash result is stored in the ``hash.rss`` mbuf field which > overlaps ``hash.fdir.lo``. Since `Action: MARK`_ sets the ``hash.fdir.hi`` > field only, both can be requested simultaneously. > @@ -1309,15 +1315,19 @@ field only, both can be requested simultaneously. > > .. table:: RSS > > - +--------------+--------------------------------+ > - | Field | Value | > - +==============+================================+ > - | ``rss_conf`` | RSS parameters | > - +--------------+--------------------------------+ > - | ``num`` | number of entries in ``queue`` | > - +--------------+--------------------------------+ > - | ``queue`` | queue indices to use | > - +--------------+--------------------------------+ > + +---------------+---------------------------------------------+ > + | Field | Value | > + > +===============+========================================= > ====+ > + | ``types`` | specific RSS hash types (see ``ETH_RSS_*``) | > + +---------------+---------------------------------------------+ > + | ``key_len`` | hash key length in bytes | > + +---------------+---------------------------------------------+ > + | ``queue_num`` | number of entries in ``queue`` | > + +---------------+---------------------------------------------+ > + | ``key`` | hash key | > + +---------------+---------------------------------------------+ > + | ``queue`` | queue indices to use | > + +---------------+---------------------------------------------+ > > Action: ``PF`` > ^^^^^^^^^^^^^^ > diff --git a/doc/guides/rel_notes/release_18_05.rst > b/doc/guides/rel_notes/release_18_05.rst > index ca173450c..b702ac66a 100644 > --- a/doc/guides/rel_notes/release_18_05.rst > +++ b/doc/guides/rel_notes/release_18_05.rst > @@ -254,6 +254,13 @@ API Changes > present. > * C99-style flexible arrays were replaced with standard pointers in RSS > action and in RAW pattern item structures due to compatibility issues. > + * The RSS action was modified to not rely on external > + ``struct rte_eth_rss_conf`` anymore to instead expose its own and more > + appropriately named configuration fields directly > + (``rss_conf->rss_key`` => ``key``, > + ``rss_conf->rss_key_len`` => ``key_len``, > + ``rss_conf->rss_hf`` => ``types``, > + ``num`` => ``queue_num``). > > > ABI Changes > @@ -302,9 +309,9 @@ ABI Changes > ``rte_flow_isolate``, ``rte_flow_query`` and ``rte_flow_validate``, due to > changes in error type definitions (``enum rte_flow_error_type``), removal > of the unused DUP action (``enum rte_flow_action_type``), modified > - behavior for flow rule actions (see API changes) and removal of C99 > - flexible arrays from RSS action (``struct rte_flow_action_rss``) and RAW > - pattern item (``struct rte_flow_item_raw``). > + behavior for flow rule actions (see API changes), removal of C99 flexible > + array from RAW pattern item (``struct rte_flow_item_raw``) and complete > + rework of the RSS action definition (``struct rte_flow_action_rss``). > > > Removed Items > diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst > b/doc/guides/testpmd_app_ug/testpmd_funcs.rst > index 68c286bd4..a12e0267a 100644 > --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst > +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst > @@ -3422,8 +3422,10 @@ This section lists supported actions and their > attributes, if any. > > - ``rss``: spread packets among several queues. > > - - ``types [{RSS hash type} [...]] end``: RSS hash types, allowed tokens > - are the same as `set_hash_input_set`_, an empty list means none (0). > + - ``types [{RSS hash type} [...]] end``: specific RSS hash types, allowed > + tokens are the same as `set_hash_input_set`_, except that an empty list > + does not disable RSS but instead requests unspecified "best-effort" > + settings. > > - ``key {string}``: RSS hash key, overrides ``key_len``. > > diff --git a/drivers/net/e1000/e1000_ethdev.h > b/drivers/net/e1000/e1000_ethdev.h > index 6354b894a..902001f36 100644 > --- a/drivers/net/e1000/e1000_ethdev.h > +++ b/drivers/net/e1000/e1000_ethdev.h > @@ -4,6 +4,10 @@ > > #ifndef _E1000_ETHDEV_H_ > #define _E1000_ETHDEV_H_ > + > +#include <stdint.h> > + > +#include <rte_flow.h> > #include <rte_time.h> > #include <rte_pci.h> > > @@ -27,6 +31,7 @@ > #define E1000_CTRL_EXT_EXTEND_VLAN (1<<26) /* EXTENDED VLAN */ > #define IGB_VFTA_SIZE 128 > > +#define IGB_HKEY_MAX_INDEX 10 > #define IGB_MAX_RX_QUEUE_NUM 8 > #define IGB_MAX_RX_QUEUE_NUM_82576 16 > > @@ -229,8 +234,8 @@ struct igb_ethertype_filter { > }; > > struct igb_rte_flow_rss_conf { > - struct rte_eth_rss_conf rss_conf; /**< RSS parameters. */ > - uint16_t num; /**< Number of entries in queue[]. */ > + struct rte_flow_action_rss conf; /**< RSS parameters. */ > + uint8_t key[IGB_HKEY_MAX_INDEX * sizeof(uint32_t)]; /* Hash key. > */ > uint16_t queue[IGB_MAX_RX_QUEUE_NUM]; /**< Queues indices > to use. */ > }; > > @@ -501,6 +506,10 @@ int eth_igb_syn_filter_set(struct rte_eth_dev *dev, > int eth_igb_add_del_flex_filter(struct rte_eth_dev *dev, > struct rte_eth_flex_filter *filter, > bool add); > +int igb_rss_conf_init(struct igb_rte_flow_rss_conf *out, > + const struct rte_flow_action_rss *in); > +int igb_action_rss_same(const struct rte_flow_action_rss *comp, > + const struct rte_flow_action_rss *with); > int igb_config_rss_filter(struct rte_eth_dev *dev, > struct igb_rte_flow_rss_conf *conf, > bool add); > diff --git a/drivers/net/e1000/igb_ethdev.c > b/drivers/net/e1000/igb_ethdev.c > index c35c9352a..140334772 100644 > --- a/drivers/net/e1000/igb_ethdev.c > +++ b/drivers/net/e1000/igb_ethdev.c > @@ -41,8 +41,6 @@ > #define IGB_DEFAULT_TX_HTHRESH 1 > #define IGB_DEFAULT_TX_WTHRESH ((hw->mac.type == e1000_82576) ? > 1 : 16) > > -#define IGB_HKEY_MAX_INDEX 10 > - > /* Bit shift and mask */ > #define IGB_4_BIT_WIDTH (CHAR_BIT / 2) > #define IGB_4_BIT_MASK RTE_LEN2MASK(IGB_4_BIT_WIDTH, uint8_t) > @@ -5662,7 +5660,7 @@ igb_rss_filter_restore(struct rte_eth_dev *dev) > struct e1000_filter_info *filter_info = > E1000_DEV_PRIVATE_TO_FILTER_INFO(dev->data- > >dev_private); > > - if (filter_info->rss_info.num) > + if (filter_info->rss_info.conf.queue_num) > igb_config_rss_filter(dev, &filter_info->rss_info, TRUE); > } > > diff --git a/drivers/net/e1000/igb_flow.c b/drivers/net/e1000/igb_flow.c > index c0f5b5190..8dc5f75f2 100644 > --- a/drivers/net/e1000/igb_flow.c > +++ b/drivers/net/e1000/igb_flow.c > @@ -1292,7 +1292,7 @@ igb_parse_rss_filter(struct rte_eth_dev *dev, > > rss = (const struct rte_flow_action_rss *)act->conf; > > - if (!rss || !rss->num) { > + if (!rss || !rss->queue_num) { > rte_flow_error_set(error, EINVAL, > RTE_FLOW_ERROR_TYPE_ACTION, > act, > @@ -1300,7 +1300,7 @@ igb_parse_rss_filter(struct rte_eth_dev *dev, > return -rte_errno; > } > > - for (n = 0; n < rss->num; n++) { > + for (n = 0; n < rss->queue_num; n++) { > if (rss->queue[n] >= dev->data->nb_rx_queues) { > rte_flow_error_set(error, EINVAL, > RTE_FLOW_ERROR_TYPE_ACTION, > @@ -1310,14 +1310,18 @@ igb_parse_rss_filter(struct rte_eth_dev *dev, > } > } > > - if (rss->rss_conf) > - rss_conf->rss_conf = *rss->rss_conf; > - else > - rss_conf->rss_conf.rss_hf = IGB_RSS_OFFLOAD_ALL; > - > - for (n = 0; n < rss->num; ++n) > - rss_conf->queue[n] = rss->queue[n]; > - rss_conf->num = rss->num; > + if (rss->key_len && rss->key_len != RTE_DIM(rss_conf->key)) > + return rte_flow_error_set > + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, > act, > + "RSS hash key must be exactly 40 bytes"); > + if (rss->queue_num > RTE_DIM(rss_conf->queue)) > + return rte_flow_error_set > + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, > act, > + "too many queues for RSS context"); > + if (igb_rss_conf_init(rss_conf, rss)) > + return rte_flow_error_set > + (error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, > act, > + "RSS context initialization failure"); > > /* check if the next not void item is END */ > index++; > @@ -1518,9 +1522,8 @@ igb_flow_create(struct rte_eth_dev *dev, > PMD_DRV_LOG(ERR, "failed to allocate > memory"); > goto out; > } > - rte_memcpy(&rss_filter_ptr->filter_info, > - &rss_conf, > - sizeof(struct igb_rte_flow_rss_conf)); > + igb_rss_conf_init(&rss_filter_ptr->filter_info, > + &rss_conf.conf); > TAILQ_INSERT_TAIL(&igb_filter_rss_list, > rss_filter_ptr, entries); > flow->rule = rss_filter_ptr; > @@ -1757,7 +1760,7 @@ igb_clear_rss_filter(struct rte_eth_dev *dev) > struct e1000_filter_info *filter = > E1000_DEV_PRIVATE_TO_FILTER_INFO(dev->data- > >dev_private); > > - if (filter->rss_info.num) > + if (filter->rss_info.conf.queue_num) > igb_config_rss_filter(dev, &filter->rss_info, FALSE); > } > > diff --git a/drivers/net/e1000/igb_rxtx.c b/drivers/net/e1000/igb_rxtx.c > index 323913f0d..45bb3455c 100644 > --- a/drivers/net/e1000/igb_rxtx.c > +++ b/drivers/net/e1000/igb_rxtx.c > @@ -2898,12 +2898,47 @@ igb_txq_info_get(struct rte_eth_dev *dev, > uint16_t queue_id, > } > > int > +igb_rss_conf_init(struct igb_rte_flow_rss_conf *out, > + const struct rte_flow_action_rss *in) > +{ > + if (in->key_len > RTE_DIM(out->key) || > + in->queue_num > RTE_DIM(out->queue)) > + return -EINVAL; > + out->conf = (struct rte_flow_action_rss){ > + .types = in->types, > + .key_len = in->key_len, > + .queue_num = in->queue_num, > + .key = memcpy(out->key, in->key, in->key_len), > + .queue = memcpy(out->queue, in->queue, > + sizeof(*in->queue) * in->queue_num), > + }; > + return 0; > +} > + > +int > +igb_action_rss_same(const struct rte_flow_action_rss *comp, > + const struct rte_flow_action_rss *with) > +{ > + return (comp->types == with->types && > + comp->key_len == with->key_len && > + comp->queue_num == with->queue_num && > + !memcmp(comp->key, with->key, with->key_len) && > + !memcmp(comp->queue, with->queue, > + sizeof(*with->queue) * with->queue_num)); > +} > + > +int > igb_config_rss_filter(struct rte_eth_dev *dev, > struct igb_rte_flow_rss_conf *conf, bool add) > { > uint32_t shift; > uint16_t i, j; > - struct rte_eth_rss_conf rss_conf = conf->rss_conf; > + struct rte_eth_rss_conf rss_conf = { > + .rss_key = conf->conf.key_len ? > + (void *)(uintptr_t)conf->conf.key : NULL, > + .rss_key_len = conf->conf.key_len, > + .rss_hf = conf->conf.types, > + }; > struct e1000_filter_info *filter_info = > E1000_DEV_PRIVATE_TO_FILTER_INFO(dev->data- > >dev_private); > struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data- > >dev_private); > @@ -2911,8 +2946,8 @@ igb_config_rss_filter(struct rte_eth_dev *dev, > hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private); > > if (!add) { > - if (memcmp(conf, &filter_info->rss_info, > - sizeof(struct igb_rte_flow_rss_conf)) == 0) { > + if (igb_action_rss_same(&filter_info->rss_info.conf, > + &conf->conf)) { > igb_rss_disable(dev); > memset(&filter_info->rss_info, 0, > sizeof(struct igb_rte_flow_rss_conf)); > @@ -2921,7 +2956,7 @@ igb_config_rss_filter(struct rte_eth_dev *dev, > return -EINVAL; > } > > - if (filter_info->rss_info.num) > + if (filter_info->rss_info.conf.queue_num) > return -EINVAL; > > /* Fill in redirection table. */ > @@ -2933,9 +2968,9 @@ igb_config_rss_filter(struct rte_eth_dev *dev, > } reta; > uint8_t q_idx; > > - if (j == conf->num) > + if (j == conf->conf.queue_num) > j = 0; > - q_idx = conf->queue[j]; > + q_idx = conf->conf.queue[j]; > reta.bytes[i & 3] = (uint8_t)(q_idx << shift); > if ((i & 3) == 3) > E1000_WRITE_REG(hw, E1000_RETA(i >> 2), > reta.dword); > @@ -2952,8 +2987,8 @@ igb_config_rss_filter(struct rte_eth_dev *dev, > rss_conf.rss_key = rss_intel_key; /* Default hash key */ > igb_hw_rss_hash_set(hw, &rss_conf); > > - rte_memcpy(&filter_info->rss_info, > - conf, sizeof(struct igb_rte_flow_rss_conf)); > + if (igb_rss_conf_init(&filter_info->rss_info, &conf->conf)) > + return -EINVAL; > > return 0; > } > diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c > index 78f2be7da..50e77901c 100644 > --- a/drivers/net/i40e/i40e_ethdev.c > +++ b/drivers/net/i40e/i40e_ethdev.c > @@ -11,6 +11,7 @@ > #include <inttypes.h> > #include <assert.h> > > +#include <rte_common.h> > #include <rte_eal.h> > #include <rte_string_fns.h> > #include <rte_pci.h> > @@ -11650,7 +11651,7 @@ i40e_rss_filter_restore(struct i40e_pf *pf) > { > struct i40e_rte_flow_rss_conf *conf = > &pf->rss_info; > - if (conf->num) > + if (conf->conf.queue_num) > i40e_config_rss_filter(pf, conf, TRUE); > } > > @@ -12182,18 +12183,52 @@ i40e_cloud_filter_qinq_create(struct i40e_pf > *pf) > } > > int > +i40e_rss_conf_init(struct i40e_rte_flow_rss_conf *out, > + const struct rte_flow_action_rss *in) > +{ > + if (in->key_len > RTE_DIM(out->key) || > + in->queue_num > RTE_DIM(out->queue)) > + return -EINVAL; > + out->conf = (struct rte_flow_action_rss){ > + .types = in->types, > + .key_len = in->key_len, > + .queue_num = in->queue_num, > + .key = memcpy(out->key, in->key, in->key_len), > + .queue = memcpy(out->queue, in->queue, > + sizeof(*in->queue) * in->queue_num), > + }; > + return 0; > +} > + > +int > +i40e_action_rss_same(const struct rte_flow_action_rss *comp, > + const struct rte_flow_action_rss *with) > +{ > + return (comp->types == with->types && > + comp->key_len == with->key_len && > + comp->queue_num == with->queue_num && > + !memcmp(comp->key, with->key, with->key_len) && > + !memcmp(comp->queue, with->queue, > + sizeof(*with->queue) * with->queue_num)); > +} > + > +int > i40e_config_rss_filter(struct i40e_pf *pf, > struct i40e_rte_flow_rss_conf *conf, bool add) > { > struct i40e_hw *hw = I40E_PF_TO_HW(pf); > uint32_t i, lut = 0; > uint16_t j, num; > - struct rte_eth_rss_conf rss_conf = conf->rss_conf; > + struct rte_eth_rss_conf rss_conf = { > + .rss_key = conf->conf.key_len ? > + (void *)(uintptr_t)conf->conf.key : NULL, > + .rss_key_len = conf->conf.key_len, > + .rss_hf = conf->conf.types, > + }; > struct i40e_rte_flow_rss_conf *rss_info = &pf->rss_info; > > if (!add) { > - if (memcmp(conf, rss_info, > - sizeof(struct i40e_rte_flow_rss_conf)) == 0) { > + if (i40e_action_rss_same(&rss_info->conf, &conf->conf)) { > i40e_pf_disable_rss(pf); > memset(rss_info, 0, > sizeof(struct i40e_rte_flow_rss_conf)); > @@ -12202,7 +12237,7 @@ i40e_config_rss_filter(struct i40e_pf *pf, > return -EINVAL; > } > > - if (rss_info->num) > + if (rss_info->conf.queue_num) > return -EINVAL; > > /* If both VMDQ and RSS enabled, not all of PF queues are > configured. > @@ -12213,7 +12248,7 @@ i40e_config_rss_filter(struct i40e_pf *pf, > else > num = pf->dev_data->nb_rx_queues; > > - num = RTE_MIN(num, conf->num); > + num = RTE_MIN(num, conf->conf.queue_num); > PMD_DRV_LOG(INFO, "Max of contiguous %u PF queues are > configured", > num); > > @@ -12226,7 +12261,7 @@ i40e_config_rss_filter(struct i40e_pf *pf, > for (i = 0, j = 0; i < hw->func_caps.rss_table_size; i++, j++) { > if (j == num) > j = 0; > - lut = (lut << 8) | (conf->queue[j] & ((0x1 << > + lut = (lut << 8) | (conf->conf.queue[j] & ((0x1 << > hw->func_caps.rss_table_entry_width) - 1)); > if ((i & 3) == 3) > I40E_WRITE_REG(hw, I40E_PFQF_HLUT(i >> 2), lut); > @@ -12251,8 +12286,8 @@ i40e_config_rss_filter(struct i40e_pf *pf, > > i40e_hw_rss_hash_set(pf, &rss_conf); > > - rte_memcpy(rss_info, > - conf, sizeof(struct i40e_rte_flow_rss_conf)); > + if (i40e_rss_conf_init(rss_info, &conf->conf)) > + return -EINVAL; > > return 0; > } > diff --git a/drivers/net/i40e/i40e_ethdev.h > b/drivers/net/i40e/i40e_ethdev.h > index d33b255e7..a0569d4ae 100644 > --- a/drivers/net/i40e/i40e_ethdev.h > +++ b/drivers/net/i40e/i40e_ethdev.h > @@ -5,14 +5,19 @@ > #ifndef _I40E_ETHDEV_H_ > #define _I40E_ETHDEV_H_ > > +#include <stdint.h> > + > #include <rte_eth_ctrl.h> > #include <rte_time.h> > #include <rte_kvargs.h> > #include <rte_hash.h> > +#include <rte_flow.h> > #include <rte_flow_driver.h> > #include <rte_tm_driver.h> > #include "rte_pmd_i40e.h" > > +#include "base/i40e_register.h" > + > #define I40E_VLAN_TAG_SIZE 4 > > #define I40E_AQ_LEN 32 > @@ -878,9 +883,11 @@ struct i40e_customized_pctype { > }; > > struct i40e_rte_flow_rss_conf { > - struct rte_eth_rss_conf rss_conf; /**< RSS parameters. */ > + struct rte_flow_action_rss conf; /**< RSS parameters. */ > uint16_t queue_region_conf; /**< Queue region config flag */ > - uint16_t num; /**< Number of entries in queue[]. */ > + uint8_t key[(I40E_VFQF_HKEY_MAX_INDEX > > I40E_PFQF_HKEY_MAX_INDEX ? > + I40E_VFQF_HKEY_MAX_INDEX : > I40E_PFQF_HKEY_MAX_INDEX) + 1 * > + sizeof(uint32_t)]; /* Hash key. */ > uint16_t queue[I40E_MAX_Q_PER_TC]; /**< Queues indices to use. > */ > }; > > @@ -1219,6 +1226,10 @@ void i40e_init_queue_region_conf(struct > rte_eth_dev *dev); > void i40e_flex_payload_reg_set_default(struct i40e_hw *hw); > int i40e_set_rss_key(struct i40e_vsi *vsi, uint8_t *key, uint8_t key_len); > int i40e_set_rss_lut(struct i40e_vsi *vsi, uint8_t *lut, uint16_t lut_size); > +int i40e_rss_conf_init(struct i40e_rte_flow_rss_conf *out, > + const struct rte_flow_action_rss *in); > +int i40e_action_rss_same(const struct rte_flow_action_rss *comp, > + const struct rte_flow_action_rss *with); > int i40e_config_rss_filter(struct i40e_pf *pf, > struct i40e_rte_flow_rss_conf *conf, bool add); > > diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c > index d6f5e9923..ec6231003 100644 > --- a/drivers/net/i40e/i40e_flow.c > +++ b/drivers/net/i40e/i40e_flow.c > @@ -4220,7 +4220,7 @@ i40e_flow_parse_rss_action(struct rte_eth_dev > *dev, > > if (action_flag) { > for (n = 0; n < 64; n++) { > - if (rss->rss_conf->rss_hf & (hf_bit << n)) { > + if (rss->types & (hf_bit << n)) { > conf_info->region[0].hw_flowtype[0] = n; > conf_info->region[0].flowtype_num = 1; > conf_info->queue_region_number = 1; > @@ -4236,12 +4236,12 @@ i40e_flow_parse_rss_action(struct rte_eth_dev > *dev, > * queue index for this port. > */ > if (conf_info->queue_region_number) { > - for (i = 0; i < rss->num; i++) { > - for (j = 0; j < rss_info->num; j++) { > - if (rss->queue[i] == rss_info->queue[j]) > + for (i = 0; i < rss->queue_num; i++) { > + for (j = 0; j < rss_info->conf.queue_num; j++) { > + if (rss->queue[i] == rss_info->conf.queue[j]) > break; > } > - if (j == rss_info->num) { > + if (j == rss_info->conf.queue_num) { > rte_flow_error_set(error, EINVAL, > RTE_FLOW_ERROR_TYPE_ACTION, > act, > @@ -4250,7 +4250,7 @@ i40e_flow_parse_rss_action(struct rte_eth_dev > *dev, > } > } > > - for (i = 0; i < rss->num - 1; i++) { > + for (i = 0; i < rss->queue_num - 1; i++) { > if (rss->queue[i + 1] != rss->queue[i] + 1) { > rte_flow_error_set(error, EINVAL, > RTE_FLOW_ERROR_TYPE_ACTION, > @@ -4265,8 +4265,8 @@ i40e_flow_parse_rss_action(struct rte_eth_dev > *dev, > for (n = 0; n < conf_info->queue_region_number; n++) { > if (conf_info->region[n].user_priority_num || > conf_info->region[n].flowtype_num) { > - if (!((rte_is_power_of_2(rss->num)) && > - rss->num <= 64)) { > + if (!((rte_is_power_of_2(rss->queue_num)) && > + rss->queue_num <= 64)) { > rte_flow_error_set(error, EINVAL, > RTE_FLOW_ERROR_TYPE_ACTION, > act, > @@ -4294,7 +4294,8 @@ i40e_flow_parse_rss_action(struct rte_eth_dev > *dev, > } > > for (i = 0; i < info->queue_region_number; i++) { > - if (info->region[i].queue_num == rss->num > && > + if (info->region[i].queue_num == > + rss->queue_num && > info->region[i].queue_start_index == > rss->queue[0]) > break; > @@ -4310,7 +4311,7 @@ i40e_flow_parse_rss_action(struct rte_eth_dev > *dev, > } > > info->region[i].queue_num = > - rss->num; > + rss->queue_num; > info->region[i].queue_start_index = > rss->queue[0]; > info->region[i].region_id = > @@ -4356,7 +4357,7 @@ i40e_flow_parse_rss_action(struct rte_eth_dev > *dev, > if (rss_config->queue_region_conf) > return 0; > > - if (!rss || !rss->num) { > + if (!rss || !rss->queue_num) { > rte_flow_error_set(error, EINVAL, > RTE_FLOW_ERROR_TYPE_ACTION, > act, > @@ -4364,7 +4365,7 @@ i40e_flow_parse_rss_action(struct rte_eth_dev > *dev, > return -rte_errno; > } > > - for (n = 0; n < rss->num; n++) { > + for (n = 0; n < rss->queue_num; n++) { > if (rss->queue[n] >= dev->data->nb_rx_queues) { > rte_flow_error_set(error, EINVAL, > RTE_FLOW_ERROR_TYPE_ACTION, > @@ -4375,15 +4376,19 @@ i40e_flow_parse_rss_action(struct rte_eth_dev > *dev, > } > > /* Parse RSS related parameters from configuration */ > - if (rss->rss_conf) > - rss_config->rss_conf = *rss->rss_conf; > - else > - rss_config->rss_conf.rss_hf = > - pf->adapter->flow_types_mask; > + if (rss->key_len && rss->key_len > RTE_DIM(rss_config->key)) > + return rte_flow_error_set > + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, > act, > + "RSS hash key too large"); > + if (rss->queue_num > RTE_DIM(rss_config->queue)) > + return rte_flow_error_set > + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, > act, > + "too many queues for RSS context"); > + if (i40e_rss_conf_init(rss_config, rss)) > + return rte_flow_error_set > + (error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, > act, > + "RSS context initialization failure"); > > - for (n = 0; n < rss->num; ++n) > - rss_config->queue[n] = rss->queue[n]; > - rss_config->num = rss->num; > index++; > > /* check if the next not void action is END */ > @@ -4903,7 +4908,7 @@ i40e_flow_flush_rss_filter(struct rte_eth_dev *dev) > > ret = i40e_flush_queue_region_all_conf(dev, hw, pf, 0); > > - if (rss_info->num) > + if (rss_info->conf.queue_num) > ret = i40e_config_rss_filter(pf, rss_info, FALSE); > return ret; > } > diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c > b/drivers/net/ixgbe/ixgbe_ethdev.c > index 92434809c..c00bdae3d 100644 > --- a/drivers/net/ixgbe/ixgbe_ethdev.c > +++ b/drivers/net/ixgbe/ixgbe_ethdev.c > @@ -100,8 +100,6 @@ > > #define IXGBE_QUEUE_STAT_COUNTERS (sizeof(hw_stats->qprc) / > sizeof(hw_stats->qprc[0])) > > -#define IXGBE_HKEY_MAX_INDEX 10 > - > /* Additional timesync values. */ > #define NSEC_PER_SEC 1000000000L > #define IXGBE_INCVAL_10GB 0x66666666 > @@ -8371,7 +8369,7 @@ ixgbe_rss_filter_restore(struct rte_eth_dev *dev) > struct ixgbe_filter_info *filter_info = > IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data- > >dev_private); > > - if (filter_info->rss_info.num) > + if (filter_info->rss_info.conf.queue_num) > ixgbe_config_rss_filter(dev, > &filter_info->rss_info, TRUE); > } > diff --git a/drivers/net/ixgbe/ixgbe_ethdev.h > b/drivers/net/ixgbe/ixgbe_ethdev.h > index 655077700..9491b03f4 100644 > --- a/drivers/net/ixgbe/ixgbe_ethdev.h > +++ b/drivers/net/ixgbe/ixgbe_ethdev.h > @@ -4,6 +4,9 @@ > > #ifndef _IXGBE_ETHDEV_H_ > #define _IXGBE_ETHDEV_H_ > + > +#include <stdint.h> > + > #include "base/ixgbe_type.h" > #include "base/ixgbe_dcb.h" > #include "base/ixgbe_dcb_82599.h" > @@ -12,6 +15,7 @@ > #ifdef RTE_LIBRTE_SECURITY > #include "ixgbe_ipsec.h" > #endif > +#include <rte_flow.h> > #include <rte_time.h> > #include <rte_hash.h> > #include <rte_pci.h> > @@ -39,6 +43,7 @@ > #define IXGBE_EXTENDED_VLAN (uint32_t)(1 << 26) /* EXTENDED > VLAN ENABLE */ > #define IXGBE_VFTA_SIZE 128 > #define IXGBE_VLAN_TAG_SIZE 4 > +#define IXGBE_HKEY_MAX_INDEX 10 > #define IXGBE_MAX_RX_QUEUE_NUM 128 > #define IXGBE_MAX_INTR_QUEUE_NUM 15 > #define IXGBE_VMDQ_DCB_NB_QUEUES IXGBE_MAX_RX_QUEUE_NUM > @@ -196,8 +201,8 @@ struct ixgbe_hw_fdir_info { > }; > > struct ixgbe_rte_flow_rss_conf { > - struct rte_eth_rss_conf rss_conf; /**< RSS parameters. */ > - uint16_t num; /**< Number of entries in queue[]. */ > + struct rte_flow_action_rss conf; /**< RSS parameters. */ > + uint8_t key[IXGBE_HKEY_MAX_INDEX * sizeof(uint32_t)]; /* Hash > key. */ > uint16_t queue[IXGBE_MAX_RX_QUEUE_NUM]; /**< Queues > indices to use. */ > }; > > @@ -696,6 +701,10 @@ void ixgbe_tm_conf_init(struct rte_eth_dev *dev); > void ixgbe_tm_conf_uninit(struct rte_eth_dev *dev); > int ixgbe_set_queue_rate_limit(struct rte_eth_dev *dev, uint16_t > queue_idx, > uint16_t tx_rate); > +int ixgbe_rss_conf_init(struct ixgbe_rte_flow_rss_conf *out, > + const struct rte_flow_action_rss *in); > +int ixgbe_action_rss_same(const struct rte_flow_action_rss *comp, > + const struct rte_flow_action_rss *with); > int ixgbe_config_rss_filter(struct rte_eth_dev *dev, > struct ixgbe_rte_flow_rss_conf *conf, bool add); > > diff --git a/drivers/net/ixgbe/ixgbe_flow.c b/drivers/net/ixgbe/ixgbe_flow.c > index abdeac28b..4e31c7c56 100644 > --- a/drivers/net/ixgbe/ixgbe_flow.c > +++ b/drivers/net/ixgbe/ixgbe_flow.c > @@ -2761,7 +2761,7 @@ ixgbe_parse_rss_filter(struct rte_eth_dev *dev, > > rss = (const struct rte_flow_action_rss *)act->conf; > > - if (!rss || !rss->num) { > + if (!rss || !rss->queue_num) { > rte_flow_error_set(error, EINVAL, > RTE_FLOW_ERROR_TYPE_ACTION, > act, > @@ -2769,7 +2769,7 @@ ixgbe_parse_rss_filter(struct rte_eth_dev *dev, > return -rte_errno; > } > > - for (n = 0; n < rss->num; n++) { > + for (n = 0; n < rss->queue_num; n++) { > if (rss->queue[n] >= dev->data->nb_rx_queues) { > rte_flow_error_set(error, EINVAL, > RTE_FLOW_ERROR_TYPE_ACTION, > @@ -2778,14 +2778,19 @@ ixgbe_parse_rss_filter(struct rte_eth_dev *dev, > return -rte_errno; > } > } > - if (rss->rss_conf) > - rss_conf->rss_conf = *rss->rss_conf; > - else > - rss_conf->rss_conf.rss_hf = IXGBE_RSS_OFFLOAD_ALL; > > - for (n = 0; n < rss->num; ++n) > - rss_conf->queue[n] = rss->queue[n]; > - rss_conf->num = rss->num; > + if (rss->key_len && rss->key_len != RTE_DIM(rss_conf->key)) > + return rte_flow_error_set > + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, > act, > + "RSS hash key must be exactly 40 bytes"); > + if (rss->queue_num > RTE_DIM(rss_conf->queue)) > + return rte_flow_error_set > + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, > act, > + "too many queues for RSS context"); > + if (ixgbe_rss_conf_init(rss_conf, rss)) > + return rte_flow_error_set > + (error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, > act, > + "RSS context initialization failure"); > > /* check if the next not void item is END */ > act = next_no_void_action(actions, act); > @@ -2834,7 +2839,7 @@ ixgbe_clear_rss_filter(struct rte_eth_dev *dev) > struct ixgbe_filter_info *filter_info = > IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data- > >dev_private); > > - if (filter_info->rss_info.num) > + if (filter_info->rss_info.conf.queue_num) > ixgbe_config_rss_filter(dev, &filter_info->rss_info, FALSE); > } > > @@ -3153,9 +3158,8 @@ ixgbe_flow_create(struct rte_eth_dev *dev, > PMD_DRV_LOG(ERR, "failed to allocate > memory"); > goto out; > } > - rte_memcpy(&rss_filter_ptr->filter_info, > - &rss_conf, > - sizeof(struct ixgbe_rte_flow_rss_conf)); > + ixgbe_rss_conf_init(&rss_filter_ptr->filter_info, > + &rss_conf.conf); > TAILQ_INSERT_TAIL(&filter_rss_list, > rss_filter_ptr, entries); > flow->rule = rss_filter_ptr; > diff --git a/drivers/net/ixgbe/ixgbe_rxtx.c b/drivers/net/ixgbe/ixgbe_rxtx.c > index aed3f5a9a..9fbd7dbd7 100644 > --- a/drivers/net/ixgbe/ixgbe_rxtx.c > +++ b/drivers/net/ixgbe/ixgbe_rxtx.c > @@ -5676,6 +5676,36 @@ ixgbevf_dev_rxtx_start(struct rte_eth_dev *dev) > } > > int > +ixgbe_rss_conf_init(struct ixgbe_rte_flow_rss_conf *out, > + const struct rte_flow_action_rss *in) > +{ > + if (in->key_len > RTE_DIM(out->key) || > + in->queue_num > RTE_DIM(out->queue)) > + return -EINVAL; > + out->conf = (struct rte_flow_action_rss){ > + .types = in->types, > + .key_len = in->key_len, > + .queue_num = in->queue_num, > + .key = memcpy(out->key, in->key, in->key_len), > + .queue = memcpy(out->queue, in->queue, > + sizeof(*in->queue) * in->queue_num), > + }; > + return 0; > +} > + > +int > +ixgbe_action_rss_same(const struct rte_flow_action_rss *comp, > + const struct rte_flow_action_rss *with) > +{ > + return (comp->types == with->types && > + comp->key_len == with->key_len && > + comp->queue_num == with->queue_num && > + !memcmp(comp->key, with->key, with->key_len) && > + !memcmp(comp->queue, with->queue, > + sizeof(*with->queue) * with->queue_num)); > +} > + > +int > ixgbe_config_rss_filter(struct rte_eth_dev *dev, > struct ixgbe_rte_flow_rss_conf *conf, bool add) > { > @@ -5685,7 +5715,12 @@ ixgbe_config_rss_filter(struct rte_eth_dev *dev, > uint16_t j; > uint16_t sp_reta_size; > uint32_t reta_reg; > - struct rte_eth_rss_conf rss_conf = conf->rss_conf; > + struct rte_eth_rss_conf rss_conf = { > + .rss_key = conf->conf.key_len ? > + (void *)(uintptr_t)conf->conf.key : NULL, > + .rss_key_len = conf->conf.key_len, > + .rss_hf = conf->conf.types, > + }; > struct ixgbe_filter_info *filter_info = > IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data- > >dev_private); > > @@ -5695,8 +5730,8 @@ ixgbe_config_rss_filter(struct rte_eth_dev *dev, > sp_reta_size = ixgbe_reta_size_get(hw->mac.type); > > if (!add) { > - if (memcmp(conf, &filter_info->rss_info, > - sizeof(struct ixgbe_rte_flow_rss_conf)) == 0) { > + if (ixgbe_action_rss_same(&filter_info->rss_info.conf, > + &conf->conf)) { > ixgbe_rss_disable(dev); > memset(&filter_info->rss_info, 0, > sizeof(struct ixgbe_rte_flow_rss_conf)); > @@ -5705,7 +5740,7 @@ ixgbe_config_rss_filter(struct rte_eth_dev *dev, > return -EINVAL; > } > > - if (filter_info->rss_info.num) > + if (filter_info->rss_info.conf.queue_num) > return -EINVAL; > /* Fill in redirection table > * The byte-swap is needed because NIC registers are in > @@ -5715,9 +5750,9 @@ ixgbe_config_rss_filter(struct rte_eth_dev *dev, > for (i = 0, j = 0; i < sp_reta_size; i++, j++) { > reta_reg = ixgbe_reta_reg_get(hw->mac.type, i); > > - if (j == conf->num) > + if (j == conf->conf.queue_num) > j = 0; > - reta = (reta << 8) | conf->queue[j]; > + reta = (reta << 8) | conf->conf.queue[j]; > if ((i & 3) == 3) > IXGBE_WRITE_REG(hw, reta_reg, > rte_bswap32(reta)); > @@ -5734,8 +5769,8 @@ ixgbe_config_rss_filter(struct rte_eth_dev *dev, > rss_conf.rss_key = rss_intel_key; /* Default hash key */ > ixgbe_hw_rss_hash_set(hw, &rss_conf); > > - rte_memcpy(&filter_info->rss_info, > - conf, sizeof(struct ixgbe_rte_flow_rss_conf)); > + if (ixgbe_rss_conf_init(&filter_info->rss_info, &conf->conf)) > + return -EINVAL; > > return 0; > } > diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c > index 937074a4f..3dd72dbf5 100644 > --- a/drivers/net/mlx4/mlx4.c > +++ b/drivers/net/mlx4/mlx4.c > @@ -571,7 +571,7 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct > rte_pci_device *pci_dev) > " for UDP RSS and inner VXLAN RSS"); > /* Fake support for all possible RSS hash fields. */ > priv->hw_rss_sup = ~UINT64_C(0); > - priv->hw_rss_sup = mlx4_conv_rss_hf(priv, -1); > + priv->hw_rss_sup = mlx4_conv_rss_types(priv, -1); > /* Filter out known unsupported fields. */ > priv->hw_rss_sup &= > ~(uint64_t)(IBV_RX_HASH_SRC_PORT_UDP | > diff --git a/drivers/net/mlx4/mlx4_flow.c b/drivers/net/mlx4/mlx4_flow.c > index 8feb6ae31..dd86e4ce7 100644 > --- a/drivers/net/mlx4/mlx4_flow.c > +++ b/drivers/net/mlx4/mlx4_flow.c > @@ -76,22 +76,22 @@ struct mlx4_drop { > }; > > /** > - * Convert DPDK RSS hash fields to their Verbs equivalent. > + * Convert DPDK RSS hash types to their Verbs equivalent. > * > - * This function returns the supported (default) set when @p rss_hf has > + * This function returns the supported (default) set when @p types has > * special value (uint64_t)-1. > * > * @param priv > * Pointer to private structure. > - * @param rss_hf > - * Hash fields in DPDK format (see struct rte_eth_rss_conf). > + * @param types > + * Hash types in DPDK format (see struct rte_eth_rss_conf). > * > * @return > * A valid Verbs RSS hash fields mask for mlx4 on success, (uint64_t)-1 > * otherwise and rte_errno is set. > */ > uint64_t > -mlx4_conv_rss_hf(struct priv *priv, uint64_t rss_hf) > +mlx4_conv_rss_types(struct priv *priv, uint64_t types) > { > enum { IPV4, IPV6, TCP, UDP, }; > const uint64_t in[] = { > @@ -126,17 +126,17 @@ mlx4_conv_rss_hf(struct priv *priv, uint64_t rss_hf) > unsigned int i; > > for (i = 0; i != RTE_DIM(in); ++i) > - if (rss_hf & in[i]) { > - seen |= rss_hf & in[i]; > + if (types & in[i]) { > + seen |= types & in[i]; > conv |= out[i]; > } > if ((conv & priv->hw_rss_sup) == conv) { > - if (rss_hf == (uint64_t)-1) { > + if (types == (uint64_t)-1) { > /* Include inner RSS by default if supported. */ > conv |= priv->hw_rss_sup & IBV_RX_HASH_INNER; > return conv; > } > - if (!(rss_hf & ~seen)) > + if (!(types & ~seen)) > return conv; > } > rte_errno = ENOTSUP; > @@ -717,7 +717,8 @@ mlx4_flow_prepare(struct priv *priv, > switch (action->type) { > const struct rte_flow_action_queue *queue; > const struct rte_flow_action_rss *rss; > - const struct rte_eth_rss_conf *rss_conf; > + const uint8_t *rss_key; > + uint32_t rss_key_len; > uint64_t fields; > unsigned int i; > > @@ -747,58 +748,56 @@ mlx4_flow_prepare(struct priv *priv, > break; > rss = action->conf; > /* Default RSS configuration if none is provided. */ > - rss_conf = > - rss->rss_conf ? > - rss->rss_conf : > - &(struct rte_eth_rss_conf){ > - .rss_key = > mlx4_rss_hash_key_default, > - .rss_key_len = > MLX4_RSS_HASH_KEY_SIZE, > - .rss_hf = -1, > - }; > + if (rss->key_len) { > + rss_key = rss->key; > + rss_key_len = rss->key_len; > + } else { > + rss_key = mlx4_rss_hash_key_default; > + rss_key_len = MLX4_RSS_HASH_KEY_SIZE; > + } > /* Sanity checks. */ > - for (i = 0; i < rss->num; ++i) > + for (i = 0; i < rss->queue_num; ++i) > if (rss->queue[i] >= > priv->dev->data->nb_rx_queues) > break; > - if (i != rss->num) { > + if (i != rss->queue_num) { > msg = "queue index target beyond number > of" > " configured Rx queues"; > goto exit_action_not_supported; > } > - if (!rte_is_power_of_2(rss->num)) { > + if (!rte_is_power_of_2(rss->queue_num)) { > msg = "for RSS, mlx4 requires the number of" > " queues to be a power of two"; > goto exit_action_not_supported; > } > - if (rss_conf->rss_key_len != > - sizeof(flow->rss->key)) { > + if (rss_key_len != sizeof(flow->rss->key)) { > msg = "mlx4 supports exactly one RSS hash > key" > " length: " > > MLX4_STR_EXPAND(MLX4_RSS_HASH_KEY_SIZE); > goto exit_action_not_supported; > } > - for (i = 1; i < rss->num; ++i) > + for (i = 1; i < rss->queue_num; ++i) > if (rss->queue[i] - rss->queue[i - 1] != 1) > break; > - if (i != rss->num) { > + if (i != rss->queue_num) { > msg = "mlx4 requires RSS contexts to use" > " consecutive queue indices only"; > goto exit_action_not_supported; > } > - if (rss->queue[0] % rss->num) { > + if (rss->queue[0] % rss->queue_num) { > msg = "mlx4 requires the first queue of a > RSS" > " context to be aligned on a multiple" > " of the context size"; > goto exit_action_not_supported; > } > rte_errno = 0; > - fields = mlx4_conv_rss_hf(priv, rss_conf->rss_hf); > + fields = mlx4_conv_rss_types(priv, rss->types); > if (fields == (uint64_t)-1 && rte_errno) { > msg = "unsupported RSS hash type > requested"; > goto exit_action_not_supported; > } > flow->rss = mlx4_rss_get > - (priv, fields, rss_conf->rss_key, rss->num, > + (priv, fields, rss_key, rss->queue_num, > rss->queue); > if (!flow->rss) { > msg = "either invalid parameters or not > enough" > @@ -1284,8 +1283,10 @@ mlx4_flow_internal(struct priv *priv, struct > rte_flow_error *error) > rte_align32pow2(priv->dev->data->nb_rx_queues + 1) >> 1; > uint16_t queue[queues]; > struct rte_flow_action_rss action_rss = { > - .rss_conf = NULL, /* Rely on default fallback settings. */ > - .num = queues, > + .types = -1, > + .key_len = MLX4_RSS_HASH_KEY_SIZE, > + .queue_num = queues, > + .key = mlx4_rss_hash_key_default, > .queue = queue, > }; > struct rte_flow_action actions[] = { > diff --git a/drivers/net/mlx4/mlx4_flow.h b/drivers/net/mlx4/mlx4_flow.h > index 4e3889e67..7b83d74b0 100644 > --- a/drivers/net/mlx4/mlx4_flow.h > +++ b/drivers/net/mlx4/mlx4_flow.h > @@ -47,7 +47,7 @@ struct rte_flow { > > /* mlx4_flow.c */ > > -uint64_t mlx4_conv_rss_hf(struct priv *priv, uint64_t rss_hf); > +uint64_t mlx4_conv_rss_types(struct priv *priv, uint64_t rss_hf); > int mlx4_flow_sync(struct priv *priv, struct rte_flow_error *error); > void mlx4_flow_clean(struct priv *priv); > int mlx4_filter_ctrl(struct rte_eth_dev *dev, > diff --git a/drivers/net/mlx4/mlx4_rxq.c b/drivers/net/mlx4/mlx4_rxq.c > index a7acc047b..65f099423 100644 > --- a/drivers/net/mlx4/mlx4_rxq.c > +++ b/drivers/net/mlx4/mlx4_rxq.c > @@ -88,7 +88,7 @@ > mlx4_rss_hash_key_default[MLX4_RSS_HASH_KEY_SIZE] = { > */ > struct mlx4_rss * > mlx4_rss_get(struct priv *priv, uint64_t fields, > - uint8_t key[MLX4_RSS_HASH_KEY_SIZE], > + const uint8_t key[MLX4_RSS_HASH_KEY_SIZE], > uint16_t queues, const uint16_t queue_id[]) > { > struct mlx4_rss *rss; > diff --git a/drivers/net/mlx4/mlx4_rxtx.h b/drivers/net/mlx4/mlx4_rxtx.h > index b1af86110..2dfee957f 100644 > --- a/drivers/net/mlx4/mlx4_rxtx.h > +++ b/drivers/net/mlx4/mlx4_rxtx.h > @@ -127,7 +127,7 @@ uint8_t > mlx4_rss_hash_key_default[MLX4_RSS_HASH_KEY_SIZE]; > int mlx4_rss_init(struct priv *priv); > void mlx4_rss_deinit(struct priv *priv); > struct mlx4_rss *mlx4_rss_get(struct priv *priv, uint64_t fields, > - uint8_t key[MLX4_RSS_HASH_KEY_SIZE], > + const uint8_t key[MLX4_RSS_HASH_KEY_SIZE], > uint16_t queues, const uint16_t queue_id[]); > void mlx4_rss_put(struct mlx4_rss *rss); > int mlx4_rss_attach(struct mlx4_rss *rss); > diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c > index 0c89bff45..af8853e09 100644 > --- a/drivers/net/mlx5/mlx5_flow.c > +++ b/drivers/net/mlx5/mlx5_flow.c > @@ -214,9 +214,8 @@ struct rte_flow { > TAILQ_ENTRY(rte_flow) next; /**< Pointer to the next flow structure. > */ > uint32_t mark:1; /**< Set if the flow is marked. */ > uint32_t drop:1; /**< Drop queue. */ > - uint16_t queues_n; /**< Number of entries in queue[]. */ > + struct rte_flow_action_rss rss_conf; /**< RSS configuration */ > uint16_t (*queues)[]; /**< Queues indexes to use. */ > - struct rte_eth_rss_conf rss_conf; /**< RSS configuration */ > uint8_t rss_key[40]; /**< copy of the RSS key. */ > struct ibv_counter_set *cs; /**< Holds the counters for the rule. */ > struct mlx5_flow_counter_stats counter_stats;/**<The counter > stats. */ > @@ -406,9 +405,8 @@ struct mlx5_flow_parse { > uint32_t mark:1; /**< Mark is present in the flow. */ > uint32_t count:1; /**< Count is present in the flow. */ > uint32_t mark_id; /**< Mark identifier. */ > + struct rte_flow_action_rss rss_conf; /**< RSS configuration */ > uint16_t queues[RTE_MAX_QUEUES_PER_PORT]; /**< Queues > indexes to use. */ > - uint16_t queues_n; /**< Number of entries in queue[]. */ > - struct rte_eth_rss_conf rss_conf; /**< RSS configuration */ > uint8_t rss_key[40]; /**< copy of the RSS key. */ > enum hash_rxq_type layer; /**< Last pattern layer detected. */ > struct ibv_counter_set *cs; /**< Holds the counter set for the rule */ > @@ -540,47 +538,6 @@ mlx5_flow_item_validate(const struct > rte_flow_item *item, > } > > /** > - * Copy the RSS configuration from the user ones, of the rss_conf is null, > - * uses the driver one. > - * > - * @param parser > - * Internal parser structure. > - * @param rss_conf > - * User RSS configuration to save. > - * > - * @return > - * 0 on success, a negative errno value otherwise and rte_errno is set. > - */ > -static int > -mlx5_flow_convert_rss_conf(struct mlx5_flow_parse *parser, > - const struct rte_eth_rss_conf *rss_conf) > -{ > - /* > - * This function is also called at the beginning of > - * mlx5_flow_convert_actions() to initialize the parser with the > - * device default RSS configuration. > - */ > - if (rss_conf) { > - if (rss_conf->rss_hf & MLX5_RSS_HF_MASK) { > - rte_errno = EINVAL; > - return -rte_errno; > - } > - if (rss_conf->rss_key_len != 40) { > - rte_errno = EINVAL; > - return -rte_errno; > - } > - if (rss_conf->rss_key_len && rss_conf->rss_key) { > - parser->rss_conf.rss_key_len = rss_conf- > >rss_key_len; > - memcpy(parser->rss_key, rss_conf->rss_key, > - rss_conf->rss_key_len); > - parser->rss_conf.rss_key = parser->rss_key; > - } > - parser->rss_conf.rss_hf = rss_conf->rss_hf; > - } > - return 0; > -} > - > -/** > * Extract attribute to the parser. > * > * @param[in] attr > @@ -650,17 +607,7 @@ mlx5_flow_convert_actions(struct rte_eth_dev > *dev, > enum { FATE = 1, MARK = 2, COUNT = 4, }; > uint32_t overlap = 0; > struct priv *priv = dev->data->dev_private; > - int ret; > > - /* > - * Add default RSS configuration necessary for Verbs to create QP > even > - * if no RSS is necessary. > - */ > - ret = mlx5_flow_convert_rss_conf(parser, > - (const struct rte_eth_rss_conf *) > - &priv->rss_conf); > - if (ret) > - return ret; > for (; actions->type != RTE_FLOW_ACTION_TYPE_END; ++actions) { > if (actions->type == RTE_FLOW_ACTION_TYPE_VOID) { > continue; > @@ -679,25 +626,53 @@ mlx5_flow_convert_actions(struct rte_eth_dev > *dev, > overlap |= FATE; > if (!queue || (queue->index > (priv->rxqs_n - 1))) > goto exit_action_not_supported; > - parser->queues_n = 1; > parser->queues[0] = queue->index; > + parser->rss_conf = (struct rte_flow_action_rss){ > + .queue_num = 1, > + .queue = parser->queues, > + }; > } else if (actions->type == RTE_FLOW_ACTION_TYPE_RSS) { > const struct rte_flow_action_rss *rss = > (const struct rte_flow_action_rss *) > actions->conf; > + const uint8_t *rss_key; > + uint32_t rss_key_len; > uint16_t n; > > if (overlap & FATE) > goto exit_action_overlap; > overlap |= FATE; > - if (!rss || !rss->num) { > + if (rss->types & MLX5_RSS_HF_MASK) { > + rte_flow_error_set(error, EINVAL, > + > RTE_FLOW_ERROR_TYPE_ACTION, > + actions, > + "unsupported RSS type" > + " requested"); > + return -rte_errno; > + } > + if (rss->key_len) { > + rss_key_len = rss->key_len; > + rss_key = rss->key; > + } else { > + rss_key_len = rss_hash_default_key_len; > + rss_key = rss_hash_default_key; > + } > + if (rss_key_len != RTE_DIM(parser->rss_key)) { > + rte_flow_error_set(error, EINVAL, > + > RTE_FLOW_ERROR_TYPE_ACTION, > + actions, > + "RSS hash key must be" > + " exactly 40 bytes long"); > + return -rte_errno; > + } > + if (!rss->queue_num) { > rte_flow_error_set(error, EINVAL, > > RTE_FLOW_ERROR_TYPE_ACTION, > actions, > "no valid queues"); > return -rte_errno; > } > - if (rss->num > RTE_DIM(parser->queues)) { > + if (rss->queue_num > RTE_DIM(parser->queues)) { > rte_flow_error_set(error, EINVAL, > > RTE_FLOW_ERROR_TYPE_ACTION, > actions, > @@ -705,7 +680,7 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, > " context"); > return -rte_errno; > } > - for (n = 0; n < rss->num; ++n) { > + for (n = 0; n < rss->queue_num; ++n) { > if (rss->queue[n] >= priv->rxqs_n) { > rte_flow_error_set(error, EINVAL, > > RTE_FLOW_ERROR_TYPE_ACTION, > @@ -715,16 +690,16 @@ mlx5_flow_convert_actions(struct rte_eth_dev > *dev, > return -rte_errno; > } > } > - for (n = 0; n < rss->num; ++n) > - parser->queues[n] = rss->queue[n]; > - parser->queues_n = rss->num; > - if (mlx5_flow_convert_rss_conf(parser, rss- > >rss_conf)) { > - rte_flow_error_set(error, EINVAL, > - > RTE_FLOW_ERROR_TYPE_ACTION, > - actions, > - "wrong RSS configuration"); > - return -rte_errno; > - } > + parser->rss_conf = (struct rte_flow_action_rss){ > + .types = rss->types, > + .key_len = rss_key_len, > + .queue_num = rss->queue_num, > + .key = memcpy(parser->rss_key, rss_key, > + sizeof(*rss_key) * rss_key_len), > + .queue = memcpy(parser->queues, rss- > >queue, > + sizeof(*rss->queue) * > + rss->queue_num), > + }; > } else if (actions->type == RTE_FLOW_ACTION_TYPE_MARK) > { > const struct rte_flow_action_mark *mark = > (const struct rte_flow_action_mark *) > @@ -769,7 +744,7 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, > parser->drop = 1; > if (parser->drop && parser->mark) > parser->mark = 0; > - if (!parser->queues_n && !parser->drop) { > + if (!parser->rss_conf.queue_num && !parser->drop) { > rte_flow_error_set(error, ENOTSUP, > RTE_FLOW_ERROR_TYPE_HANDLE, > NULL, "no valid action"); > return -rte_errno; > @@ -951,7 +926,7 @@ mlx5_flow_convert_finalise(struct mlx5_flow_parse > *parser) > unsigned int i; > > /* Remove any other flow not matching the pattern. */ > - if (parser->queues_n == 1 && !parser->rss_conf.rss_hf) { > + if (parser->rss_conf.queue_num == 1 && !parser->rss_conf.types) { > for (i = 0; i != hash_rxq_init_n; ++i) { > if (i == HASH_RXQ_ETH) > continue; > @@ -979,7 +954,7 @@ mlx5_flow_convert_finalise(struct mlx5_flow_parse > *parser) > } > /* Remove impossible flow according to the RSS configuration. */ > if (hash_rxq_init[parser->layer].dpdk_rss_hf & > - parser->rss_conf.rss_hf) { > + parser->rss_conf.types) { > /* Remove any other flow. */ > for (i = hmin; i != (hmax + 1); ++i) { > if ((i == parser->layer) || > @@ -990,7 +965,7 @@ mlx5_flow_convert_finalise(struct mlx5_flow_parse > *parser) > } > } else if (!parser->queue[ip].ibv_attr) { > /* no RSS possible with the current configuration. */ > - parser->queues_n = 1; > + parser->rss_conf.queue_num = 1; > return; > } > fill: > @@ -1119,7 +1094,7 @@ mlx5_flow_convert(struct rte_eth_dev *dev, > for (i = 0; i != hash_rxq_init_n; ++i) { > unsigned int offset; > > - if (!(parser->rss_conf.rss_hf & > + if (!(parser->rss_conf.types & > hash_rxq_init[i].dpdk_rss_hf) && > (i != HASH_RXQ_ETH)) > continue; > @@ -1787,20 +1762,20 @@ mlx5_flow_create_action_queue_rss(struct > rte_eth_dev *dev, > continue; > flow->frxq[i].hrxq = > mlx5_hrxq_get(dev, > - parser->rss_conf.rss_key, > - parser->rss_conf.rss_key_len, > + parser->rss_conf.key, > + parser->rss_conf.key_len, > hash_fields, > - parser->queues, > - parser->queues_n); > + parser->rss_conf.queue, > + parser->rss_conf.queue_num); > if (flow->frxq[i].hrxq) > continue; > flow->frxq[i].hrxq = > mlx5_hrxq_new(dev, > - parser->rss_conf.rss_key, > - parser->rss_conf.rss_key_len, > + parser->rss_conf.key, > + parser->rss_conf.key_len, > hash_fields, > - parser->queues, > - parser->queues_n); > + parser->rss_conf.queue, > + parser->rss_conf.queue_num); > if (!flow->frxq[i].hrxq) { > return rte_flow_error_set(error, ENOMEM, > > RTE_FLOW_ERROR_TYPE_HANDLE, > @@ -1871,9 +1846,9 @@ mlx5_flow_create_action_queue(struct > rte_eth_dev *dev, > NULL, "internal error in flow creation"); > goto error; > } > - for (i = 0; i != parser->queues_n; ++i) { > + for (i = 0; i != parser->rss_conf.queue_num; ++i) { > struct mlx5_rxq_data *q = > - (*priv->rxqs)[parser->queues[i]]; > + (*priv->rxqs)[parser->rss_conf.queue[i]]; > > q->mark |= parser->mark; > } > @@ -1937,7 +1912,8 @@ mlx5_flow_list_create(struct rte_eth_dev *dev, > if (ret) > goto exit; > flow = rte_calloc(__func__, 1, > - sizeof(*flow) + parser.queues_n * sizeof(uint16_t), > + sizeof(*flow) + > + parser.rss_conf.queue_num * sizeof(uint16_t), > 0); > if (!flow) { > rte_flow_error_set(error, ENOMEM, > @@ -1946,15 +1922,20 @@ mlx5_flow_list_create(struct rte_eth_dev *dev, > "cannot allocate flow memory"); > return NULL; > } > - /* Copy queues configuration. */ > + /* Copy configuration. */ > flow->queues = (uint16_t (*)[])(flow + 1); > - memcpy(flow->queues, parser.queues, parser.queues_n * > sizeof(uint16_t)); > - flow->queues_n = parser.queues_n; > + flow->rss_conf = (struct rte_flow_action_rss){ > + .types = parser.rss_conf.types, > + .key_len = parser.rss_conf.key_len, > + .queue_num = parser.rss_conf.queue_num, > + .key = memcpy(flow->rss_key, parser.rss_conf.key, > + sizeof(*parser.rss_conf.key) * > + parser.rss_conf.key_len), > + .queue = memcpy(flow->queues, parser.rss_conf.queue, > + sizeof(*parser.rss_conf.queue) * > + parser.rss_conf.queue_num), > + }; > flow->mark = parser.mark; > - /* Copy RSS configuration. */ > - flow->rss_conf = parser.rss_conf; > - flow->rss_conf.rss_key = flow->rss_key; > - memcpy(flow->rss_key, parser.rss_key, > parser.rss_conf.rss_key_len); > /* finalise the flow. */ > if (parser.drop) > ret = mlx5_flow_create_action_queue_drop(dev, &parser, > flow, > @@ -2034,7 +2015,7 @@ mlx5_flow_list_destroy(struct rte_eth_dev *dev, > struct mlx5_flows *list, > > if (flow->drop || !flow->mark) > goto free; > - for (i = 0; i != flow->queues_n; ++i) { > + for (i = 0; i != flow->rss_conf.queue_num; ++i) { > struct rte_flow *tmp; > int mark = 0; > > @@ -2344,19 +2325,19 @@ mlx5_flow_start(struct rte_eth_dev *dev, struct > mlx5_flows *list) > if (!flow->frxq[i].ibv_attr) > continue; > flow->frxq[i].hrxq = > - mlx5_hrxq_get(dev, flow->rss_conf.rss_key, > - flow->rss_conf.rss_key_len, > + mlx5_hrxq_get(dev, flow->rss_conf.key, > + flow->rss_conf.key_len, > hash_rxq_init[i].hash_fields, > - (*flow->queues), > - flow->queues_n); > + flow->rss_conf.queue, > + flow->rss_conf.queue_num); > if (flow->frxq[i].hrxq) > goto flow_create; > flow->frxq[i].hrxq = > - mlx5_hrxq_new(dev, flow->rss_conf.rss_key, > - flow->rss_conf.rss_key_len, > + mlx5_hrxq_new(dev, flow->rss_conf.key, > + flow->rss_conf.key_len, > hash_rxq_init[i].hash_fields, > - (*flow->queues), > - flow->queues_n); > + flow->rss_conf.queue, > + flow->rss_conf.queue_num); > if (!flow->frxq[i].hrxq) { > DRV_LOG(DEBUG, > "port %u flow %p cannot be applied", > @@ -2380,8 +2361,8 @@ mlx5_flow_start(struct rte_eth_dev *dev, struct > mlx5_flows *list) > } > if (!flow->mark) > continue; > - for (i = 0; i != flow->queues_n; ++i) > - (*priv->rxqs)[(*flow->queues)[i]]->mark = 1; > + for (i = 0; i != flow->rss_conf.queue_num; ++i) > + (*priv->rxqs)[flow->rss_conf.queue[i]]->mark = 1; > } > return 0; > } > @@ -2458,8 +2439,10 @@ mlx5_ctrl_flow_vlan(struct rte_eth_dev *dev, > }; > uint16_t queue[priv->reta_idx_n]; > struct rte_flow_action_rss action_rss = { > - .rss_conf = &priv->rss_conf, > - .num = priv->reta_idx_n, > + .types = priv->rss_conf.rss_hf, > + .key_len = priv->rss_conf.rss_key_len, > + .queue_num = priv->reta_idx_n, > + .key = priv->rss_conf.rss_key, > .queue = queue, > }; > struct rte_flow_action actions[] = { > diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c > index eda3ba3d5..d2b25e8e8 100644 > --- a/drivers/net/mlx5/mlx5_rxq.c > +++ b/drivers/net/mlx5/mlx5_rxq.c > @@ -1218,8 +1218,8 @@ mlx5_rxq_verify(struct rte_eth_dev *dev) > * The Verbs object initialised, NULL otherwise and rte_errno is set. > */ > struct mlx5_ind_table_ibv * > -mlx5_ind_table_ibv_new(struct rte_eth_dev *dev, uint16_t queues[], > - uint16_t queues_n) > +mlx5_ind_table_ibv_new(struct rte_eth_dev *dev, const uint16_t *queues, > + uint32_t queues_n) > { > struct priv *priv = dev->data->dev_private; > struct mlx5_ind_table_ibv *ind_tbl; > @@ -1286,8 +1286,8 @@ mlx5_ind_table_ibv_new(struct rte_eth_dev *dev, > uint16_t queues[], > * An indirection table if found. > */ > struct mlx5_ind_table_ibv * > -mlx5_ind_table_ibv_get(struct rte_eth_dev *dev, uint16_t queues[], > - uint16_t queues_n) > +mlx5_ind_table_ibv_get(struct rte_eth_dev *dev, const uint16_t *queues, > + uint32_t queues_n) > { > struct priv *priv = dev->data->dev_private; > struct mlx5_ind_table_ibv *ind_tbl; > @@ -1391,8 +1391,10 @@ mlx5_ind_table_ibv_verify(struct rte_eth_dev > *dev) > * The Verbs object initialised, NULL otherwise and rte_errno is set. > */ > struct mlx5_hrxq * > -mlx5_hrxq_new(struct rte_eth_dev *dev, uint8_t *rss_key, uint8_t > rss_key_len, > - uint64_t hash_fields, uint16_t queues[], uint16_t queues_n) > +mlx5_hrxq_new(struct rte_eth_dev *dev, > + const uint8_t *rss_key, uint32_t rss_key_len, > + uint64_t hash_fields, > + const uint16_t *queues, uint32_t queues_n) > { > struct priv *priv = dev->data->dev_private; > struct mlx5_hrxq *hrxq; > @@ -1408,6 +1410,10 @@ mlx5_hrxq_new(struct rte_eth_dev *dev, uint8_t > *rss_key, uint8_t rss_key_len, > rte_errno = ENOMEM; > return NULL; > } > + if (!rss_key_len) { > + rss_key_len = rss_hash_default_key_len; > + rss_key = rss_hash_default_key; > + } > qp = mlx5_glue->create_qp_ex > (priv->ctx, > &(struct ibv_qp_init_attr_ex){ > @@ -1419,7 +1425,7 @@ mlx5_hrxq_new(struct rte_eth_dev *dev, uint8_t > *rss_key, uint8_t rss_key_len, > .rx_hash_conf = (struct ibv_rx_hash_conf){ > .rx_hash_function = > IBV_RX_HASH_FUNC_TOEPLITZ, > .rx_hash_key_len = rss_key_len, > - .rx_hash_key = rss_key, > + .rx_hash_key = (void *)(uintptr_t)rss_key, > .rx_hash_fields_mask = hash_fields, > }, > .rwq_ind_tbl = ind_tbl->ind_table, > @@ -1469,8 +1475,10 @@ mlx5_hrxq_new(struct rte_eth_dev *dev, uint8_t > *rss_key, uint8_t rss_key_len, > * An hash Rx queue on success. > */ > struct mlx5_hrxq * > -mlx5_hrxq_get(struct rte_eth_dev *dev, uint8_t *rss_key, uint8_t > rss_key_len, > - uint64_t hash_fields, uint16_t queues[], uint16_t queues_n) > +mlx5_hrxq_get(struct rte_eth_dev *dev, > + const uint8_t *rss_key, uint32_t rss_key_len, > + uint64_t hash_fields, > + const uint16_t *queues, uint32_t queues_n) > { > struct priv *priv = dev->data->dev_private; > struct mlx5_hrxq *hrxq; > diff --git a/drivers/net/mlx5/mlx5_rxtx.h b/drivers/net/mlx5/mlx5_rxtx.h > index 14d4418d9..c3a1ae213 100644 > --- a/drivers/net/mlx5/mlx5_rxtx.h > +++ b/drivers/net/mlx5/mlx5_rxtx.h > @@ -134,7 +134,7 @@ struct mlx5_ind_table_ibv { > LIST_ENTRY(mlx5_ind_table_ibv) next; /* Pointer to the next > element. */ > rte_atomic32_t refcnt; /* Reference counter. */ > struct ibv_rwq_ind_table *ind_table; /**< Indirection table. */ > - uint16_t queues_n; /**< Number of queues in the list. */ > + uint32_t queues_n; /**< Number of queues in the list. */ > uint16_t queues[]; /**< Queue list. */ > }; > > @@ -145,7 +145,7 @@ struct mlx5_hrxq { > struct mlx5_ind_table_ibv *ind_table; /* Indirection table. */ > struct ibv_qp *qp; /* Verbs queue pair. */ > uint64_t hash_fields; /* Verbs Hash fields. */ > - uint8_t rss_key_len; /* Hash key length in bytes. */ > + uint32_t rss_key_len; /* Hash key length in bytes. */ > uint8_t rss_key[]; /* Hash key. */ > }; > > @@ -238,20 +238,22 @@ int mlx5_rxq_releasable(struct rte_eth_dev *dev, > uint16_t idx); > int mlx5_rxq_verify(struct rte_eth_dev *dev); > int rxq_alloc_elts(struct mlx5_rxq_ctrl *rxq_ctrl); > struct mlx5_ind_table_ibv *mlx5_ind_table_ibv_new(struct rte_eth_dev > *dev, > - uint16_t queues[], > - uint16_t queues_n); > + const uint16_t *queues, > + uint32_t queues_n); > struct mlx5_ind_table_ibv *mlx5_ind_table_ibv_get(struct rte_eth_dev > *dev, > - uint16_t queues[], > - uint16_t queues_n); > + const uint16_t *queues, > + uint32_t queues_n); > int mlx5_ind_table_ibv_release(struct rte_eth_dev *dev, > struct mlx5_ind_table_ibv *ind_tbl); > int mlx5_ind_table_ibv_verify(struct rte_eth_dev *dev); > -struct mlx5_hrxq *mlx5_hrxq_new(struct rte_eth_dev *dev, uint8_t > *rss_key, > - uint8_t rss_key_len, uint64_t hash_fields, > - uint16_t queues[], uint16_t queues_n); > -struct mlx5_hrxq *mlx5_hrxq_get(struct rte_eth_dev *dev, uint8_t > *rss_key, > - uint8_t rss_key_len, uint64_t hash_fields, > - uint16_t queues[], uint16_t queues_n); > +struct mlx5_hrxq *mlx5_hrxq_new(struct rte_eth_dev *dev, > + const uint8_t *rss_key, uint32_t rss_key_len, > + uint64_t hash_fields, > + const uint16_t *queues, uint32_t queues_n); > +struct mlx5_hrxq *mlx5_hrxq_get(struct rte_eth_dev *dev, > + const uint8_t *rss_key, uint32_t rss_key_len, > + uint64_t hash_fields, > + const uint16_t *queues, uint32_t queues_n); > int mlx5_hrxq_release(struct rte_eth_dev *dev, struct mlx5_hrxq *hxrq); > int mlx5_hrxq_ibv_verify(struct rte_eth_dev *dev); > uint64_t mlx5_get_rx_port_offloads(void); > diff --git a/drivers/net/sfc/sfc_flow.c b/drivers/net/sfc/sfc_flow.c > index 056405515..1a2c0299c 100644 > --- a/drivers/net/sfc/sfc_flow.c > +++ b/drivers/net/sfc/sfc_flow.c > @@ -1234,13 +1234,11 @@ sfc_flow_parse_rss(struct sfc_adapter *sa, > struct sfc_rxq *rxq; > unsigned int rxq_hw_index_min; > unsigned int rxq_hw_index_max; > - const struct rte_eth_rss_conf *rss_conf = rss->rss_conf; > - uint64_t rss_hf; > - uint8_t *rss_key = NULL; > + const uint8_t *rss_key; > struct sfc_flow_rss *sfc_rss_conf = &flow->rss_conf; > unsigned int i; > > - if (rss->num == 0) > + if (rss->queue_num == 0) > return -EINVAL; > > rxq_sw_index = sa->rxq_count - 1; > @@ -1248,7 +1246,7 @@ sfc_flow_parse_rss(struct sfc_adapter *sa, > rxq_hw_index_min = rxq->hw_index; > rxq_hw_index_max = 0; > > - for (i = 0; i < rss->num; ++i) { > + for (i = 0; i < rss->queue_num; ++i) { > rxq_sw_index = rss->queue[i]; > > if (rxq_sw_index >= sa->rxq_count) > @@ -1263,15 +1261,14 @@ sfc_flow_parse_rss(struct sfc_adapter *sa, > rxq_hw_index_max = rxq->hw_index; > } > > - rss_hf = (rss_conf != NULL) ? rss_conf->rss_hf : SFC_RSS_OFFLOADS; > - if ((rss_hf & ~SFC_RSS_OFFLOADS) != 0) > + if ((rss->types & ~SFC_RSS_OFFLOADS) != 0) > return -EINVAL; > > - if (rss_conf != NULL) { > - if (rss_conf->rss_key_len != sizeof(sa->rss_key)) > + if (rss->key_len) { > + if (rss->key_len != sizeof(sa->rss_key)) > return -EINVAL; > > - rss_key = rss_conf->rss_key; > + rss_key = rss->key; > } else { > rss_key = sa->rss_key; > } > @@ -1280,11 +1277,11 @@ sfc_flow_parse_rss(struct sfc_adapter *sa, > > sfc_rss_conf->rxq_hw_index_min = rxq_hw_index_min; > sfc_rss_conf->rxq_hw_index_max = rxq_hw_index_max; > - sfc_rss_conf->rss_hash_types = sfc_rte_to_efx_hash_type(rss_hf); > + sfc_rss_conf->rss_hash_types = sfc_rte_to_efx_hash_type(rss- > >types); > rte_memcpy(sfc_rss_conf->rss_key, rss_key, sizeof(sa->rss_key)); > > for (i = 0; i < RTE_DIM(sfc_rss_conf->rss_tbl); ++i) { > - unsigned int rxq_sw_index = rss->queue[i % rss->num]; > + unsigned int rxq_sw_index = rss->queue[i % rss- > >queue_num]; > struct sfc_rxq *rxq = sa->rxq_info[rxq_sw_index].rxq; > > sfc_rss_conf->rss_tbl[i] = rxq->hw_index - > rxq_hw_index_min; > diff --git a/drivers/net/tap/tap_flow.c b/drivers/net/tap/tap_flow.c > index fe2f94010..67146aaba 100644 > --- a/drivers/net/tap/tap_flow.c > +++ b/drivers/net/tap/tap_flow.c > @@ -1215,7 +1215,7 @@ priv_flow_process(struct pmd_internals *pmd, > if (err) > goto exit_action_not_supported; > } > - if (flow && rss) > + if (flow) > err = rss_add_actions(flow, pmd, rss, error); > } else { > goto exit_action_not_supported; > @@ -2050,7 +2050,7 @@ static int rss_add_actions(struct rte_flow *flow, > struct pmd_internals *pmd, > struct rte_flow_error *error) > { > /* 4096 is the maximum number of instructions for a BPF program */ > - int i; > + unsigned int i; > int err; > struct rss_key rss_entry = { .hash_fields = 0, > .key_size = 0 }; > @@ -2066,8 +2066,8 @@ static int rss_add_actions(struct rte_flow *flow, > struct pmd_internals *pmd, > } > > /* Update RSS map entry with queues */ > - rss_entry.nb_queues = rss->num; > - for (i = 0; i < rss->num; i++) > + rss_entry.nb_queues = rss->queue_num; > + for (i = 0; i < rss->queue_num; i++) > rss_entry.queues[i] = rss->queue[i]; > rss_entry.hash_fields = > (1 << HASH_FIELD_IPV4_L3_L4) | (1 << > HASH_FIELD_IPV6_L3_L4); > diff --git a/examples/ipsec-secgw/ipsec.c b/examples/ipsec-secgw/ipsec.c > index 5971937cf..ee2497352 100644 > --- a/examples/ipsec-secgw/ipsec.c > +++ b/examples/ipsec-secgw/ipsec.c > @@ -203,9 +203,13 @@ create_session(struct ipsec_ctx *ipsec_ctx, struct > ipsec_sa *sa) > i < eth_dev->data->nb_rx_queues; ++i) > if (eth_dev->data->rx_queues[i]) > queue[j++] = i; > - action_rss.rss_conf = &rss_conf; > - action_rss.num = j; > - action_rss.queue = queue; > + action_rss = (struct rte_flow_action_rss){ > + .types = rss_conf.rss_hf, > + .key_len = rss_conf.rss_key_len, > + .queue_num = j, > + .key = rss_key, > + .queue = queue, > + }; > ret = rte_flow_validate(sa->portid, &sa->attr, > sa->pattern, sa- > >action, > &err); > diff --git a/lib/librte_ether/rte_flow.c b/lib/librte_ether/rte_flow.c > index bb19e28c6..cc7819b6a 100644 > --- a/lib/librte_ether/rte_flow.c > +++ b/lib/librte_ether/rte_flow.c > @@ -330,40 +330,27 @@ flow_action_conf_copy(void *buf, const struct > rte_flow_action *action) > off = 0; > if (dst.rss) > *dst.rss = (struct rte_flow_action_rss){ > - .num = src.rss->num, > + .types = src.rss->types, > + .key_len = src.rss->key_len, > + .queue_num = src.rss->queue_num, > }; > off += sizeof(*src.rss); > - if (src.rss->num) { > + if (src.rss->key_len) { > off = RTE_ALIGN_CEIL(off, sizeof(double)); > - size = sizeof(*src.rss->queue) * src.rss->num; > + size = sizeof(*src.rss->key) * src.rss->key_len; > if (dst.rss) > - dst.rss->queue = memcpy > + dst.rss->key = memcpy > ((void *)((uintptr_t)dst.rss + off), > - src.rss->queue, size); > + src.rss->key, size); > off += size; > } > - off = RTE_ALIGN_CEIL(off, sizeof(double)); > - if (dst.rss) { > - dst.rss->rss_conf = (void *)((uintptr_t)dst.rss + off); > - *(struct rte_eth_rss_conf *)(uintptr_t) > - dst.rss->rss_conf = (struct > rte_eth_rss_conf){ > - .rss_key_len = src.rss->rss_conf- > >rss_key_len, > - .rss_hf = src.rss->rss_conf->rss_hf, > - }; > - } > - off += sizeof(*src.rss->rss_conf); > - if (src.rss->rss_conf->rss_key_len) { > + if (src.rss->queue_num) { > off = RTE_ALIGN_CEIL(off, sizeof(double)); > - size = sizeof(*src.rss->rss_conf->rss_key) * > - src.rss->rss_conf->rss_key_len; > - if (dst.rss) { > - ((struct rte_eth_rss_conf *)(uintptr_t) > - dst.rss->rss_conf)->rss_key = > - (void *)((uintptr_t)dst.rss + off); > - memcpy(dst.rss->rss_conf->rss_key, > - src.rss->rss_conf->rss_key, > - size); > - } > + size = sizeof(*src.rss->queue) * src.rss->queue_num; > + if (dst.rss) > + dst.rss->queue = memcpy > + ((void *)((uintptr_t)dst.rss + off), > + src.rss->queue, size); > off += size; > } > size = off; > diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h > index ad2e55b8e..bbc408fa6 100644 > --- a/lib/librte_ether/rte_flow.h > +++ b/lib/librte_ether/rte_flow.h > @@ -1033,13 +1033,21 @@ struct rte_flow_query_count { > * Similar to QUEUE, except RSS is additionally performed on packets to > * spread them among several queues according to the provided parameters. > * > + * Unlike global RSS settings used by other DPDK APIs, unsetting the > + * @p types field does not disable RSS in a flow rule. Doing so instead > + * requests safe unspecified "best-effort" settings from the underlying > PMD, > + * which depending on the flow rule, may result in anything ranging from > + * empty (single queue) to all-inclusive RSS. > + * > * Note: RSS hash result is stored in the hash.rss mbuf field which overlaps > * hash.fdir.lo. Since the MARK action sets the hash.fdir.hi field only, > * both can be requested simultaneously. > */ > struct rte_flow_action_rss { > - const struct rte_eth_rss_conf *rss_conf; /**< RSS parameters. */ > - uint16_t num; /**< Number of entries in @p queue. */ > + uint64_t types; /**< Specific RSS hash types (see ETH_RSS_*). */ > + uint32_t key_len; /**< Hash key length in bytes. */ > + uint32_t queue_num; /**< Number of entries in @p queue. */ > + const uint8_t *key; /**< Hash key. */ > const uint16_t *queue; /**< Queue indices to use. */ > }; > > -- > 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [dpdk-dev] [PATCH v6 07/16] ethdev: flatten RSS configuration in flow API 2018-04-28 5:28 ` Peng, Yuan @ 2018-04-28 7:45 ` Peng, Yuan 2018-05-03 12:48 ` Adrien Mazarguil 0 siblings, 1 reply; 157+ messages in thread From: Peng, Yuan @ 2018-04-28 7:45 UTC (permalink / raw) To: Peng, Yuan, Zhao1, Wei, Adrien Mazarguil, dev Cc: Xu, Qian Q, Liu, Yu Y, Lu, Wenzhuo, Wu, Jingjing Hi,Adrien Mazarguil There is a bug of queue region with 18.05-rc1 The test steps are as below: ./usertools/dpdk-devbind.py -b igb_uio 05:00.0 ./x86_64-native-linuxapp-gcc/app/testpmd -c 1ffff -n 4 -- -i --rxq=16 --txq=16 testpmd> port config all rss all Configuration of RSS hash at ethernet port 0 failed with error (22): Invalid argument. testpmd> set fwd rxonly testpmd> set verbose 1 testpmd> start testpmd> set port 0 queue-region region_id 0 queue_start_index 1 queue_num 1 testpmd> set port 0 queue-region region_id 0 flowtype 31 testpmd> set port 0 queue-region flush on testpmd> port 0/queue 0: received 1 packets src=00:13:3B:0C:21:95 - dst=00:00:00:00:01:00 - type=0x0800 - length=90 - nb_segs=1 - hw ptype: L2_ETHER L3_IPV4_EXT_UNKNOWN L4_UDP - sw ptype: L2_ETHER L3_IPV4 L4_UDP - l2_len=14 - l3_len=20 - l4_len=8 - Receive queue=0x0 ol_flags: PKT_RX_L4_CKSUM_GOOD PKT_RX_IP_CKSUM_GOOD the packet should be distributed to queue 1 instead of queue0. And the command" port config all rss all" failed to execute. Could you help to check if this has relationship with your patches relevant to flow api? Thanks. Yuan. -----Original Message----- From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Peng, Yuan Sent: Saturday, April 28, 2018 1:29 PM To: Zhao1, Wei <wei.zhao1@intel.com>; Adrien Mazarguil <adrien.mazarguil@6wind.com>; dev@dpdk.org Cc: Xu, Qian Q <qian.q.xu@intel.com>; Liu, Yu Y <yu.y.liu@intel.com>; Lu, Wenzhuo <wenzhuo.lu@intel.com>; Wu, Jingjing <jingjing.wu@intel.com> Subject: Re: [dpdk-dev] [PATCH v6 07/16] ethdev: flatten RSS configuration in flow API Hi,Adrien Mazarguil There is a bug present with 18.05-rci when I test the feature "Move RSS to rte_flow" in i40e NIC The test steps are as below: ./usertools/dpdk-devbind.py -b igb_uio 05:00.0 05:00.1 ./x86_64-native-linuxapp-gcc/app/testpmd -c 0x1fffe -n 4 -- -i --nb-cores=8 --rxq=8 --txq=8 --port-topology=chained testpmd> set fwd rxonly Set rxonly packet forwarding mode testpmd> set verbose 1 Change verbose level from 0 to 1 testpmd> start testpmd> flow create 0 ingress pattern end actions rss queues 0 4 7 end / end Caught error type 16 (specific action): cause: 0x7fff84e33658, RSS hash key too large The rss rule can be set successfully when I test it yesterday with older dpdk version without this patch. The NIC information is: driver: i40e version: 2.4.3 firmware-version: 6.01 0x80003205 1.1691.0 There is another problem with ixgbe nic: ./usertools/dpdk-devbind.py -b igb_uio 07:00.0 07:00.1 ./x86_64-native-linuxapp-gcc/app/testpmd -c 0x1fffe -n 4 -- -i --nb-cores=8 --rxq=8 --txq=8 --disable-rss --port-topology=chained testpmd> flow create 0 ingress pattern end actions rss queues 5 6 7 end / end Caught error type 2 (flow rule (handle)): Failed to create flow. The rule setting command can be executed successfully with older dpdk version. Could you help to check if there is a relationship between the bugs and this patch? Thank you. Yuan. -----Original Message----- From: Zhao1, Wei Sent: Saturday, April 28, 2018 11:46 AM To: Adrien Mazarguil <adrien.mazarguil@6wind.com>; dev@dpdk.org Cc: Peng, Yuan <yuan.peng@intel.com>; Xu, Qian Q <qian.q.xu@intel.com>; Liu, Yu Y <yu.y.liu@intel.com>; Lu, Wenzhuo <wenzhuo.lu@intel.com>; Wu, Jingjing <jingjing.wu@intel.com> Subject: RE: [dpdk-dev] [PATCH v6 07/16] ethdev: flatten RSS configuration in flow API Hi,Adrien Mazarguil We have just use new RC.1 code on the feature of flow RSS API, but we find some abnormal phenomenon. After that I check code again, I find that it is introduced in this patch: SHA-1: ac8d22de2394e03ba4a77d8fd24381147aafb1d3 * ethdev: flatten RSS configuration in flow API Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> This abnormal phenomenon include i40e and ixgbe 2 NIC, it do not has these 2 bug before merge this patch. It is first find out by yuan.peng@intel.com, she can tell you how to reappear these abnormal phenomenon on RSS flow API. Thank you. > -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Adrien Mazarguil > Sent: Wednesday, April 25, 2018 11:28 PM > To: Thomas Monjalon <thomas@monjalon.net>; Yigit, Ferruh > <ferruh.yigit@intel.com>; dev@dpdk.org > Cc: Xueming Li <xuemingl@mellanox.com>; Lu, Wenzhuo > <wenzhuo.lu@intel.com>; Wu, Jingjing <jingjing.wu@intel.com>; Xing, Beilei > <beilei.xing@intel.com>; Zhang, Qi Z <qi.z.zhang@intel.com>; Ananyev, > Konstantin <konstantin.ananyev@intel.com>; Nelio Laranjeiro > <nelio.laranjeiro@6wind.com>; Yongseok Koh <yskoh@mellanox.com>; > Andrew Rybchenko <arybchenko@solarflare.com>; Pascal Mazon > <pascal.mazon@6wind.com>; Nicolau, Radu <radu.nicolau@intel.com>; Akhil > Goyal <akhil.goyal@nxp.com> > Subject: [dpdk-dev] [PATCH v6 07/16] ethdev: flatten RSS configuration in > flow API > > Since its inception, the rte_flow RSS action has been relying in part on > external struct rte_eth_rss_conf for compatibility with the legacy RSS API. > This structure lacks parameters such as the hash algorithm to use, and more > recently, a method to tell which layer RSS should be performed on [1]. > > Given struct rte_eth_rss_conf will never be flexible enough to represent a > complete RSS configuration (e.g. RETA table), this patch supersedes it by > extending the rte_flow RSS action directly. > > A subsequent patch will add a field to use a non-default RSS hash > algorithm. To that end, a field named "types" replaces the field formerly > known as "rss_hf" and standing for "RSS hash functions" as it was > confusing. Actual RSS hash function types are defined by enum > rte_eth_hash_function. > > This patch updates all PMDs and example applications accordingly. > > It breaks ABI compatibility for the following public functions: > > - rte_flow_copy() > - rte_flow_create() > - rte_flow_query() > - rte_flow_validate() > > [1] commit 676b605182a5 ("doc: announce ethdev API change for RSS > configuration") > > Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> > Acked-by: Andrew Rybchenko <arybchenko@solarflare.com> > Cc: Xueming Li <xuemingl@mellanox.com> > Cc: Ferruh Yigit <ferruh.yigit@intel.com> > Cc: Thomas Monjalon <thomas@monjalon.net> > Cc: Wenzhuo Lu <wenzhuo.lu@intel.com> > Cc: Jingjing Wu <jingjing.wu@intel.com> > Cc: Beilei Xing <beilei.xing@intel.com> > Cc: Qi Zhang <qi.z.zhang@intel.com> > Cc: Konstantin Ananyev <konstantin.ananyev@intel.com> > Cc: Nelio Laranjeiro <nelio.laranjeiro@6wind.com> > Cc: Yongseok Koh <yskoh@mellanox.com> > Cc: Andrew Rybchenko <arybchenko@solarflare.com> > Cc: Pascal Mazon <pascal.mazon@6wind.com> > Cc: Radu Nicolau <radu.nicolau@intel.com> > Cc: Akhil Goyal <akhil.goyal@nxp.com> > > --- > > v6 changes: > > - Fixed QUEUE action support in mlx5 according to Nelio's comment [1]. > This action relies on RSS to work and even though it targets a single Rx > queue, a non-NULL hash key is required. > - Updated API and ABI changes sections in release notes. > > [1] http://dpdk.org/ml/archives/dev/2018-April/098635.html > > v3 changes: > > Documentation update regarding the meaning of a 0 value for RSS types in > flow rules. > > It used to implicitly mean "no RSS" but is redefined as requesting a kind > of "best-effort" mode from PMDs, i.e. anything ranging from empty to > all-inclusive RSS; what matters is it provides safe defaults that will work > regardless of PMD capabilities. > --- > app/test-pmd/cmdline_flow.c | 48 +++--- > app/test-pmd/config.c | 39 ++--- > doc/guides/prog_guide/rte_flow.rst | 28 ++-- > doc/guides/rel_notes/release_18_05.rst | 13 +- > doc/guides/testpmd_app_ug/testpmd_funcs.rst | 6 +- > drivers/net/e1000/e1000_ethdev.h | 13 +- > drivers/net/e1000/igb_ethdev.c | 4 +- > drivers/net/e1000/igb_flow.c | 31 ++-- > drivers/net/e1000/igb_rxtx.c | 51 +++++- > drivers/net/i40e/i40e_ethdev.c | 53 +++++-- > drivers/net/i40e/i40e_ethdev.h | 15 +- > drivers/net/i40e/i40e_flow.c | 47 +++--- > drivers/net/ixgbe/ixgbe_ethdev.c | 4 +- > drivers/net/ixgbe/ixgbe_ethdev.h | 13 +- > drivers/net/ixgbe/ixgbe_flow.c | 30 ++-- > drivers/net/ixgbe/ixgbe_rxtx.c | 51 +++++- > drivers/net/mlx4/mlx4.c | 2 +- > drivers/net/mlx4/mlx4_flow.c | 61 +++---- > drivers/net/mlx4/mlx4_flow.h | 2 +- > drivers/net/mlx4/mlx4_rxq.c | 2 +- > drivers/net/mlx4/mlx4_rxtx.h | 2 +- > drivers/net/mlx5/mlx5_flow.c | 193 +++++++++++------------ > drivers/net/mlx5/mlx5_rxq.c | 26 +-- > drivers/net/mlx5/mlx5_rxtx.h | 26 +-- > drivers/net/sfc/sfc_flow.c | 21 ++- > drivers/net/tap/tap_flow.c | 8 +- > examples/ipsec-secgw/ipsec.c | 10 +- > lib/librte_ether/rte_flow.c | 39 ++--- > lib/librte_ether/rte_flow.h | 12 +- > 29 files changed, 492 insertions(+), 358 deletions(-) > > diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c > index 798b7948d..c9c2c3ad9 100644 > --- a/app/test-pmd/cmdline_flow.c > +++ b/app/test-pmd/cmdline_flow.c > @@ -192,9 +192,8 @@ enum index { > /** Storage for struct rte_flow_action_rss including external data. */ > struct action_rss_data { > struct rte_flow_action_rss conf; > + uint8_t key[RSS_HASH_KEY_LENGTH]; > uint16_t queue[ACTION_RSS_QUEUE_NUM]; > - struct rte_eth_rss_conf rss_conf; > - uint8_t rss_key[RSS_HASH_KEY_LENGTH]; > }; > > /** Maximum number of subsequent tokens and arguments on the stack. > */ > @@ -1587,7 +1586,7 @@ static const struct token token_list[] = { > }, > [ACTION_RSS_TYPES] = { > .name = "types", > - .help = "RSS hash types", > + .help = "specific RSS hash types", > .next = NEXT(action_rss, NEXT_ENTRY(ACTION_RSS_TYPE)), > }, > [ACTION_RSS_TYPE] = { > @@ -1602,21 +1601,21 @@ static const struct token token_list[] = { > .next = NEXT(action_rss, NEXT_ENTRY(STRING)), > .args = ARGS(ARGS_ENTRY_ARB(0, 0), > ARGS_ENTRY_ARB > - (offsetof(struct action_rss_data, rss_conf) + > - offsetof(struct rte_eth_rss_conf, rss_key_len), > - sizeof(((struct rte_eth_rss_conf *)0)-> > - rss_key_len)), > - ARGS_ENTRY(struct action_rss_data, rss_key)), > + (offsetof(struct action_rss_data, conf) + > + offsetof(struct rte_flow_action_rss, key_len), > + sizeof(((struct rte_flow_action_rss *)0)-> > + key_len)), > + ARGS_ENTRY(struct action_rss_data, key)), > }, > [ACTION_RSS_KEY_LEN] = { > .name = "key_len", > .help = "RSS hash key length in bytes", > .next = NEXT(action_rss, NEXT_ENTRY(UNSIGNED)), > .args = ARGS(ARGS_ENTRY_ARB_BOUNDED > - (offsetof(struct action_rss_data, rss_conf) + > - offsetof(struct rte_eth_rss_conf, rss_key_len), > - sizeof(((struct rte_eth_rss_conf *)0)-> > - rss_key_len), > + (offsetof(struct action_rss_data, conf) + > + offsetof(struct rte_flow_action_rss, key_len), > + sizeof(((struct rte_flow_action_rss *)0)-> > + key_len), > 0, > RSS_HASH_KEY_LENGTH)), > }, > @@ -2075,27 +2074,24 @@ parse_vc_action_rss(struct context *ctx, const > struct token *token, > action_rss_data = ctx->object; > *action_rss_data = (struct action_rss_data){ > .conf = (struct rte_flow_action_rss){ > - .rss_conf = &action_rss_data->rss_conf, > - .num = RTE_MIN(nb_rxq, > ACTION_RSS_QUEUE_NUM), > + .types = rss_hf, > + .key_len = sizeof(action_rss_data->key), > + .queue_num = RTE_MIN(nb_rxq, > ACTION_RSS_QUEUE_NUM), > + .key = action_rss_data->key, > .queue = action_rss_data->queue, > }, > + .key = "testpmd's default RSS hash key", > .queue = { 0 }, > - .rss_conf = (struct rte_eth_rss_conf){ > - .rss_key = action_rss_data->rss_key, > - .rss_key_len = sizeof(action_rss_data->rss_key), > - .rss_hf = rss_hf, > - }, > - .rss_key = "testpmd's default RSS hash key", > }; > - for (i = 0; i < action_rss_data->conf.num; ++i) > + for (i = 0; i < action_rss_data->conf.queue_num; ++i) > action_rss_data->queue[i] = i; > if (!port_id_is_invalid(ctx->port, DISABLED_WARN) && > ctx->port != (portid_t)RTE_PORT_ALL) { > struct rte_eth_dev_info info; > > rte_eth_dev_info_get(ctx->port, &info); > - action_rss_data->rss_conf.rss_key_len = > - RTE_MIN(sizeof(action_rss_data->rss_key), > + action_rss_data->conf.key_len = > + RTE_MIN(sizeof(action_rss_data->key), > info.hash_key_size); > } > action->conf = &action_rss_data->conf; > @@ -2123,7 +2119,7 @@ parse_vc_action_rss_type(struct context *ctx, > const struct token *token, > return -1; > if (!(ctx->objdata >> 16) && ctx->object) { > action_rss_data = ctx->object; > - action_rss_data->rss_conf.rss_hf = 0; > + action_rss_data->conf.types = 0; > } > if (!strcmp_partial("end", str, len)) { > ctx->objdata &= 0xffff; > @@ -2142,7 +2138,7 @@ parse_vc_action_rss_type(struct context *ctx, > const struct token *token, > if (!ctx->object) > return len; > action_rss_data = ctx->object; > - action_rss_data->rss_conf.rss_hf |= rss_type_table[i].rss_type; > + action_rss_data->conf.types |= rss_type_table[i].rss_type; > return len; > } > > @@ -2192,7 +2188,7 @@ parse_vc_action_rss_queue(struct context *ctx, > const struct token *token, > if (!ctx->object) > return len; > action_rss_data = ctx->object; > - action_rss_data->conf.num = i; > + action_rss_data->conf.queue_num = i; > action_rss_data->conf.queue = i ? action_rss_data->queue : NULL; > return len; > } > diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c > index eb7ac315e..4700dd674 100644 > --- a/app/test-pmd/config.c > +++ b/app/test-pmd/config.c > @@ -1117,40 +1117,27 @@ flow_action_conf_copy(void *buf, const struct > rte_flow_action *action) > off = 0; > if (dst.rss) > *dst.rss = (struct rte_flow_action_rss){ > - .num = src.rss->num, > + .types = src.rss->types, > + .key_len = src.rss->key_len, > + .queue_num = src.rss->queue_num, > }; > off += sizeof(*src.rss); > - if (src.rss->num) { > + if (src.rss->key_len) { > off = RTE_ALIGN_CEIL(off, sizeof(double)); > - size = sizeof(*src.rss->queue) * src.rss->num; > + size = sizeof(*src.rss->key) * src.rss->key_len; > if (dst.rss) > - dst.rss->queue = memcpy > + dst.rss->key = memcpy > ((void *)((uintptr_t)dst.rss + off), > - src.rss->queue, size); > + src.rss->key, size); > off += size; > } > - off = RTE_ALIGN_CEIL(off, sizeof(double)); > - if (dst.rss) { > - dst.rss->rss_conf = (void *)((uintptr_t)dst.rss + off); > - *(struct rte_eth_rss_conf *)(uintptr_t) > - dst.rss->rss_conf = (struct > rte_eth_rss_conf){ > - .rss_key_len = src.rss->rss_conf- > >rss_key_len, > - .rss_hf = src.rss->rss_conf->rss_hf, > - }; > - } > - off += sizeof(*src.rss->rss_conf); > - if (src.rss->rss_conf->rss_key_len) { > + if (src.rss->queue_num) { > off = RTE_ALIGN_CEIL(off, sizeof(double)); > - size = sizeof(*src.rss->rss_conf->rss_key) * > - src.rss->rss_conf->rss_key_len; > - if (dst.rss) { > - ((struct rte_eth_rss_conf *)(uintptr_t) > - dst.rss->rss_conf)->rss_key = > - (void *)((uintptr_t)dst.rss + off); > - memcpy(dst.rss->rss_conf->rss_key, > - src.rss->rss_conf->rss_key, > - size); > - } > + size = sizeof(*src.rss->queue) * src.rss->queue_num; > + if (dst.rss) > + dst.rss->queue = memcpy > + ((void *)((uintptr_t)dst.rss + off), > + src.rss->queue, size); > off += size; > } > size = off; > diff --git a/doc/guides/prog_guide/rte_flow.rst > b/doc/guides/prog_guide/rte_flow.rst > index acbeaacbd..cf252eeba 100644 > --- a/doc/guides/prog_guide/rte_flow.rst > +++ b/doc/guides/prog_guide/rte_flow.rst > @@ -1301,6 +1301,12 @@ Action: ``RSS`` > Similar to QUEUE, except RSS is additionally performed on packets to spread > them among several queues according to the provided parameters. > > +Unlike global RSS settings used by other DPDK APIs, unsetting the ``types`` > +field does not disable RSS in a flow rule. Doing so instead requests safe > +unspecified "best-effort" settings from the underlying PMD, which > depending > +on the flow rule, may result in anything ranging from empty (single queue) > +to all-inclusive RSS. > + > Note: RSS hash result is stored in the ``hash.rss`` mbuf field which > overlaps ``hash.fdir.lo``. Since `Action: MARK`_ sets the ``hash.fdir.hi`` > field only, both can be requested simultaneously. > @@ -1309,15 +1315,19 @@ field only, both can be requested simultaneously. > > .. table:: RSS > > - +--------------+--------------------------------+ > - | Field | Value | > - +==============+================================+ > - | ``rss_conf`` | RSS parameters | > - +--------------+--------------------------------+ > - | ``num`` | number of entries in ``queue`` | > - +--------------+--------------------------------+ > - | ``queue`` | queue indices to use | > - +--------------+--------------------------------+ > + +---------------+---------------------------------------------+ > + | Field | Value | > + > +===============+========================================= > ====+ > + | ``types`` | specific RSS hash types (see ``ETH_RSS_*``) | > + +---------------+---------------------------------------------+ > + | ``key_len`` | hash key length in bytes | > + +---------------+---------------------------------------------+ > + | ``queue_num`` | number of entries in ``queue`` | > + +---------------+---------------------------------------------+ > + | ``key`` | hash key | > + +---------------+---------------------------------------------+ > + | ``queue`` | queue indices to use | > + +---------------+---------------------------------------------+ > > Action: ``PF`` > ^^^^^^^^^^^^^^ > diff --git a/doc/guides/rel_notes/release_18_05.rst > b/doc/guides/rel_notes/release_18_05.rst > index ca173450c..b702ac66a 100644 > --- a/doc/guides/rel_notes/release_18_05.rst > +++ b/doc/guides/rel_notes/release_18_05.rst > @@ -254,6 +254,13 @@ API Changes > present. > * C99-style flexible arrays were replaced with standard pointers in RSS > action and in RAW pattern item structures due to compatibility issues. > + * The RSS action was modified to not rely on external > + ``struct rte_eth_rss_conf`` anymore to instead expose its own and more > + appropriately named configuration fields directly > + (``rss_conf->rss_key`` => ``key``, > + ``rss_conf->rss_key_len`` => ``key_len``, > + ``rss_conf->rss_hf`` => ``types``, > + ``num`` => ``queue_num``). > > > ABI Changes > @@ -302,9 +309,9 @@ ABI Changes > ``rte_flow_isolate``, ``rte_flow_query`` and ``rte_flow_validate``, due to > changes in error type definitions (``enum rte_flow_error_type``), removal > of the unused DUP action (``enum rte_flow_action_type``), modified > - behavior for flow rule actions (see API changes) and removal of C99 > - flexible arrays from RSS action (``struct rte_flow_action_rss``) and RAW > - pattern item (``struct rte_flow_item_raw``). > + behavior for flow rule actions (see API changes), removal of C99 flexible > + array from RAW pattern item (``struct rte_flow_item_raw``) and complete > + rework of the RSS action definition (``struct rte_flow_action_rss``). > > > Removed Items > diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst > b/doc/guides/testpmd_app_ug/testpmd_funcs.rst > index 68c286bd4..a12e0267a 100644 > --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst > +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst > @@ -3422,8 +3422,10 @@ This section lists supported actions and their > attributes, if any. > > - ``rss``: spread packets among several queues. > > - - ``types [{RSS hash type} [...]] end``: RSS hash types, allowed tokens > - are the same as `set_hash_input_set`_, an empty list means none (0). > + - ``types [{RSS hash type} [...]] end``: specific RSS hash types, allowed > + tokens are the same as `set_hash_input_set`_, except that an empty list > + does not disable RSS but instead requests unspecified "best-effort" > + settings. > > - ``key {string}``: RSS hash key, overrides ``key_len``. > > diff --git a/drivers/net/e1000/e1000_ethdev.h > b/drivers/net/e1000/e1000_ethdev.h > index 6354b894a..902001f36 100644 > --- a/drivers/net/e1000/e1000_ethdev.h > +++ b/drivers/net/e1000/e1000_ethdev.h > @@ -4,6 +4,10 @@ > > #ifndef _E1000_ETHDEV_H_ > #define _E1000_ETHDEV_H_ > + > +#include <stdint.h> > + > +#include <rte_flow.h> > #include <rte_time.h> > #include <rte_pci.h> > > @@ -27,6 +31,7 @@ > #define E1000_CTRL_EXT_EXTEND_VLAN (1<<26) /* EXTENDED VLAN */ > #define IGB_VFTA_SIZE 128 > > +#define IGB_HKEY_MAX_INDEX 10 > #define IGB_MAX_RX_QUEUE_NUM 8 > #define IGB_MAX_RX_QUEUE_NUM_82576 16 > > @@ -229,8 +234,8 @@ struct igb_ethertype_filter { > }; > > struct igb_rte_flow_rss_conf { > - struct rte_eth_rss_conf rss_conf; /**< RSS parameters. */ > - uint16_t num; /**< Number of entries in queue[]. */ > + struct rte_flow_action_rss conf; /**< RSS parameters. */ > + uint8_t key[IGB_HKEY_MAX_INDEX * sizeof(uint32_t)]; /* Hash key. > */ > uint16_t queue[IGB_MAX_RX_QUEUE_NUM]; /**< Queues indices > to use. */ > }; > > @@ -501,6 +506,10 @@ int eth_igb_syn_filter_set(struct rte_eth_dev *dev, > int eth_igb_add_del_flex_filter(struct rte_eth_dev *dev, > struct rte_eth_flex_filter *filter, > bool add); > +int igb_rss_conf_init(struct igb_rte_flow_rss_conf *out, > + const struct rte_flow_action_rss *in); > +int igb_action_rss_same(const struct rte_flow_action_rss *comp, > + const struct rte_flow_action_rss *with); > int igb_config_rss_filter(struct rte_eth_dev *dev, > struct igb_rte_flow_rss_conf *conf, > bool add); > diff --git a/drivers/net/e1000/igb_ethdev.c > b/drivers/net/e1000/igb_ethdev.c > index c35c9352a..140334772 100644 > --- a/drivers/net/e1000/igb_ethdev.c > +++ b/drivers/net/e1000/igb_ethdev.c > @@ -41,8 +41,6 @@ > #define IGB_DEFAULT_TX_HTHRESH 1 > #define IGB_DEFAULT_TX_WTHRESH ((hw->mac.type == e1000_82576) ? > 1 : 16) > > -#define IGB_HKEY_MAX_INDEX 10 > - > /* Bit shift and mask */ > #define IGB_4_BIT_WIDTH (CHAR_BIT / 2) > #define IGB_4_BIT_MASK RTE_LEN2MASK(IGB_4_BIT_WIDTH, uint8_t) > @@ -5662,7 +5660,7 @@ igb_rss_filter_restore(struct rte_eth_dev *dev) > struct e1000_filter_info *filter_info = > E1000_DEV_PRIVATE_TO_FILTER_INFO(dev->data- > >dev_private); > > - if (filter_info->rss_info.num) > + if (filter_info->rss_info.conf.queue_num) > igb_config_rss_filter(dev, &filter_info->rss_info, TRUE); > } > > diff --git a/drivers/net/e1000/igb_flow.c b/drivers/net/e1000/igb_flow.c > index c0f5b5190..8dc5f75f2 100644 > --- a/drivers/net/e1000/igb_flow.c > +++ b/drivers/net/e1000/igb_flow.c > @@ -1292,7 +1292,7 @@ igb_parse_rss_filter(struct rte_eth_dev *dev, > > rss = (const struct rte_flow_action_rss *)act->conf; > > - if (!rss || !rss->num) { > + if (!rss || !rss->queue_num) { > rte_flow_error_set(error, EINVAL, > RTE_FLOW_ERROR_TYPE_ACTION, > act, > @@ -1300,7 +1300,7 @@ igb_parse_rss_filter(struct rte_eth_dev *dev, > return -rte_errno; > } > > - for (n = 0; n < rss->num; n++) { > + for (n = 0; n < rss->queue_num; n++) { > if (rss->queue[n] >= dev->data->nb_rx_queues) { > rte_flow_error_set(error, EINVAL, > RTE_FLOW_ERROR_TYPE_ACTION, > @@ -1310,14 +1310,18 @@ igb_parse_rss_filter(struct rte_eth_dev *dev, > } > } > > - if (rss->rss_conf) > - rss_conf->rss_conf = *rss->rss_conf; > - else > - rss_conf->rss_conf.rss_hf = IGB_RSS_OFFLOAD_ALL; > - > - for (n = 0; n < rss->num; ++n) > - rss_conf->queue[n] = rss->queue[n]; > - rss_conf->num = rss->num; > + if (rss->key_len && rss->key_len != RTE_DIM(rss_conf->key)) > + return rte_flow_error_set > + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, > act, > + "RSS hash key must be exactly 40 bytes"); > + if (rss->queue_num > RTE_DIM(rss_conf->queue)) > + return rte_flow_error_set > + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, > act, > + "too many queues for RSS context"); > + if (igb_rss_conf_init(rss_conf, rss)) > + return rte_flow_error_set > + (error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, > act, > + "RSS context initialization failure"); > > /* check if the next not void item is END */ > index++; > @@ -1518,9 +1522,8 @@ igb_flow_create(struct rte_eth_dev *dev, > PMD_DRV_LOG(ERR, "failed to allocate > memory"); > goto out; > } > - rte_memcpy(&rss_filter_ptr->filter_info, > - &rss_conf, > - sizeof(struct igb_rte_flow_rss_conf)); > + igb_rss_conf_init(&rss_filter_ptr->filter_info, > + &rss_conf.conf); > TAILQ_INSERT_TAIL(&igb_filter_rss_list, > rss_filter_ptr, entries); > flow->rule = rss_filter_ptr; > @@ -1757,7 +1760,7 @@ igb_clear_rss_filter(struct rte_eth_dev *dev) > struct e1000_filter_info *filter = > E1000_DEV_PRIVATE_TO_FILTER_INFO(dev->data- > >dev_private); > > - if (filter->rss_info.num) > + if (filter->rss_info.conf.queue_num) > igb_config_rss_filter(dev, &filter->rss_info, FALSE); > } > > diff --git a/drivers/net/e1000/igb_rxtx.c b/drivers/net/e1000/igb_rxtx.c > index 323913f0d..45bb3455c 100644 > --- a/drivers/net/e1000/igb_rxtx.c > +++ b/drivers/net/e1000/igb_rxtx.c > @@ -2898,12 +2898,47 @@ igb_txq_info_get(struct rte_eth_dev *dev, > uint16_t queue_id, > } > > int > +igb_rss_conf_init(struct igb_rte_flow_rss_conf *out, > + const struct rte_flow_action_rss *in) > +{ > + if (in->key_len > RTE_DIM(out->key) || > + in->queue_num > RTE_DIM(out->queue)) > + return -EINVAL; > + out->conf = (struct rte_flow_action_rss){ > + .types = in->types, > + .key_len = in->key_len, > + .queue_num = in->queue_num, > + .key = memcpy(out->key, in->key, in->key_len), > + .queue = memcpy(out->queue, in->queue, > + sizeof(*in->queue) * in->queue_num), > + }; > + return 0; > +} > + > +int > +igb_action_rss_same(const struct rte_flow_action_rss *comp, > + const struct rte_flow_action_rss *with) > +{ > + return (comp->types == with->types && > + comp->key_len == with->key_len && > + comp->queue_num == with->queue_num && > + !memcmp(comp->key, with->key, with->key_len) && > + !memcmp(comp->queue, with->queue, > + sizeof(*with->queue) * with->queue_num)); > +} > + > +int > igb_config_rss_filter(struct rte_eth_dev *dev, > struct igb_rte_flow_rss_conf *conf, bool add) > { > uint32_t shift; > uint16_t i, j; > - struct rte_eth_rss_conf rss_conf = conf->rss_conf; > + struct rte_eth_rss_conf rss_conf = { > + .rss_key = conf->conf.key_len ? > + (void *)(uintptr_t)conf->conf.key : NULL, > + .rss_key_len = conf->conf.key_len, > + .rss_hf = conf->conf.types, > + }; > struct e1000_filter_info *filter_info = > E1000_DEV_PRIVATE_TO_FILTER_INFO(dev->data- > >dev_private); > struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data- > >dev_private); > @@ -2911,8 +2946,8 @@ igb_config_rss_filter(struct rte_eth_dev *dev, > hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private); > > if (!add) { > - if (memcmp(conf, &filter_info->rss_info, > - sizeof(struct igb_rte_flow_rss_conf)) == 0) { > + if (igb_action_rss_same(&filter_info->rss_info.conf, > + &conf->conf)) { > igb_rss_disable(dev); > memset(&filter_info->rss_info, 0, > sizeof(struct igb_rte_flow_rss_conf)); > @@ -2921,7 +2956,7 @@ igb_config_rss_filter(struct rte_eth_dev *dev, > return -EINVAL; > } > > - if (filter_info->rss_info.num) > + if (filter_info->rss_info.conf.queue_num) > return -EINVAL; > > /* Fill in redirection table. */ > @@ -2933,9 +2968,9 @@ igb_config_rss_filter(struct rte_eth_dev *dev, > } reta; > uint8_t q_idx; > > - if (j == conf->num) > + if (j == conf->conf.queue_num) > j = 0; > - q_idx = conf->queue[j]; > + q_idx = conf->conf.queue[j]; > reta.bytes[i & 3] = (uint8_t)(q_idx << shift); > if ((i & 3) == 3) > E1000_WRITE_REG(hw, E1000_RETA(i >> 2), > reta.dword); > @@ -2952,8 +2987,8 @@ igb_config_rss_filter(struct rte_eth_dev *dev, > rss_conf.rss_key = rss_intel_key; /* Default hash key */ > igb_hw_rss_hash_set(hw, &rss_conf); > > - rte_memcpy(&filter_info->rss_info, > - conf, sizeof(struct igb_rte_flow_rss_conf)); > + if (igb_rss_conf_init(&filter_info->rss_info, &conf->conf)) > + return -EINVAL; > > return 0; > } > diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c > index 78f2be7da..50e77901c 100644 > --- a/drivers/net/i40e/i40e_ethdev.c > +++ b/drivers/net/i40e/i40e_ethdev.c > @@ -11,6 +11,7 @@ > #include <inttypes.h> > #include <assert.h> > > +#include <rte_common.h> > #include <rte_eal.h> > #include <rte_string_fns.h> > #include <rte_pci.h> > @@ -11650,7 +11651,7 @@ i40e_rss_filter_restore(struct i40e_pf *pf) > { > struct i40e_rte_flow_rss_conf *conf = > &pf->rss_info; > - if (conf->num) > + if (conf->conf.queue_num) > i40e_config_rss_filter(pf, conf, TRUE); > } > > @@ -12182,18 +12183,52 @@ i40e_cloud_filter_qinq_create(struct i40e_pf > *pf) > } > > int > +i40e_rss_conf_init(struct i40e_rte_flow_rss_conf *out, > + const struct rte_flow_action_rss *in) > +{ > + if (in->key_len > RTE_DIM(out->key) || > + in->queue_num > RTE_DIM(out->queue)) > + return -EINVAL; > + out->conf = (struct rte_flow_action_rss){ > + .types = in->types, > + .key_len = in->key_len, > + .queue_num = in->queue_num, > + .key = memcpy(out->key, in->key, in->key_len), > + .queue = memcpy(out->queue, in->queue, > + sizeof(*in->queue) * in->queue_num), > + }; > + return 0; > +} > + > +int > +i40e_action_rss_same(const struct rte_flow_action_rss *comp, > + const struct rte_flow_action_rss *with) > +{ > + return (comp->types == with->types && > + comp->key_len == with->key_len && > + comp->queue_num == with->queue_num && > + !memcmp(comp->key, with->key, with->key_len) && > + !memcmp(comp->queue, with->queue, > + sizeof(*with->queue) * with->queue_num)); > +} > + > +int > i40e_config_rss_filter(struct i40e_pf *pf, > struct i40e_rte_flow_rss_conf *conf, bool add) > { > struct i40e_hw *hw = I40E_PF_TO_HW(pf); > uint32_t i, lut = 0; > uint16_t j, num; > - struct rte_eth_rss_conf rss_conf = conf->rss_conf; > + struct rte_eth_rss_conf rss_conf = { > + .rss_key = conf->conf.key_len ? > + (void *)(uintptr_t)conf->conf.key : NULL, > + .rss_key_len = conf->conf.key_len, > + .rss_hf = conf->conf.types, > + }; > struct i40e_rte_flow_rss_conf *rss_info = &pf->rss_info; > > if (!add) { > - if (memcmp(conf, rss_info, > - sizeof(struct i40e_rte_flow_rss_conf)) == 0) { > + if (i40e_action_rss_same(&rss_info->conf, &conf->conf)) { > i40e_pf_disable_rss(pf); > memset(rss_info, 0, > sizeof(struct i40e_rte_flow_rss_conf)); > @@ -12202,7 +12237,7 @@ i40e_config_rss_filter(struct i40e_pf *pf, > return -EINVAL; > } > > - if (rss_info->num) > + if (rss_info->conf.queue_num) > return -EINVAL; > > /* If both VMDQ and RSS enabled, not all of PF queues are > configured. > @@ -12213,7 +12248,7 @@ i40e_config_rss_filter(struct i40e_pf *pf, > else > num = pf->dev_data->nb_rx_queues; > > - num = RTE_MIN(num, conf->num); > + num = RTE_MIN(num, conf->conf.queue_num); > PMD_DRV_LOG(INFO, "Max of contiguous %u PF queues are > configured", > num); > > @@ -12226,7 +12261,7 @@ i40e_config_rss_filter(struct i40e_pf *pf, > for (i = 0, j = 0; i < hw->func_caps.rss_table_size; i++, j++) { > if (j == num) > j = 0; > - lut = (lut << 8) | (conf->queue[j] & ((0x1 << > + lut = (lut << 8) | (conf->conf.queue[j] & ((0x1 << > hw->func_caps.rss_table_entry_width) - 1)); > if ((i & 3) == 3) > I40E_WRITE_REG(hw, I40E_PFQF_HLUT(i >> 2), lut); > @@ -12251,8 +12286,8 @@ i40e_config_rss_filter(struct i40e_pf *pf, > > i40e_hw_rss_hash_set(pf, &rss_conf); > > - rte_memcpy(rss_info, > - conf, sizeof(struct i40e_rte_flow_rss_conf)); > + if (i40e_rss_conf_init(rss_info, &conf->conf)) > + return -EINVAL; > > return 0; > } > diff --git a/drivers/net/i40e/i40e_ethdev.h > b/drivers/net/i40e/i40e_ethdev.h > index d33b255e7..a0569d4ae 100644 > --- a/drivers/net/i40e/i40e_ethdev.h > +++ b/drivers/net/i40e/i40e_ethdev.h > @@ -5,14 +5,19 @@ > #ifndef _I40E_ETHDEV_H_ > #define _I40E_ETHDEV_H_ > > +#include <stdint.h> > + > #include <rte_eth_ctrl.h> > #include <rte_time.h> > #include <rte_kvargs.h> > #include <rte_hash.h> > +#include <rte_flow.h> > #include <rte_flow_driver.h> > #include <rte_tm_driver.h> > #include "rte_pmd_i40e.h" > > +#include "base/i40e_register.h" > + > #define I40E_VLAN_TAG_SIZE 4 > > #define I40E_AQ_LEN 32 > @@ -878,9 +883,11 @@ struct i40e_customized_pctype { > }; > > struct i40e_rte_flow_rss_conf { > - struct rte_eth_rss_conf rss_conf; /**< RSS parameters. */ > + struct rte_flow_action_rss conf; /**< RSS parameters. */ > uint16_t queue_region_conf; /**< Queue region config flag */ > - uint16_t num; /**< Number of entries in queue[]. */ > + uint8_t key[(I40E_VFQF_HKEY_MAX_INDEX > > I40E_PFQF_HKEY_MAX_INDEX ? > + I40E_VFQF_HKEY_MAX_INDEX : > I40E_PFQF_HKEY_MAX_INDEX) + 1 * > + sizeof(uint32_t)]; /* Hash key. */ > uint16_t queue[I40E_MAX_Q_PER_TC]; /**< Queues indices to use. > */ > }; > > @@ -1219,6 +1226,10 @@ void i40e_init_queue_region_conf(struct > rte_eth_dev *dev); > void i40e_flex_payload_reg_set_default(struct i40e_hw *hw); > int i40e_set_rss_key(struct i40e_vsi *vsi, uint8_t *key, uint8_t key_len); > int i40e_set_rss_lut(struct i40e_vsi *vsi, uint8_t *lut, uint16_t lut_size); > +int i40e_rss_conf_init(struct i40e_rte_flow_rss_conf *out, > + const struct rte_flow_action_rss *in); > +int i40e_action_rss_same(const struct rte_flow_action_rss *comp, > + const struct rte_flow_action_rss *with); > int i40e_config_rss_filter(struct i40e_pf *pf, > struct i40e_rte_flow_rss_conf *conf, bool add); > > diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c > index d6f5e9923..ec6231003 100644 > --- a/drivers/net/i40e/i40e_flow.c > +++ b/drivers/net/i40e/i40e_flow.c > @@ -4220,7 +4220,7 @@ i40e_flow_parse_rss_action(struct rte_eth_dev > *dev, > > if (action_flag) { > for (n = 0; n < 64; n++) { > - if (rss->rss_conf->rss_hf & (hf_bit << n)) { > + if (rss->types & (hf_bit << n)) { > conf_info->region[0].hw_flowtype[0] = n; > conf_info->region[0].flowtype_num = 1; > conf_info->queue_region_number = 1; > @@ -4236,12 +4236,12 @@ i40e_flow_parse_rss_action(struct rte_eth_dev > *dev, > * queue index for this port. > */ > if (conf_info->queue_region_number) { > - for (i = 0; i < rss->num; i++) { > - for (j = 0; j < rss_info->num; j++) { > - if (rss->queue[i] == rss_info->queue[j]) > + for (i = 0; i < rss->queue_num; i++) { > + for (j = 0; j < rss_info->conf.queue_num; j++) { > + if (rss->queue[i] == rss_info->conf.queue[j]) > break; > } > - if (j == rss_info->num) { > + if (j == rss_info->conf.queue_num) { > rte_flow_error_set(error, EINVAL, > RTE_FLOW_ERROR_TYPE_ACTION, > act, > @@ -4250,7 +4250,7 @@ i40e_flow_parse_rss_action(struct rte_eth_dev > *dev, > } > } > > - for (i = 0; i < rss->num - 1; i++) { > + for (i = 0; i < rss->queue_num - 1; i++) { > if (rss->queue[i + 1] != rss->queue[i] + 1) { > rte_flow_error_set(error, EINVAL, > RTE_FLOW_ERROR_TYPE_ACTION, > @@ -4265,8 +4265,8 @@ i40e_flow_parse_rss_action(struct rte_eth_dev > *dev, > for (n = 0; n < conf_info->queue_region_number; n++) { > if (conf_info->region[n].user_priority_num || > conf_info->region[n].flowtype_num) { > - if (!((rte_is_power_of_2(rss->num)) && > - rss->num <= 64)) { > + if (!((rte_is_power_of_2(rss->queue_num)) && > + rss->queue_num <= 64)) { > rte_flow_error_set(error, EINVAL, > RTE_FLOW_ERROR_TYPE_ACTION, > act, > @@ -4294,7 +4294,8 @@ i40e_flow_parse_rss_action(struct rte_eth_dev > *dev, > } > > for (i = 0; i < info->queue_region_number; i++) { > - if (info->region[i].queue_num == rss->num > && > + if (info->region[i].queue_num == > + rss->queue_num && > info->region[i].queue_start_index == > rss->queue[0]) > break; > @@ -4310,7 +4311,7 @@ i40e_flow_parse_rss_action(struct rte_eth_dev > *dev, > } > > info->region[i].queue_num = > - rss->num; > + rss->queue_num; > info->region[i].queue_start_index = > rss->queue[0]; > info->region[i].region_id = > @@ -4356,7 +4357,7 @@ i40e_flow_parse_rss_action(struct rte_eth_dev > *dev, > if (rss_config->queue_region_conf) > return 0; > > - if (!rss || !rss->num) { > + if (!rss || !rss->queue_num) { > rte_flow_error_set(error, EINVAL, > RTE_FLOW_ERROR_TYPE_ACTION, > act, > @@ -4364,7 +4365,7 @@ i40e_flow_parse_rss_action(struct rte_eth_dev > *dev, > return -rte_errno; > } > > - for (n = 0; n < rss->num; n++) { > + for (n = 0; n < rss->queue_num; n++) { > if (rss->queue[n] >= dev->data->nb_rx_queues) { > rte_flow_error_set(error, EINVAL, > RTE_FLOW_ERROR_TYPE_ACTION, > @@ -4375,15 +4376,19 @@ i40e_flow_parse_rss_action(struct rte_eth_dev > *dev, > } > > /* Parse RSS related parameters from configuration */ > - if (rss->rss_conf) > - rss_config->rss_conf = *rss->rss_conf; > - else > - rss_config->rss_conf.rss_hf = > - pf->adapter->flow_types_mask; > + if (rss->key_len && rss->key_len > RTE_DIM(rss_config->key)) > + return rte_flow_error_set > + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, > act, > + "RSS hash key too large"); > + if (rss->queue_num > RTE_DIM(rss_config->queue)) > + return rte_flow_error_set > + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, > act, > + "too many queues for RSS context"); > + if (i40e_rss_conf_init(rss_config, rss)) > + return rte_flow_error_set > + (error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, > act, > + "RSS context initialization failure"); > > - for (n = 0; n < rss->num; ++n) > - rss_config->queue[n] = rss->queue[n]; > - rss_config->num = rss->num; > index++; > > /* check if the next not void action is END */ > @@ -4903,7 +4908,7 @@ i40e_flow_flush_rss_filter(struct rte_eth_dev *dev) > > ret = i40e_flush_queue_region_all_conf(dev, hw, pf, 0); > > - if (rss_info->num) > + if (rss_info->conf.queue_num) > ret = i40e_config_rss_filter(pf, rss_info, FALSE); > return ret; > } > diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c > b/drivers/net/ixgbe/ixgbe_ethdev.c > index 92434809c..c00bdae3d 100644 > --- a/drivers/net/ixgbe/ixgbe_ethdev.c > +++ b/drivers/net/ixgbe/ixgbe_ethdev.c > @@ -100,8 +100,6 @@ > > #define IXGBE_QUEUE_STAT_COUNTERS (sizeof(hw_stats->qprc) / > sizeof(hw_stats->qprc[0])) > > -#define IXGBE_HKEY_MAX_INDEX 10 > - > /* Additional timesync values. */ > #define NSEC_PER_SEC 1000000000L > #define IXGBE_INCVAL_10GB 0x66666666 > @@ -8371,7 +8369,7 @@ ixgbe_rss_filter_restore(struct rte_eth_dev *dev) > struct ixgbe_filter_info *filter_info = > IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data- > >dev_private); > > - if (filter_info->rss_info.num) > + if (filter_info->rss_info.conf.queue_num) > ixgbe_config_rss_filter(dev, > &filter_info->rss_info, TRUE); > } > diff --git a/drivers/net/ixgbe/ixgbe_ethdev.h > b/drivers/net/ixgbe/ixgbe_ethdev.h > index 655077700..9491b03f4 100644 > --- a/drivers/net/ixgbe/ixgbe_ethdev.h > +++ b/drivers/net/ixgbe/ixgbe_ethdev.h > @@ -4,6 +4,9 @@ > > #ifndef _IXGBE_ETHDEV_H_ > #define _IXGBE_ETHDEV_H_ > + > +#include <stdint.h> > + > #include "base/ixgbe_type.h" > #include "base/ixgbe_dcb.h" > #include "base/ixgbe_dcb_82599.h" > @@ -12,6 +15,7 @@ > #ifdef RTE_LIBRTE_SECURITY > #include "ixgbe_ipsec.h" > #endif > +#include <rte_flow.h> > #include <rte_time.h> > #include <rte_hash.h> > #include <rte_pci.h> > @@ -39,6 +43,7 @@ > #define IXGBE_EXTENDED_VLAN (uint32_t)(1 << 26) /* EXTENDED > VLAN ENABLE */ > #define IXGBE_VFTA_SIZE 128 > #define IXGBE_VLAN_TAG_SIZE 4 > +#define IXGBE_HKEY_MAX_INDEX 10 > #define IXGBE_MAX_RX_QUEUE_NUM 128 > #define IXGBE_MAX_INTR_QUEUE_NUM 15 > #define IXGBE_VMDQ_DCB_NB_QUEUES IXGBE_MAX_RX_QUEUE_NUM > @@ -196,8 +201,8 @@ struct ixgbe_hw_fdir_info { > }; > > struct ixgbe_rte_flow_rss_conf { > - struct rte_eth_rss_conf rss_conf; /**< RSS parameters. */ > - uint16_t num; /**< Number of entries in queue[]. */ > + struct rte_flow_action_rss conf; /**< RSS parameters. */ > + uint8_t key[IXGBE_HKEY_MAX_INDEX * sizeof(uint32_t)]; /* Hash > key. */ > uint16_t queue[IXGBE_MAX_RX_QUEUE_NUM]; /**< Queues > indices to use. */ > }; > > @@ -696,6 +701,10 @@ void ixgbe_tm_conf_init(struct rte_eth_dev *dev); > void ixgbe_tm_conf_uninit(struct rte_eth_dev *dev); > int ixgbe_set_queue_rate_limit(struct rte_eth_dev *dev, uint16_t > queue_idx, > uint16_t tx_rate); > +int ixgbe_rss_conf_init(struct ixgbe_rte_flow_rss_conf *out, > + const struct rte_flow_action_rss *in); > +int ixgbe_action_rss_same(const struct rte_flow_action_rss *comp, > + const struct rte_flow_action_rss *with); > int ixgbe_config_rss_filter(struct rte_eth_dev *dev, > struct ixgbe_rte_flow_rss_conf *conf, bool add); > > diff --git a/drivers/net/ixgbe/ixgbe_flow.c b/drivers/net/ixgbe/ixgbe_flow.c > index abdeac28b..4e31c7c56 100644 > --- a/drivers/net/ixgbe/ixgbe_flow.c > +++ b/drivers/net/ixgbe/ixgbe_flow.c > @@ -2761,7 +2761,7 @@ ixgbe_parse_rss_filter(struct rte_eth_dev *dev, > > rss = (const struct rte_flow_action_rss *)act->conf; > > - if (!rss || !rss->num) { > + if (!rss || !rss->queue_num) { > rte_flow_error_set(error, EINVAL, > RTE_FLOW_ERROR_TYPE_ACTION, > act, > @@ -2769,7 +2769,7 @@ ixgbe_parse_rss_filter(struct rte_eth_dev *dev, > return -rte_errno; > } > > - for (n = 0; n < rss->num; n++) { > + for (n = 0; n < rss->queue_num; n++) { > if (rss->queue[n] >= dev->data->nb_rx_queues) { > rte_flow_error_set(error, EINVAL, > RTE_FLOW_ERROR_TYPE_ACTION, > @@ -2778,14 +2778,19 @@ ixgbe_parse_rss_filter(struct rte_eth_dev *dev, > return -rte_errno; > } > } > - if (rss->rss_conf) > - rss_conf->rss_conf = *rss->rss_conf; > - else > - rss_conf->rss_conf.rss_hf = IXGBE_RSS_OFFLOAD_ALL; > > - for (n = 0; n < rss->num; ++n) > - rss_conf->queue[n] = rss->queue[n]; > - rss_conf->num = rss->num; > + if (rss->key_len && rss->key_len != RTE_DIM(rss_conf->key)) > + return rte_flow_error_set > + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, > act, > + "RSS hash key must be exactly 40 bytes"); > + if (rss->queue_num > RTE_DIM(rss_conf->queue)) > + return rte_flow_error_set > + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, > act, > + "too many queues for RSS context"); > + if (ixgbe_rss_conf_init(rss_conf, rss)) > + return rte_flow_error_set > + (error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, > act, > + "RSS context initialization failure"); > > /* check if the next not void item is END */ > act = next_no_void_action(actions, act); > @@ -2834,7 +2839,7 @@ ixgbe_clear_rss_filter(struct rte_eth_dev *dev) > struct ixgbe_filter_info *filter_info = > IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data- > >dev_private); > > - if (filter_info->rss_info.num) > + if (filter_info->rss_info.conf.queue_num) > ixgbe_config_rss_filter(dev, &filter_info->rss_info, FALSE); > } > > @@ -3153,9 +3158,8 @@ ixgbe_flow_create(struct rte_eth_dev *dev, > PMD_DRV_LOG(ERR, "failed to allocate > memory"); > goto out; > } > - rte_memcpy(&rss_filter_ptr->filter_info, > - &rss_conf, > - sizeof(struct ixgbe_rte_flow_rss_conf)); > + ixgbe_rss_conf_init(&rss_filter_ptr->filter_info, > + &rss_conf.conf); > TAILQ_INSERT_TAIL(&filter_rss_list, > rss_filter_ptr, entries); > flow->rule = rss_filter_ptr; > diff --git a/drivers/net/ixgbe/ixgbe_rxtx.c b/drivers/net/ixgbe/ixgbe_rxtx.c > index aed3f5a9a..9fbd7dbd7 100644 > --- a/drivers/net/ixgbe/ixgbe_rxtx.c > +++ b/drivers/net/ixgbe/ixgbe_rxtx.c > @@ -5676,6 +5676,36 @@ ixgbevf_dev_rxtx_start(struct rte_eth_dev *dev) > } > > int > +ixgbe_rss_conf_init(struct ixgbe_rte_flow_rss_conf *out, > + const struct rte_flow_action_rss *in) > +{ > + if (in->key_len > RTE_DIM(out->key) || > + in->queue_num > RTE_DIM(out->queue)) > + return -EINVAL; > + out->conf = (struct rte_flow_action_rss){ > + .types = in->types, > + .key_len = in->key_len, > + .queue_num = in->queue_num, > + .key = memcpy(out->key, in->key, in->key_len), > + .queue = memcpy(out->queue, in->queue, > + sizeof(*in->queue) * in->queue_num), > + }; > + return 0; > +} > + > +int > +ixgbe_action_rss_same(const struct rte_flow_action_rss *comp, > + const struct rte_flow_action_rss *with) > +{ > + return (comp->types == with->types && > + comp->key_len == with->key_len && > + comp->queue_num == with->queue_num && > + !memcmp(comp->key, with->key, with->key_len) && > + !memcmp(comp->queue, with->queue, > + sizeof(*with->queue) * with->queue_num)); > +} > + > +int > ixgbe_config_rss_filter(struct rte_eth_dev *dev, > struct ixgbe_rte_flow_rss_conf *conf, bool add) > { > @@ -5685,7 +5715,12 @@ ixgbe_config_rss_filter(struct rte_eth_dev *dev, > uint16_t j; > uint16_t sp_reta_size; > uint32_t reta_reg; > - struct rte_eth_rss_conf rss_conf = conf->rss_conf; > + struct rte_eth_rss_conf rss_conf = { > + .rss_key = conf->conf.key_len ? > + (void *)(uintptr_t)conf->conf.key : NULL, > + .rss_key_len = conf->conf.key_len, > + .rss_hf = conf->conf.types, > + }; > struct ixgbe_filter_info *filter_info = > IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data- > >dev_private); > > @@ -5695,8 +5730,8 @@ ixgbe_config_rss_filter(struct rte_eth_dev *dev, > sp_reta_size = ixgbe_reta_size_get(hw->mac.type); > > if (!add) { > - if (memcmp(conf, &filter_info->rss_info, > - sizeof(struct ixgbe_rte_flow_rss_conf)) == 0) { > + if (ixgbe_action_rss_same(&filter_info->rss_info.conf, > + &conf->conf)) { > ixgbe_rss_disable(dev); > memset(&filter_info->rss_info, 0, > sizeof(struct ixgbe_rte_flow_rss_conf)); > @@ -5705,7 +5740,7 @@ ixgbe_config_rss_filter(struct rte_eth_dev *dev, > return -EINVAL; > } > > - if (filter_info->rss_info.num) > + if (filter_info->rss_info.conf.queue_num) > return -EINVAL; > /* Fill in redirection table > * The byte-swap is needed because NIC registers are in > @@ -5715,9 +5750,9 @@ ixgbe_config_rss_filter(struct rte_eth_dev *dev, > for (i = 0, j = 0; i < sp_reta_size; i++, j++) { > reta_reg = ixgbe_reta_reg_get(hw->mac.type, i); > > - if (j == conf->num) > + if (j == conf->conf.queue_num) > j = 0; > - reta = (reta << 8) | conf->queue[j]; > + reta = (reta << 8) | conf->conf.queue[j]; > if ((i & 3) == 3) > IXGBE_WRITE_REG(hw, reta_reg, > rte_bswap32(reta)); > @@ -5734,8 +5769,8 @@ ixgbe_config_rss_filter(struct rte_eth_dev *dev, > rss_conf.rss_key = rss_intel_key; /* Default hash key */ > ixgbe_hw_rss_hash_set(hw, &rss_conf); > > - rte_memcpy(&filter_info->rss_info, > - conf, sizeof(struct ixgbe_rte_flow_rss_conf)); > + if (ixgbe_rss_conf_init(&filter_info->rss_info, &conf->conf)) > + return -EINVAL; > > return 0; > } > diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c > index 937074a4f..3dd72dbf5 100644 > --- a/drivers/net/mlx4/mlx4.c > +++ b/drivers/net/mlx4/mlx4.c > @@ -571,7 +571,7 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct > rte_pci_device *pci_dev) > " for UDP RSS and inner VXLAN RSS"); > /* Fake support for all possible RSS hash fields. */ > priv->hw_rss_sup = ~UINT64_C(0); > - priv->hw_rss_sup = mlx4_conv_rss_hf(priv, -1); > + priv->hw_rss_sup = mlx4_conv_rss_types(priv, -1); > /* Filter out known unsupported fields. */ > priv->hw_rss_sup &= > ~(uint64_t)(IBV_RX_HASH_SRC_PORT_UDP | > diff --git a/drivers/net/mlx4/mlx4_flow.c b/drivers/net/mlx4/mlx4_flow.c > index 8feb6ae31..dd86e4ce7 100644 > --- a/drivers/net/mlx4/mlx4_flow.c > +++ b/drivers/net/mlx4/mlx4_flow.c > @@ -76,22 +76,22 @@ struct mlx4_drop { > }; > > /** > - * Convert DPDK RSS hash fields to their Verbs equivalent. > + * Convert DPDK RSS hash types to their Verbs equivalent. > * > - * This function returns the supported (default) set when @p rss_hf has > + * This function returns the supported (default) set when @p types has > * special value (uint64_t)-1. > * > * @param priv > * Pointer to private structure. > - * @param rss_hf > - * Hash fields in DPDK format (see struct rte_eth_rss_conf). > + * @param types > + * Hash types in DPDK format (see struct rte_eth_rss_conf). > * > * @return > * A valid Verbs RSS hash fields mask for mlx4 on success, (uint64_t)-1 > * otherwise and rte_errno is set. > */ > uint64_t > -mlx4_conv_rss_hf(struct priv *priv, uint64_t rss_hf) > +mlx4_conv_rss_types(struct priv *priv, uint64_t types) > { > enum { IPV4, IPV6, TCP, UDP, }; > const uint64_t in[] = { > @@ -126,17 +126,17 @@ mlx4_conv_rss_hf(struct priv *priv, uint64_t rss_hf) > unsigned int i; > > for (i = 0; i != RTE_DIM(in); ++i) > - if (rss_hf & in[i]) { > - seen |= rss_hf & in[i]; > + if (types & in[i]) { > + seen |= types & in[i]; > conv |= out[i]; > } > if ((conv & priv->hw_rss_sup) == conv) { > - if (rss_hf == (uint64_t)-1) { > + if (types == (uint64_t)-1) { > /* Include inner RSS by default if supported. */ > conv |= priv->hw_rss_sup & IBV_RX_HASH_INNER; > return conv; > } > - if (!(rss_hf & ~seen)) > + if (!(types & ~seen)) > return conv; > } > rte_errno = ENOTSUP; > @@ -717,7 +717,8 @@ mlx4_flow_prepare(struct priv *priv, > switch (action->type) { > const struct rte_flow_action_queue *queue; > const struct rte_flow_action_rss *rss; > - const struct rte_eth_rss_conf *rss_conf; > + const uint8_t *rss_key; > + uint32_t rss_key_len; > uint64_t fields; > unsigned int i; > > @@ -747,58 +748,56 @@ mlx4_flow_prepare(struct priv *priv, > break; > rss = action->conf; > /* Default RSS configuration if none is provided. */ > - rss_conf = > - rss->rss_conf ? > - rss->rss_conf : > - &(struct rte_eth_rss_conf){ > - .rss_key = > mlx4_rss_hash_key_default, > - .rss_key_len = > MLX4_RSS_HASH_KEY_SIZE, > - .rss_hf = -1, > - }; > + if (rss->key_len) { > + rss_key = rss->key; > + rss_key_len = rss->key_len; > + } else { > + rss_key = mlx4_rss_hash_key_default; > + rss_key_len = MLX4_RSS_HASH_KEY_SIZE; > + } > /* Sanity checks. */ > - for (i = 0; i < rss->num; ++i) > + for (i = 0; i < rss->queue_num; ++i) > if (rss->queue[i] >= > priv->dev->data->nb_rx_queues) > break; > - if (i != rss->num) { > + if (i != rss->queue_num) { > msg = "queue index target beyond number > of" > " configured Rx queues"; > goto exit_action_not_supported; > } > - if (!rte_is_power_of_2(rss->num)) { > + if (!rte_is_power_of_2(rss->queue_num)) { > msg = "for RSS, mlx4 requires the number of" > " queues to be a power of two"; > goto exit_action_not_supported; > } > - if (rss_conf->rss_key_len != > - sizeof(flow->rss->key)) { > + if (rss_key_len != sizeof(flow->rss->key)) { > msg = "mlx4 supports exactly one RSS hash > key" > " length: " > > MLX4_STR_EXPAND(MLX4_RSS_HASH_KEY_SIZE); > goto exit_action_not_supported; > } > - for (i = 1; i < rss->num; ++i) > + for (i = 1; i < rss->queue_num; ++i) > if (rss->queue[i] - rss->queue[i - 1] != 1) > break; > - if (i != rss->num) { > + if (i != rss->queue_num) { > msg = "mlx4 requires RSS contexts to use" > " consecutive queue indices only"; > goto exit_action_not_supported; > } > - if (rss->queue[0] % rss->num) { > + if (rss->queue[0] % rss->queue_num) { > msg = "mlx4 requires the first queue of a > RSS" > " context to be aligned on a multiple" > " of the context size"; > goto exit_action_not_supported; > } > rte_errno = 0; > - fields = mlx4_conv_rss_hf(priv, rss_conf->rss_hf); > + fields = mlx4_conv_rss_types(priv, rss->types); > if (fields == (uint64_t)-1 && rte_errno) { > msg = "unsupported RSS hash type > requested"; > goto exit_action_not_supported; > } > flow->rss = mlx4_rss_get > - (priv, fields, rss_conf->rss_key, rss->num, > + (priv, fields, rss_key, rss->queue_num, > rss->queue); > if (!flow->rss) { > msg = "either invalid parameters or not > enough" > @@ -1284,8 +1283,10 @@ mlx4_flow_internal(struct priv *priv, struct > rte_flow_error *error) > rte_align32pow2(priv->dev->data->nb_rx_queues + 1) >> 1; > uint16_t queue[queues]; > struct rte_flow_action_rss action_rss = { > - .rss_conf = NULL, /* Rely on default fallback settings. */ > - .num = queues, > + .types = -1, > + .key_len = MLX4_RSS_HASH_KEY_SIZE, > + .queue_num = queues, > + .key = mlx4_rss_hash_key_default, > .queue = queue, > }; > struct rte_flow_action actions[] = { > diff --git a/drivers/net/mlx4/mlx4_flow.h b/drivers/net/mlx4/mlx4_flow.h > index 4e3889e67..7b83d74b0 100644 > --- a/drivers/net/mlx4/mlx4_flow.h > +++ b/drivers/net/mlx4/mlx4_flow.h > @@ -47,7 +47,7 @@ struct rte_flow { > > /* mlx4_flow.c */ > > -uint64_t mlx4_conv_rss_hf(struct priv *priv, uint64_t rss_hf); > +uint64_t mlx4_conv_rss_types(struct priv *priv, uint64_t rss_hf); > int mlx4_flow_sync(struct priv *priv, struct rte_flow_error *error); > void mlx4_flow_clean(struct priv *priv); > int mlx4_filter_ctrl(struct rte_eth_dev *dev, > diff --git a/drivers/net/mlx4/mlx4_rxq.c b/drivers/net/mlx4/mlx4_rxq.c > index a7acc047b..65f099423 100644 > --- a/drivers/net/mlx4/mlx4_rxq.c > +++ b/drivers/net/mlx4/mlx4_rxq.c > @@ -88,7 +88,7 @@ > mlx4_rss_hash_key_default[MLX4_RSS_HASH_KEY_SIZE] = { > */ > struct mlx4_rss * > mlx4_rss_get(struct priv *priv, uint64_t fields, > - uint8_t key[MLX4_RSS_HASH_KEY_SIZE], > + const uint8_t key[MLX4_RSS_HASH_KEY_SIZE], > uint16_t queues, const uint16_t queue_id[]) > { > struct mlx4_rss *rss; > diff --git a/drivers/net/mlx4/mlx4_rxtx.h b/drivers/net/mlx4/mlx4_rxtx.h > index b1af86110..2dfee957f 100644 > --- a/drivers/net/mlx4/mlx4_rxtx.h > +++ b/drivers/net/mlx4/mlx4_rxtx.h > @@ -127,7 +127,7 @@ uint8_t > mlx4_rss_hash_key_default[MLX4_RSS_HASH_KEY_SIZE]; > int mlx4_rss_init(struct priv *priv); > void mlx4_rss_deinit(struct priv *priv); > struct mlx4_rss *mlx4_rss_get(struct priv *priv, uint64_t fields, > - uint8_t key[MLX4_RSS_HASH_KEY_SIZE], > + const uint8_t key[MLX4_RSS_HASH_KEY_SIZE], > uint16_t queues, const uint16_t queue_id[]); > void mlx4_rss_put(struct mlx4_rss *rss); > int mlx4_rss_attach(struct mlx4_rss *rss); > diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c > index 0c89bff45..af8853e09 100644 > --- a/drivers/net/mlx5/mlx5_flow.c > +++ b/drivers/net/mlx5/mlx5_flow.c > @@ -214,9 +214,8 @@ struct rte_flow { > TAILQ_ENTRY(rte_flow) next; /**< Pointer to the next flow structure. > */ > uint32_t mark:1; /**< Set if the flow is marked. */ > uint32_t drop:1; /**< Drop queue. */ > - uint16_t queues_n; /**< Number of entries in queue[]. */ > + struct rte_flow_action_rss rss_conf; /**< RSS configuration */ > uint16_t (*queues)[]; /**< Queues indexes to use. */ > - struct rte_eth_rss_conf rss_conf; /**< RSS configuration */ > uint8_t rss_key[40]; /**< copy of the RSS key. */ > struct ibv_counter_set *cs; /**< Holds the counters for the rule. */ > struct mlx5_flow_counter_stats counter_stats;/**<The counter > stats. */ > @@ -406,9 +405,8 @@ struct mlx5_flow_parse { > uint32_t mark:1; /**< Mark is present in the flow. */ > uint32_t count:1; /**< Count is present in the flow. */ > uint32_t mark_id; /**< Mark identifier. */ > + struct rte_flow_action_rss rss_conf; /**< RSS configuration */ > uint16_t queues[RTE_MAX_QUEUES_PER_PORT]; /**< Queues > indexes to use. */ > - uint16_t queues_n; /**< Number of entries in queue[]. */ > - struct rte_eth_rss_conf rss_conf; /**< RSS configuration */ > uint8_t rss_key[40]; /**< copy of the RSS key. */ > enum hash_rxq_type layer; /**< Last pattern layer detected. */ > struct ibv_counter_set *cs; /**< Holds the counter set for the rule */ > @@ -540,47 +538,6 @@ mlx5_flow_item_validate(const struct > rte_flow_item *item, > } > > /** > - * Copy the RSS configuration from the user ones, of the rss_conf is null, > - * uses the driver one. > - * > - * @param parser > - * Internal parser structure. > - * @param rss_conf > - * User RSS configuration to save. > - * > - * @return > - * 0 on success, a negative errno value otherwise and rte_errno is set. > - */ > -static int > -mlx5_flow_convert_rss_conf(struct mlx5_flow_parse *parser, > - const struct rte_eth_rss_conf *rss_conf) > -{ > - /* > - * This function is also called at the beginning of > - * mlx5_flow_convert_actions() to initialize the parser with the > - * device default RSS configuration. > - */ > - if (rss_conf) { > - if (rss_conf->rss_hf & MLX5_RSS_HF_MASK) { > - rte_errno = EINVAL; > - return -rte_errno; > - } > - if (rss_conf->rss_key_len != 40) { > - rte_errno = EINVAL; > - return -rte_errno; > - } > - if (rss_conf->rss_key_len && rss_conf->rss_key) { > - parser->rss_conf.rss_key_len = rss_conf- > >rss_key_len; > - memcpy(parser->rss_key, rss_conf->rss_key, > - rss_conf->rss_key_len); > - parser->rss_conf.rss_key = parser->rss_key; > - } > - parser->rss_conf.rss_hf = rss_conf->rss_hf; > - } > - return 0; > -} > - > -/** > * Extract attribute to the parser. > * > * @param[in] attr > @@ -650,17 +607,7 @@ mlx5_flow_convert_actions(struct rte_eth_dev > *dev, > enum { FATE = 1, MARK = 2, COUNT = 4, }; > uint32_t overlap = 0; > struct priv *priv = dev->data->dev_private; > - int ret; > > - /* > - * Add default RSS configuration necessary for Verbs to create QP > even > - * if no RSS is necessary. > - */ > - ret = mlx5_flow_convert_rss_conf(parser, > - (const struct rte_eth_rss_conf *) > - &priv->rss_conf); > - if (ret) > - return ret; > for (; actions->type != RTE_FLOW_ACTION_TYPE_END; ++actions) { > if (actions->type == RTE_FLOW_ACTION_TYPE_VOID) { > continue; > @@ -679,25 +626,53 @@ mlx5_flow_convert_actions(struct rte_eth_dev > *dev, > overlap |= FATE; > if (!queue || (queue->index > (priv->rxqs_n - 1))) > goto exit_action_not_supported; > - parser->queues_n = 1; > parser->queues[0] = queue->index; > + parser->rss_conf = (struct rte_flow_action_rss){ > + .queue_num = 1, > + .queue = parser->queues, > + }; > } else if (actions->type == RTE_FLOW_ACTION_TYPE_RSS) { > const struct rte_flow_action_rss *rss = > (const struct rte_flow_action_rss *) > actions->conf; > + const uint8_t *rss_key; > + uint32_t rss_key_len; > uint16_t n; > > if (overlap & FATE) > goto exit_action_overlap; > overlap |= FATE; > - if (!rss || !rss->num) { > + if (rss->types & MLX5_RSS_HF_MASK) { > + rte_flow_error_set(error, EINVAL, > + > RTE_FLOW_ERROR_TYPE_ACTION, > + actions, > + "unsupported RSS type" > + " requested"); > + return -rte_errno; > + } > + if (rss->key_len) { > + rss_key_len = rss->key_len; > + rss_key = rss->key; > + } else { > + rss_key_len = rss_hash_default_key_len; > + rss_key = rss_hash_default_key; > + } > + if (rss_key_len != RTE_DIM(parser->rss_key)) { > + rte_flow_error_set(error, EINVAL, > + > RTE_FLOW_ERROR_TYPE_ACTION, > + actions, > + "RSS hash key must be" > + " exactly 40 bytes long"); > + return -rte_errno; > + } > + if (!rss->queue_num) { > rte_flow_error_set(error, EINVAL, > > RTE_FLOW_ERROR_TYPE_ACTION, > actions, > "no valid queues"); > return -rte_errno; > } > - if (rss->num > RTE_DIM(parser->queues)) { > + if (rss->queue_num > RTE_DIM(parser->queues)) { > rte_flow_error_set(error, EINVAL, > > RTE_FLOW_ERROR_TYPE_ACTION, > actions, > @@ -705,7 +680,7 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, > " context"); > return -rte_errno; > } > - for (n = 0; n < rss->num; ++n) { > + for (n = 0; n < rss->queue_num; ++n) { > if (rss->queue[n] >= priv->rxqs_n) { > rte_flow_error_set(error, EINVAL, > > RTE_FLOW_ERROR_TYPE_ACTION, > @@ -715,16 +690,16 @@ mlx5_flow_convert_actions(struct rte_eth_dev > *dev, > return -rte_errno; > } > } > - for (n = 0; n < rss->num; ++n) > - parser->queues[n] = rss->queue[n]; > - parser->queues_n = rss->num; > - if (mlx5_flow_convert_rss_conf(parser, rss- > >rss_conf)) { > - rte_flow_error_set(error, EINVAL, > - > RTE_FLOW_ERROR_TYPE_ACTION, > - actions, > - "wrong RSS configuration"); > - return -rte_errno; > - } > + parser->rss_conf = (struct rte_flow_action_rss){ > + .types = rss->types, > + .key_len = rss_key_len, > + .queue_num = rss->queue_num, > + .key = memcpy(parser->rss_key, rss_key, > + sizeof(*rss_key) * rss_key_len), > + .queue = memcpy(parser->queues, rss- > >queue, > + sizeof(*rss->queue) * > + rss->queue_num), > + }; > } else if (actions->type == RTE_FLOW_ACTION_TYPE_MARK) > { > const struct rte_flow_action_mark *mark = > (const struct rte_flow_action_mark *) > @@ -769,7 +744,7 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, > parser->drop = 1; > if (parser->drop && parser->mark) > parser->mark = 0; > - if (!parser->queues_n && !parser->drop) { > + if (!parser->rss_conf.queue_num && !parser->drop) { > rte_flow_error_set(error, ENOTSUP, > RTE_FLOW_ERROR_TYPE_HANDLE, > NULL, "no valid action"); > return -rte_errno; > @@ -951,7 +926,7 @@ mlx5_flow_convert_finalise(struct mlx5_flow_parse > *parser) > unsigned int i; > > /* Remove any other flow not matching the pattern. */ > - if (parser->queues_n == 1 && !parser->rss_conf.rss_hf) { > + if (parser->rss_conf.queue_num == 1 && !parser->rss_conf.types) { > for (i = 0; i != hash_rxq_init_n; ++i) { > if (i == HASH_RXQ_ETH) > continue; > @@ -979,7 +954,7 @@ mlx5_flow_convert_finalise(struct mlx5_flow_parse > *parser) > } > /* Remove impossible flow according to the RSS configuration. */ > if (hash_rxq_init[parser->layer].dpdk_rss_hf & > - parser->rss_conf.rss_hf) { > + parser->rss_conf.types) { > /* Remove any other flow. */ > for (i = hmin; i != (hmax + 1); ++i) { > if ((i == parser->layer) || > @@ -990,7 +965,7 @@ mlx5_flow_convert_finalise(struct mlx5_flow_parse > *parser) > } > } else if (!parser->queue[ip].ibv_attr) { > /* no RSS possible with the current configuration. */ > - parser->queues_n = 1; > + parser->rss_conf.queue_num = 1; > return; > } > fill: > @@ -1119,7 +1094,7 @@ mlx5_flow_convert(struct rte_eth_dev *dev, > for (i = 0; i != hash_rxq_init_n; ++i) { > unsigned int offset; > > - if (!(parser->rss_conf.rss_hf & > + if (!(parser->rss_conf.types & > hash_rxq_init[i].dpdk_rss_hf) && > (i != HASH_RXQ_ETH)) > continue; > @@ -1787,20 +1762,20 @@ mlx5_flow_create_action_queue_rss(struct > rte_eth_dev *dev, > continue; > flow->frxq[i].hrxq = > mlx5_hrxq_get(dev, > - parser->rss_conf.rss_key, > - parser->rss_conf.rss_key_len, > + parser->rss_conf.key, > + parser->rss_conf.key_len, > hash_fields, > - parser->queues, > - parser->queues_n); > + parser->rss_conf.queue, > + parser->rss_conf.queue_num); > if (flow->frxq[i].hrxq) > continue; > flow->frxq[i].hrxq = > mlx5_hrxq_new(dev, > - parser->rss_conf.rss_key, > - parser->rss_conf.rss_key_len, > + parser->rss_conf.key, > + parser->rss_conf.key_len, > hash_fields, > - parser->queues, > - parser->queues_n); > + parser->rss_conf.queue, > + parser->rss_conf.queue_num); > if (!flow->frxq[i].hrxq) { > return rte_flow_error_set(error, ENOMEM, > > RTE_FLOW_ERROR_TYPE_HANDLE, > @@ -1871,9 +1846,9 @@ mlx5_flow_create_action_queue(struct > rte_eth_dev *dev, > NULL, "internal error in flow creation"); > goto error; > } > - for (i = 0; i != parser->queues_n; ++i) { > + for (i = 0; i != parser->rss_conf.queue_num; ++i) { > struct mlx5_rxq_data *q = > - (*priv->rxqs)[parser->queues[i]]; > + (*priv->rxqs)[parser->rss_conf.queue[i]]; > > q->mark |= parser->mark; > } > @@ -1937,7 +1912,8 @@ mlx5_flow_list_create(struct rte_eth_dev *dev, > if (ret) > goto exit; > flow = rte_calloc(__func__, 1, > - sizeof(*flow) + parser.queues_n * sizeof(uint16_t), > + sizeof(*flow) + > + parser.rss_conf.queue_num * sizeof(uint16_t), > 0); > if (!flow) { > rte_flow_error_set(error, ENOMEM, > @@ -1946,15 +1922,20 @@ mlx5_flow_list_create(struct rte_eth_dev *dev, > "cannot allocate flow memory"); > return NULL; > } > - /* Copy queues configuration. */ > + /* Copy configuration. */ > flow->queues = (uint16_t (*)[])(flow + 1); > - memcpy(flow->queues, parser.queues, parser.queues_n * > sizeof(uint16_t)); > - flow->queues_n = parser.queues_n; > + flow->rss_conf = (struct rte_flow_action_rss){ > + .types = parser.rss_conf.types, > + .key_len = parser.rss_conf.key_len, > + .queue_num = parser.rss_conf.queue_num, > + .key = memcpy(flow->rss_key, parser.rss_conf.key, > + sizeof(*parser.rss_conf.key) * > + parser.rss_conf.key_len), > + .queue = memcpy(flow->queues, parser.rss_conf.queue, > + sizeof(*parser.rss_conf.queue) * > + parser.rss_conf.queue_num), > + }; > flow->mark = parser.mark; > - /* Copy RSS configuration. */ > - flow->rss_conf = parser.rss_conf; > - flow->rss_conf.rss_key = flow->rss_key; > - memcpy(flow->rss_key, parser.rss_key, > parser.rss_conf.rss_key_len); > /* finalise the flow. */ > if (parser.drop) > ret = mlx5_flow_create_action_queue_drop(dev, &parser, > flow, > @@ -2034,7 +2015,7 @@ mlx5_flow_list_destroy(struct rte_eth_dev *dev, > struct mlx5_flows *list, > > if (flow->drop || !flow->mark) > goto free; > - for (i = 0; i != flow->queues_n; ++i) { > + for (i = 0; i != flow->rss_conf.queue_num; ++i) { > struct rte_flow *tmp; > int mark = 0; > > @@ -2344,19 +2325,19 @@ mlx5_flow_start(struct rte_eth_dev *dev, struct > mlx5_flows *list) > if (!flow->frxq[i].ibv_attr) > continue; > flow->frxq[i].hrxq = > - mlx5_hrxq_get(dev, flow->rss_conf.rss_key, > - flow->rss_conf.rss_key_len, > + mlx5_hrxq_get(dev, flow->rss_conf.key, > + flow->rss_conf.key_len, > hash_rxq_init[i].hash_fields, > - (*flow->queues), > - flow->queues_n); > + flow->rss_conf.queue, > + flow->rss_conf.queue_num); > if (flow->frxq[i].hrxq) > goto flow_create; > flow->frxq[i].hrxq = > - mlx5_hrxq_new(dev, flow->rss_conf.rss_key, > - flow->rss_conf.rss_key_len, > + mlx5_hrxq_new(dev, flow->rss_conf.key, > + flow->rss_conf.key_len, > hash_rxq_init[i].hash_fields, > - (*flow->queues), > - flow->queues_n); > + flow->rss_conf.queue, > + flow->rss_conf.queue_num); > if (!flow->frxq[i].hrxq) { > DRV_LOG(DEBUG, > "port %u flow %p cannot be applied", > @@ -2380,8 +2361,8 @@ mlx5_flow_start(struct rte_eth_dev *dev, struct > mlx5_flows *list) > } > if (!flow->mark) > continue; > - for (i = 0; i != flow->queues_n; ++i) > - (*priv->rxqs)[(*flow->queues)[i]]->mark = 1; > + for (i = 0; i != flow->rss_conf.queue_num; ++i) > + (*priv->rxqs)[flow->rss_conf.queue[i]]->mark = 1; > } > return 0; > } > @@ -2458,8 +2439,10 @@ mlx5_ctrl_flow_vlan(struct rte_eth_dev *dev, > }; > uint16_t queue[priv->reta_idx_n]; > struct rte_flow_action_rss action_rss = { > - .rss_conf = &priv->rss_conf, > - .num = priv->reta_idx_n, > + .types = priv->rss_conf.rss_hf, > + .key_len = priv->rss_conf.rss_key_len, > + .queue_num = priv->reta_idx_n, > + .key = priv->rss_conf.rss_key, > .queue = queue, > }; > struct rte_flow_action actions[] = { > diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c > index eda3ba3d5..d2b25e8e8 100644 > --- a/drivers/net/mlx5/mlx5_rxq.c > +++ b/drivers/net/mlx5/mlx5_rxq.c > @@ -1218,8 +1218,8 @@ mlx5_rxq_verify(struct rte_eth_dev *dev) > * The Verbs object initialised, NULL otherwise and rte_errno is set. > */ > struct mlx5_ind_table_ibv * > -mlx5_ind_table_ibv_new(struct rte_eth_dev *dev, uint16_t queues[], > - uint16_t queues_n) > +mlx5_ind_table_ibv_new(struct rte_eth_dev *dev, const uint16_t *queues, > + uint32_t queues_n) > { > struct priv *priv = dev->data->dev_private; > struct mlx5_ind_table_ibv *ind_tbl; > @@ -1286,8 +1286,8 @@ mlx5_ind_table_ibv_new(struct rte_eth_dev *dev, > uint16_t queues[], > * An indirection table if found. > */ > struct mlx5_ind_table_ibv * > -mlx5_ind_table_ibv_get(struct rte_eth_dev *dev, uint16_t queues[], > - uint16_t queues_n) > +mlx5_ind_table_ibv_get(struct rte_eth_dev *dev, const uint16_t *queues, > + uint32_t queues_n) > { > struct priv *priv = dev->data->dev_private; > struct mlx5_ind_table_ibv *ind_tbl; > @@ -1391,8 +1391,10 @@ mlx5_ind_table_ibv_verify(struct rte_eth_dev > *dev) > * The Verbs object initialised, NULL otherwise and rte_errno is set. > */ > struct mlx5_hrxq * > -mlx5_hrxq_new(struct rte_eth_dev *dev, uint8_t *rss_key, uint8_t > rss_key_len, > - uint64_t hash_fields, uint16_t queues[], uint16_t queues_n) > +mlx5_hrxq_new(struct rte_eth_dev *dev, > + const uint8_t *rss_key, uint32_t rss_key_len, > + uint64_t hash_fields, > + const uint16_t *queues, uint32_t queues_n) > { > struct priv *priv = dev->data->dev_private; > struct mlx5_hrxq *hrxq; > @@ -1408,6 +1410,10 @@ mlx5_hrxq_new(struct rte_eth_dev *dev, uint8_t > *rss_key, uint8_t rss_key_len, > rte_errno = ENOMEM; > return NULL; > } > + if (!rss_key_len) { > + rss_key_len = rss_hash_default_key_len; > + rss_key = rss_hash_default_key; > + } > qp = mlx5_glue->create_qp_ex > (priv->ctx, > &(struct ibv_qp_init_attr_ex){ > @@ -1419,7 +1425,7 @@ mlx5_hrxq_new(struct rte_eth_dev *dev, uint8_t > *rss_key, uint8_t rss_key_len, > .rx_hash_conf = (struct ibv_rx_hash_conf){ > .rx_hash_function = > IBV_RX_HASH_FUNC_TOEPLITZ, > .rx_hash_key_len = rss_key_len, > - .rx_hash_key = rss_key, > + .rx_hash_key = (void *)(uintptr_t)rss_key, > .rx_hash_fields_mask = hash_fields, > }, > .rwq_ind_tbl = ind_tbl->ind_table, > @@ -1469,8 +1475,10 @@ mlx5_hrxq_new(struct rte_eth_dev *dev, uint8_t > *rss_key, uint8_t rss_key_len, > * An hash Rx queue on success. > */ > struct mlx5_hrxq * > -mlx5_hrxq_get(struct rte_eth_dev *dev, uint8_t *rss_key, uint8_t > rss_key_len, > - uint64_t hash_fields, uint16_t queues[], uint16_t queues_n) > +mlx5_hrxq_get(struct rte_eth_dev *dev, > + const uint8_t *rss_key, uint32_t rss_key_len, > + uint64_t hash_fields, > + const uint16_t *queues, uint32_t queues_n) > { > struct priv *priv = dev->data->dev_private; > struct mlx5_hrxq *hrxq; > diff --git a/drivers/net/mlx5/mlx5_rxtx.h b/drivers/net/mlx5/mlx5_rxtx.h > index 14d4418d9..c3a1ae213 100644 > --- a/drivers/net/mlx5/mlx5_rxtx.h > +++ b/drivers/net/mlx5/mlx5_rxtx.h > @@ -134,7 +134,7 @@ struct mlx5_ind_table_ibv { > LIST_ENTRY(mlx5_ind_table_ibv) next; /* Pointer to the next > element. */ > rte_atomic32_t refcnt; /* Reference counter. */ > struct ibv_rwq_ind_table *ind_table; /**< Indirection table. */ > - uint16_t queues_n; /**< Number of queues in the list. */ > + uint32_t queues_n; /**< Number of queues in the list. */ > uint16_t queues[]; /**< Queue list. */ > }; > > @@ -145,7 +145,7 @@ struct mlx5_hrxq { > struct mlx5_ind_table_ibv *ind_table; /* Indirection table. */ > struct ibv_qp *qp; /* Verbs queue pair. */ > uint64_t hash_fields; /* Verbs Hash fields. */ > - uint8_t rss_key_len; /* Hash key length in bytes. */ > + uint32_t rss_key_len; /* Hash key length in bytes. */ > uint8_t rss_key[]; /* Hash key. */ > }; > > @@ -238,20 +238,22 @@ int mlx5_rxq_releasable(struct rte_eth_dev *dev, > uint16_t idx); > int mlx5_rxq_verify(struct rte_eth_dev *dev); > int rxq_alloc_elts(struct mlx5_rxq_ctrl *rxq_ctrl); > struct mlx5_ind_table_ibv *mlx5_ind_table_ibv_new(struct rte_eth_dev > *dev, > - uint16_t queues[], > - uint16_t queues_n); > + const uint16_t *queues, > + uint32_t queues_n); > struct mlx5_ind_table_ibv *mlx5_ind_table_ibv_get(struct rte_eth_dev > *dev, > - uint16_t queues[], > - uint16_t queues_n); > + const uint16_t *queues, > + uint32_t queues_n); > int mlx5_ind_table_ibv_release(struct rte_eth_dev *dev, > struct mlx5_ind_table_ibv *ind_tbl); > int mlx5_ind_table_ibv_verify(struct rte_eth_dev *dev); > -struct mlx5_hrxq *mlx5_hrxq_new(struct rte_eth_dev *dev, uint8_t > *rss_key, > - uint8_t rss_key_len, uint64_t hash_fields, > - uint16_t queues[], uint16_t queues_n); > -struct mlx5_hrxq *mlx5_hrxq_get(struct rte_eth_dev *dev, uint8_t > *rss_key, > - uint8_t rss_key_len, uint64_t hash_fields, > - uint16_t queues[], uint16_t queues_n); > +struct mlx5_hrxq *mlx5_hrxq_new(struct rte_eth_dev *dev, > + const uint8_t *rss_key, uint32_t rss_key_len, > + uint64_t hash_fields, > + const uint16_t *queues, uint32_t queues_n); > +struct mlx5_hrxq *mlx5_hrxq_get(struct rte_eth_dev *dev, > + const uint8_t *rss_key, uint32_t rss_key_len, > + uint64_t hash_fields, > + const uint16_t *queues, uint32_t queues_n); > int mlx5_hrxq_release(struct rte_eth_dev *dev, struct mlx5_hrxq *hxrq); > int mlx5_hrxq_ibv_verify(struct rte_eth_dev *dev); > uint64_t mlx5_get_rx_port_offloads(void); > diff --git a/drivers/net/sfc/sfc_flow.c b/drivers/net/sfc/sfc_flow.c > index 056405515..1a2c0299c 100644 > --- a/drivers/net/sfc/sfc_flow.c > +++ b/drivers/net/sfc/sfc_flow.c > @@ -1234,13 +1234,11 @@ sfc_flow_parse_rss(struct sfc_adapter *sa, > struct sfc_rxq *rxq; > unsigned int rxq_hw_index_min; > unsigned int rxq_hw_index_max; > - const struct rte_eth_rss_conf *rss_conf = rss->rss_conf; > - uint64_t rss_hf; > - uint8_t *rss_key = NULL; > + const uint8_t *rss_key; > struct sfc_flow_rss *sfc_rss_conf = &flow->rss_conf; > unsigned int i; > > - if (rss->num == 0) > + if (rss->queue_num == 0) > return -EINVAL; > > rxq_sw_index = sa->rxq_count - 1; > @@ -1248,7 +1246,7 @@ sfc_flow_parse_rss(struct sfc_adapter *sa, > rxq_hw_index_min = rxq->hw_index; > rxq_hw_index_max = 0; > > - for (i = 0; i < rss->num; ++i) { > + for (i = 0; i < rss->queue_num; ++i) { > rxq_sw_index = rss->queue[i]; > > if (rxq_sw_index >= sa->rxq_count) > @@ -1263,15 +1261,14 @@ sfc_flow_parse_rss(struct sfc_adapter *sa, > rxq_hw_index_max = rxq->hw_index; > } > > - rss_hf = (rss_conf != NULL) ? rss_conf->rss_hf : SFC_RSS_OFFLOADS; > - if ((rss_hf & ~SFC_RSS_OFFLOADS) != 0) > + if ((rss->types & ~SFC_RSS_OFFLOADS) != 0) > return -EINVAL; > > - if (rss_conf != NULL) { > - if (rss_conf->rss_key_len != sizeof(sa->rss_key)) > + if (rss->key_len) { > + if (rss->key_len != sizeof(sa->rss_key)) > return -EINVAL; > > - rss_key = rss_conf->rss_key; > + rss_key = rss->key; > } else { > rss_key = sa->rss_key; > } > @@ -1280,11 +1277,11 @@ sfc_flow_parse_rss(struct sfc_adapter *sa, > > sfc_rss_conf->rxq_hw_index_min = rxq_hw_index_min; > sfc_rss_conf->rxq_hw_index_max = rxq_hw_index_max; > - sfc_rss_conf->rss_hash_types = sfc_rte_to_efx_hash_type(rss_hf); > + sfc_rss_conf->rss_hash_types = sfc_rte_to_efx_hash_type(rss- > >types); > rte_memcpy(sfc_rss_conf->rss_key, rss_key, sizeof(sa->rss_key)); > > for (i = 0; i < RTE_DIM(sfc_rss_conf->rss_tbl); ++i) { > - unsigned int rxq_sw_index = rss->queue[i % rss->num]; > + unsigned int rxq_sw_index = rss->queue[i % rss- > >queue_num]; > struct sfc_rxq *rxq = sa->rxq_info[rxq_sw_index].rxq; > > sfc_rss_conf->rss_tbl[i] = rxq->hw_index - > rxq_hw_index_min; > diff --git a/drivers/net/tap/tap_flow.c b/drivers/net/tap/tap_flow.c > index fe2f94010..67146aaba 100644 > --- a/drivers/net/tap/tap_flow.c > +++ b/drivers/net/tap/tap_flow.c > @@ -1215,7 +1215,7 @@ priv_flow_process(struct pmd_internals *pmd, > if (err) > goto exit_action_not_supported; > } > - if (flow && rss) > + if (flow) > err = rss_add_actions(flow, pmd, rss, error); > } else { > goto exit_action_not_supported; > @@ -2050,7 +2050,7 @@ static int rss_add_actions(struct rte_flow *flow, > struct pmd_internals *pmd, > struct rte_flow_error *error) > { > /* 4096 is the maximum number of instructions for a BPF program */ > - int i; > + unsigned int i; > int err; > struct rss_key rss_entry = { .hash_fields = 0, > .key_size = 0 }; > @@ -2066,8 +2066,8 @@ static int rss_add_actions(struct rte_flow *flow, > struct pmd_internals *pmd, > } > > /* Update RSS map entry with queues */ > - rss_entry.nb_queues = rss->num; > - for (i = 0; i < rss->num; i++) > + rss_entry.nb_queues = rss->queue_num; > + for (i = 0; i < rss->queue_num; i++) > rss_entry.queues[i] = rss->queue[i]; > rss_entry.hash_fields = > (1 << HASH_FIELD_IPV4_L3_L4) | (1 << > HASH_FIELD_IPV6_L3_L4); > diff --git a/examples/ipsec-secgw/ipsec.c b/examples/ipsec-secgw/ipsec.c > index 5971937cf..ee2497352 100644 > --- a/examples/ipsec-secgw/ipsec.c > +++ b/examples/ipsec-secgw/ipsec.c > @@ -203,9 +203,13 @@ create_session(struct ipsec_ctx *ipsec_ctx, struct > ipsec_sa *sa) > i < eth_dev->data->nb_rx_queues; ++i) > if (eth_dev->data->rx_queues[i]) > queue[j++] = i; > - action_rss.rss_conf = &rss_conf; > - action_rss.num = j; > - action_rss.queue = queue; > + action_rss = (struct rte_flow_action_rss){ > + .types = rss_conf.rss_hf, > + .key_len = rss_conf.rss_key_len, > + .queue_num = j, > + .key = rss_key, > + .queue = queue, > + }; > ret = rte_flow_validate(sa->portid, &sa->attr, > sa->pattern, sa- > >action, > &err); > diff --git a/lib/librte_ether/rte_flow.c b/lib/librte_ether/rte_flow.c > index bb19e28c6..cc7819b6a 100644 > --- a/lib/librte_ether/rte_flow.c > +++ b/lib/librte_ether/rte_flow.c > @@ -330,40 +330,27 @@ flow_action_conf_copy(void *buf, const struct > rte_flow_action *action) > off = 0; > if (dst.rss) > *dst.rss = (struct rte_flow_action_rss){ > - .num = src.rss->num, > + .types = src.rss->types, > + .key_len = src.rss->key_len, > + .queue_num = src.rss->queue_num, > }; > off += sizeof(*src.rss); > - if (src.rss->num) { > + if (src.rss->key_len) { > off = RTE_ALIGN_CEIL(off, sizeof(double)); > - size = sizeof(*src.rss->queue) * src.rss->num; > + size = sizeof(*src.rss->key) * src.rss->key_len; > if (dst.rss) > - dst.rss->queue = memcpy > + dst.rss->key = memcpy > ((void *)((uintptr_t)dst.rss + off), > - src.rss->queue, size); > + src.rss->key, size); > off += size; > } > - off = RTE_ALIGN_CEIL(off, sizeof(double)); > - if (dst.rss) { > - dst.rss->rss_conf = (void *)((uintptr_t)dst.rss + off); > - *(struct rte_eth_rss_conf *)(uintptr_t) > - dst.rss->rss_conf = (struct > rte_eth_rss_conf){ > - .rss_key_len = src.rss->rss_conf- > >rss_key_len, > - .rss_hf = src.rss->rss_conf->rss_hf, > - }; > - } > - off += sizeof(*src.rss->rss_conf); > - if (src.rss->rss_conf->rss_key_len) { > + if (src.rss->queue_num) { > off = RTE_ALIGN_CEIL(off, sizeof(double)); > - size = sizeof(*src.rss->rss_conf->rss_key) * > - src.rss->rss_conf->rss_key_len; > - if (dst.rss) { > - ((struct rte_eth_rss_conf *)(uintptr_t) > - dst.rss->rss_conf)->rss_key = > - (void *)((uintptr_t)dst.rss + off); > - memcpy(dst.rss->rss_conf->rss_key, > - src.rss->rss_conf->rss_key, > - size); > - } > + size = sizeof(*src.rss->queue) * src.rss->queue_num; > + if (dst.rss) > + dst.rss->queue = memcpy > + ((void *)((uintptr_t)dst.rss + off), > + src.rss->queue, size); > off += size; > } > size = off; > diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h > index ad2e55b8e..bbc408fa6 100644 > --- a/lib/librte_ether/rte_flow.h > +++ b/lib/librte_ether/rte_flow.h > @@ -1033,13 +1033,21 @@ struct rte_flow_query_count { > * Similar to QUEUE, except RSS is additionally performed on packets to > * spread them among several queues according to the provided parameters. > * > + * Unlike global RSS settings used by other DPDK APIs, unsetting the > + * @p types field does not disable RSS in a flow rule. Doing so instead > + * requests safe unspecified "best-effort" settings from the underlying > PMD, > + * which depending on the flow rule, may result in anything ranging from > + * empty (single queue) to all-inclusive RSS. > + * > * Note: RSS hash result is stored in the hash.rss mbuf field which overlaps > * hash.fdir.lo. Since the MARK action sets the hash.fdir.hi field only, > * both can be requested simultaneously. > */ > struct rte_flow_action_rss { > - const struct rte_eth_rss_conf *rss_conf; /**< RSS parameters. */ > - uint16_t num; /**< Number of entries in @p queue. */ > + uint64_t types; /**< Specific RSS hash types (see ETH_RSS_*). */ > + uint32_t key_len; /**< Hash key length in bytes. */ > + uint32_t queue_num; /**< Number of entries in @p queue. */ > + const uint8_t *key; /**< Hash key. */ > const uint16_t *queue; /**< Queue indices to use. */ > }; > > -- > 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [dpdk-dev] [PATCH v6 07/16] ethdev: flatten RSS configuration in flow API 2018-04-28 7:45 ` Peng, Yuan @ 2018-05-03 12:48 ` Adrien Mazarguil 2018-05-04 9:31 ` Zhao1, Wei 0 siblings, 1 reply; 157+ messages in thread From: Adrien Mazarguil @ 2018-05-03 12:48 UTC (permalink / raw) To: Peng, Yuan Cc: Zhao1, Wei, dev, Xu, Qian Q, Liu, Yu Y, Lu, Wenzhuo, Wu, Jingjing Hi Peng Yuan, Apologies for the delay, I'll answer below to the entire thread. On Sat, Apr 28, 2018 at 07:45:31AM +0000, Peng, Yuan wrote: > Hi,Adrien Mazarguil > > There is a bug of queue region with 18.05-rc1 > The test steps are as below: > ./usertools/dpdk-devbind.py -b igb_uio 05:00.0 > ./x86_64-native-linuxapp-gcc/app/testpmd -c 1ffff -n 4 -- -i --rxq=16 --txq=16 > testpmd> port config all rss all > Configuration of RSS hash at ethernet port 0 failed with error (22): Invalid argument. I assume this issue is related rte_eth_dev_configure() which was recently fixed [1], right? [1] "ethdev: fix applications failure on configure" http://dpdk.org/ml/archives/dev/2018-May/099858.html <snip> > There is a bug present with 18.05-rci when I test the feature "Move RSS to rte_flow" in i40e NIC > The test steps are as below: > ./usertools/dpdk-devbind.py -b igb_uio 05:00.0 05:00.1 > ./x86_64-native-linuxapp-gcc/app/testpmd -c 0x1fffe -n 4 -- -i --nb-cores=8 --rxq=8 --txq=8 --port-topology=chained > testpmd> set fwd rxonly > Set rxonly packet forwarding mode > testpmd> set verbose 1 > Change verbose level from 0 to 1 > testpmd> start > testpmd> flow create 0 ingress pattern end actions rss queues 0 4 7 end / end > Caught error type 16 (specific action): cause: 0x7fff84e33658, RSS hash key too large > > The rss rule can be set successfully when I test it yesterday with older dpdk version without this patch. Regarding this issue, the testpmd flow command now requests hash key length from the PMD by default [2] if left unspecified by user. This value is taken from the "hash_key_size" field returned by rte_eth_dev_infos_get(). While most PMDs return 40 here, i40e returns: (I40E_PFQF_HKEY_MAX_INDEX + 1) * sizeof(uint32_t) /* that is, (12 + 1) * 4 => 52 */ Is this correct and really supported by i40e? Otherwise I'd suggest to fix the PMD as it may also confuse applications other than testpmd. Note that you should be able to revert to the old behavior with the PMD-specific default key by specifying a "key_len 0" parameter to the RSS action. [2] http://dpdk.org/browse/dpdk/tree/app/test-pmd/cmdline_flow.c?id=v18.05-rc2#n2780 <snip> > There is another problem with ixgbe nic: > ./usertools/dpdk-devbind.py -b igb_uio 07:00.0 07:00.1 > ./x86_64-native-linuxapp-gcc/app/testpmd -c 0x1fffe -n 4 -- -i --nb-cores=8 --rxq=8 --txq=8 --disable-rss --port-topology=chained > testpmd> flow create 0 ingress pattern end actions rss queues 5 6 7 end / end > Caught error type 2 (flow rule (handle)): Failed to create flow. > The rule setting command can be executed successfully with older dpdk version. > > Could you help to check if there is a relationship between the bugs and this patch? Perhaps a similar issue since testpmd now provides default values for unspecified fields of the RSS action, that is, a default hash key with a PMD-returned default length and the global "rss_hf" value for types (here 0 due to --disable-rss). Try appending the following arguments to the RSS action: key_len 0 types ip udp end If it works, it probably means the issue was always present, it just never showed up due to the inability to validate RSS action parameters previously. You should make sure ixgbe supports them. -- Adrien Mazarguil 6WIND ^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [dpdk-dev] [PATCH v6 07/16] ethdev: flatten RSS configuration in flow API 2018-05-03 12:48 ` Adrien Mazarguil @ 2018-05-04 9:31 ` Zhao1, Wei 2018-05-04 9:44 ` Adrien Mazarguil 0 siblings, 1 reply; 157+ messages in thread From: Zhao1, Wei @ 2018-05-04 9:31 UTC (permalink / raw) To: Adrien Mazarguil, Peng, Yuan Cc: dev, Xu, Qian Q, Liu, Yu Y, Lu, Wenzhuo, Wu, Jingjing Hi, Adrien Mazarguil > -----Original Message----- > From: Adrien Mazarguil [mailto:adrien.mazarguil@6wind.com] > Sent: Thursday, May 3, 2018 8:48 PM > To: Peng, Yuan <yuan.peng@intel.com> > Cc: Zhao1, Wei <wei.zhao1@intel.com>; dev@dpdk.org; Xu, Qian Q > <qian.q.xu@intel.com>; Liu, Yu Y <yu.y.liu@intel.com>; Lu, Wenzhuo > <wenzhuo.lu@intel.com>; Wu, Jingjing <jingjing.wu@intel.com> > Subject: Re: [dpdk-dev] [PATCH v6 07/16] ethdev: flatten RSS configuration > in flow API > > Hi Peng Yuan, > > Apologies for the delay, I'll answer below to the entire thread. > > On Sat, Apr 28, 2018 at 07:45:31AM +0000, Peng, Yuan wrote: > > Hi,Adrien Mazarguil > > > > There is a bug of queue region with 18.05-rc1 The test steps are as > > below: > > ./usertools/dpdk-devbind.py -b igb_uio 05:00.0 > > ./x86_64-native-linuxapp-gcc/app/testpmd -c 1ffff -n 4 -- -i --rxq=16 > > --txq=16 > > testpmd> port config all rss all > > Configuration of RSS hash at ethernet port 0 failed with error (22): Invalid > argument. > > I assume this issue is related rte_eth_dev_configure() which was recently > fixed [1], right? > > [1] "ethdev: fix applications failure on configure" > http://dpdk.org/ml/archives/dev/2018-May/099858.html > > <snip> > > There is a bug present with 18.05-rci when I test the feature "Move > > RSS to rte_flow" in i40e NIC The test steps are as below: > > ./usertools/dpdk-devbind.py -b igb_uio 05:00.0 05:00.1 > > ./x86_64-native-linuxapp-gcc/app/testpmd -c 0x1fffe -n 4 -- -i > > --nb-cores=8 --rxq=8 --txq=8 --port-topology=chained > > testpmd> set fwd rxonly > > Set rxonly packet forwarding mode > > testpmd> set verbose 1 > > Change verbose level from 0 to 1 > > testpmd> start > > testpmd> flow create 0 ingress pattern end actions rss queues 0 4 7 > > testpmd> end / end > > Caught error type 16 (specific action): cause: 0x7fff84e33658, RSS > > hash key too large > > > > The rss rule can be set successfully when I test it yesterday with older dpdk > version without this patch. > > Regarding this issue, the testpmd flow command now requests hash key > length from the PMD by default [2] if left unspecified by user. This value is > taken from the "hash_key_size" field returned by rte_eth_dev_infos_get(). > > While most PMDs return 40 here, i40e returns: > > (I40E_PFQF_HKEY_MAX_INDEX + 1) * sizeof(uint32_t) > /* that is, (12 + 1) * 4 => 52 */ > > Is this correct and really supported by i40e? Otherwise I'd suggest to fix the > PMD as it may also confuse applications other than testpmd. > > Note that you should be able to revert to the old behavior with the PMD- > specific default key by specifying a "key_len 0" parameter to the RSS action. > > [2] http://dpdk.org/browse/dpdk/tree/app/test- > pmd/cmdline_flow.c?id=v18.05-rc2#n2780 This is the root cause for this issue, although i40 return : dev_info->hash_key_size = (I40E_PFQF_HKEY_MAX_INDEX + 1) * sizeof(uint32_t); that is 52 byte, but " RTE_DIM(rss_config->key)" , which is uint8_t key[(I40E_VFQF_HKEY_MAX_INDEX > I40E_PFQF_HKEY_MAX_INDEX ? I40E_VFQF_HKEY_MAX_INDEX : I40E_PFQF_HKEY_MAX_INDEX) + 1 * sizeof(uint32_t)]; /* Hash key. */ is not 52!!! I think the code should be : uint8_t key[(I40E_VFQF_HKEY_MAX_INDEX > I40E_PFQF_HKEY_MAX_INDEX ? I40E_VFQF_HKEY_MAX_INDEX : I40E_PFQF_HKEY_MAX_INDEX + 1) * sizeof(uint32_t)]; /* Hash key. */ If you agree and permit, I WILL commit a patch to fix this bug. Thank you! > > <snip> > > There is another problem with ixgbe nic: > > ./usertools/dpdk-devbind.py -b igb_uio 07:00.0 07:00.1 > > ./x86_64-native-linuxapp-gcc/app/testpmd -c 0x1fffe -n 4 -- -i > > --nb-cores=8 --rxq=8 --txq=8 --disable-rss --port-topology=chained > > testpmd> flow create 0 ingress pattern end actions rss queues 5 6 7 > > testpmd> end / end > > Caught error type 2 (flow rule (handle)): Failed to create flow. > > The rule setting command can be executed successfully with older dpdk > version. > > > > Could you help to check if there is a relationship between the bugs and this > patch? > > Perhaps a similar issue since testpmd now provides default values for > unspecified fields of the RSS action, that is, a default hash key with a PMD- > returned default length and the global "rss_hf" value for types (here 0 due to > --disable-rss). > > Try appending the following arguments to the RSS action: > > key_len 0 types ip udp end > > If it works, it probably means the issue was always present, it just never > showed up due to the inability to validate RSS action parameters previously. > You should make sure ixgbe supports them. > > -- > Adrien Mazarguil > 6WIND ^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [dpdk-dev] [PATCH v6 07/16] ethdev: flatten RSS configuration in flow API 2018-05-04 9:31 ` Zhao1, Wei @ 2018-05-04 9:44 ` Adrien Mazarguil 2018-05-07 7:42 ` Peng, Yuan ` (2 more replies) 0 siblings, 3 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-05-04 9:44 UTC (permalink / raw) To: Zhao1, Wei Cc: Peng, Yuan, dev, Xu, Qian Q, Liu, Yu Y, Lu, Wenzhuo, Wu, Jingjing On Fri, May 04, 2018 at 09:31:05AM +0000, Zhao1, Wei wrote: > Hi, Adrien Mazarguil > > > -----Original Message----- > > From: Adrien Mazarguil [mailto:adrien.mazarguil@6wind.com] > > Sent: Thursday, May 3, 2018 8:48 PM > > To: Peng, Yuan <yuan.peng@intel.com> > > Cc: Zhao1, Wei <wei.zhao1@intel.com>; dev@dpdk.org; Xu, Qian Q > > <qian.q.xu@intel.com>; Liu, Yu Y <yu.y.liu@intel.com>; Lu, Wenzhuo > > <wenzhuo.lu@intel.com>; Wu, Jingjing <jingjing.wu@intel.com> > > Subject: Re: [dpdk-dev] [PATCH v6 07/16] ethdev: flatten RSS configuration > > in flow API > > > > Hi Peng Yuan, > > > > Apologies for the delay, I'll answer below to the entire thread. > > > > On Sat, Apr 28, 2018 at 07:45:31AM +0000, Peng, Yuan wrote: > > > Hi,Adrien Mazarguil > > > > > > There is a bug of queue region with 18.05-rc1 The test steps are as > > > below: > > > ./usertools/dpdk-devbind.py -b igb_uio 05:00.0 > > > ./x86_64-native-linuxapp-gcc/app/testpmd -c 1ffff -n 4 -- -i --rxq=16 > > > --txq=16 > > > testpmd> port config all rss all > > > Configuration of RSS hash at ethernet port 0 failed with error (22): Invalid > > argument. > > > > I assume this issue is related rte_eth_dev_configure() which was recently > > fixed [1], right? > > > > [1] "ethdev: fix applications failure on configure" > > http://dpdk.org/ml/archives/dev/2018-May/099858.html > > > > <snip> > > > There is a bug present with 18.05-rci when I test the feature "Move > > > RSS to rte_flow" in i40e NIC The test steps are as below: > > > ./usertools/dpdk-devbind.py -b igb_uio 05:00.0 05:00.1 > > > ./x86_64-native-linuxapp-gcc/app/testpmd -c 0x1fffe -n 4 -- -i > > > --nb-cores=8 --rxq=8 --txq=8 --port-topology=chained > > > testpmd> set fwd rxonly > > > Set rxonly packet forwarding mode > > > testpmd> set verbose 1 > > > Change verbose level from 0 to 1 > > > testpmd> start > > > testpmd> flow create 0 ingress pattern end actions rss queues 0 4 7 > > > testpmd> end / end > > > Caught error type 16 (specific action): cause: 0x7fff84e33658, RSS > > > hash key too large > > > > > > The rss rule can be set successfully when I test it yesterday with older dpdk > > version without this patch. > > > > Regarding this issue, the testpmd flow command now requests hash key > > length from the PMD by default [2] if left unspecified by user. This value is > > taken from the "hash_key_size" field returned by rte_eth_dev_infos_get(). > > > > While most PMDs return 40 here, i40e returns: > > > > (I40E_PFQF_HKEY_MAX_INDEX + 1) * sizeof(uint32_t) > > /* that is, (12 + 1) * 4 => 52 */ > > > > Is this correct and really supported by i40e? Otherwise I'd suggest to fix the > > PMD as it may also confuse applications other than testpmd. > > > > Note that you should be able to revert to the old behavior with the PMD- > > specific default key by specifying a "key_len 0" parameter to the RSS action. > > > > [2] http://dpdk.org/browse/dpdk/tree/app/test- > > pmd/cmdline_flow.c?id=v18.05-rc2#n2780 > > > This is the root cause for this issue, although i40 return : > > dev_info->hash_key_size = (I40E_PFQF_HKEY_MAX_INDEX + 1) * > sizeof(uint32_t); > > that is 52 byte, but " RTE_DIM(rss_config->key)" , which is > > uint8_t key[(I40E_VFQF_HKEY_MAX_INDEX > I40E_PFQF_HKEY_MAX_INDEX ? > I40E_VFQF_HKEY_MAX_INDEX : I40E_PFQF_HKEY_MAX_INDEX) + 1 * > sizeof(uint32_t)]; /* Hash key. */ > is not 52!!! > > I think the code should be : > > uint8_t key[(I40E_VFQF_HKEY_MAX_INDEX > I40E_PFQF_HKEY_MAX_INDEX ? > I40E_VFQF_HKEY_MAX_INDEX : I40E_PFQF_HKEY_MAX_INDEX + 1) * > sizeof(uint32_t)]; /* Hash key. */ > > If you agree and permit, I WILL commit a patch to fix this bug. > Thank you! Whoops, dumb mistake, nice catch. If you take care of it, please add: Fixes: ac8d22de2394 ("ethdev: flatten RSS configuration in flow API") > > <snip> > > > There is another problem with ixgbe nic: > > > ./usertools/dpdk-devbind.py -b igb_uio 07:00.0 07:00.1 > > > ./x86_64-native-linuxapp-gcc/app/testpmd -c 0x1fffe -n 4 -- -i > > > --nb-cores=8 --rxq=8 --txq=8 --disable-rss --port-topology=chained > > > testpmd> flow create 0 ingress pattern end actions rss queues 5 6 7 > > > testpmd> end / end > > > Caught error type 2 (flow rule (handle)): Failed to create flow. > > > The rule setting command can be executed successfully with older dpdk > > version. > > > > > > Could you help to check if there is a relationship between the bugs and this > > patch? > > > > Perhaps a similar issue since testpmd now provides default values for > > unspecified fields of the RSS action, that is, a default hash key with a PMD- > > returned default length and the global "rss_hf" value for types (here 0 due to > > --disable-rss). > > > > Try appending the following arguments to the RSS action: > > > > key_len 0 types ip udp end > > > > If it works, it probably means the issue was always present, it just never > > showed up due to the inability to validate RSS action parameters previously. > > You should make sure ixgbe supports them. No comment regarding ixgbe? -- Adrien Mazarguil 6WIND ^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [dpdk-dev] [PATCH v6 07/16] ethdev: flatten RSS configuration in flow API 2018-05-04 9:44 ` Adrien Mazarguil @ 2018-05-07 7:42 ` Peng, Yuan 2018-05-07 8:11 ` Peng, Yuan 2018-05-07 8:16 ` Zhao1, Wei 2 siblings, 0 replies; 157+ messages in thread From: Peng, Yuan @ 2018-05-07 7:42 UTC (permalink / raw) To: Adrien Mazarguil, Zhao1, Wei Cc: dev, Xu, Qian Q, Liu, Yu Y, Lu, Wenzhuo, Wu, Jingjing Hi Adrien, The third problem which use ixgbe NIC: I add " key_len 0 types ip udp end " to the command "flow create 0 ingress pattern end actions rss queues 5 6 7 end / end" It shows: testpmd> flow create 0 ingress pattern end actions rss queues 5 6 7 end / key_len 0 types ip udp end / end Bad arguments testpmd> flow create 0 ingress pattern end actions rss queues 5 6 7 / key_len 0 types ip udp end / end Bad arguments testpmd> key_len 0 types ip udp end Command not found Could you show me the correct command? Thanks. Yuan. -----Original Message----- From: Adrien Mazarguil [mailto:adrien.mazarguil@6wind.com] Sent: Friday, May 4, 2018 5:45 PM To: Zhao1, Wei <wei.zhao1@intel.com> Cc: Peng, Yuan <yuan.peng@intel.com>; dev@dpdk.org; Xu, Qian Q <qian.q.xu@intel.com>; Liu, Yu Y <yu.y.liu@intel.com>; Lu, Wenzhuo <wenzhuo.lu@intel.com>; Wu, Jingjing <jingjing.wu@intel.com> Subject: Re: [dpdk-dev] [PATCH v6 07/16] ethdev: flatten RSS configuration in flow API On Fri, May 04, 2018 at 09:31:05AM +0000, Zhao1, Wei wrote: > Hi, Adrien Mazarguil > > > -----Original Message----- > > From: Adrien Mazarguil [mailto:adrien.mazarguil@6wind.com] > > Sent: Thursday, May 3, 2018 8:48 PM > > To: Peng, Yuan <yuan.peng@intel.com> > > Cc: Zhao1, Wei <wei.zhao1@intel.com>; dev@dpdk.org; Xu, Qian Q > > <qian.q.xu@intel.com>; Liu, Yu Y <yu.y.liu@intel.com>; Lu, Wenzhuo > > <wenzhuo.lu@intel.com>; Wu, Jingjing <jingjing.wu@intel.com> > > Subject: Re: [dpdk-dev] [PATCH v6 07/16] ethdev: flatten RSS > > configuration in flow API > > > > Hi Peng Yuan, > > > > Apologies for the delay, I'll answer below to the entire thread. > > > > On Sat, Apr 28, 2018 at 07:45:31AM +0000, Peng, Yuan wrote: > > > Hi,Adrien Mazarguil > > > > > > There is a bug of queue region with 18.05-rc1 The test steps are > > > as > > > below: > > > ./usertools/dpdk-devbind.py -b igb_uio 05:00.0 > > > ./x86_64-native-linuxapp-gcc/app/testpmd -c 1ffff -n 4 -- -i > > > --rxq=16 > > > --txq=16 > > > testpmd> port config all rss all > > > Configuration of RSS hash at ethernet port 0 failed with error > > > (22): Invalid > > argument. > > > > I assume this issue is related rte_eth_dev_configure() which was > > recently fixed [1], right? > > > > [1] "ethdev: fix applications failure on configure" > > http://dpdk.org/ml/archives/dev/2018-May/099858.html > > > > <snip> > > > There is a bug present with 18.05-rci when I test the feature > > > "Move RSS to rte_flow" in i40e NIC The test steps are as below: > > > ./usertools/dpdk-devbind.py -b igb_uio 05:00.0 05:00.1 > > > ./x86_64-native-linuxapp-gcc/app/testpmd -c 0x1fffe -n 4 -- -i > > > --nb-cores=8 --rxq=8 --txq=8 --port-topology=chained > > > testpmd> set fwd rxonly > > > Set rxonly packet forwarding mode > > > testpmd> set verbose 1 > > > Change verbose level from 0 to 1 > > > testpmd> start > > > testpmd> flow create 0 ingress pattern end actions rss queues 0 4 > > > testpmd> 7 end / end > > > Caught error type 16 (specific action): cause: 0x7fff84e33658, RSS > > > hash key too large > > > > > > The rss rule can be set successfully when I test it yesterday with > > > older dpdk > > version without this patch. > > > > Regarding this issue, the testpmd flow command now requests hash key > > length from the PMD by default [2] if left unspecified by user. This > > value is taken from the "hash_key_size" field returned by rte_eth_dev_infos_get(). > > > > While most PMDs return 40 here, i40e returns: > > > > (I40E_PFQF_HKEY_MAX_INDEX + 1) * sizeof(uint32_t) > > /* that is, (12 + 1) * 4 => 52 */ > > > > Is this correct and really supported by i40e? Otherwise I'd suggest > > to fix the PMD as it may also confuse applications other than testpmd. > > > > Note that you should be able to revert to the old behavior with the > > PMD- specific default key by specifying a "key_len 0" parameter to the RSS action. > > > > [2] http://dpdk.org/browse/dpdk/tree/app/test- > > pmd/cmdline_flow.c?id=v18.05-rc2#n2780 > > > This is the root cause for this issue, although i40 return : > > dev_info->hash_key_size = (I40E_PFQF_HKEY_MAX_INDEX + 1) * > sizeof(uint32_t); > > that is 52 byte, but " RTE_DIM(rss_config->key)" , which is > > uint8_t key[(I40E_VFQF_HKEY_MAX_INDEX > I40E_PFQF_HKEY_MAX_INDEX ? > I40E_VFQF_HKEY_MAX_INDEX : I40E_PFQF_HKEY_MAX_INDEX) + 1 * > sizeof(uint32_t)]; /* Hash key. */ is not 52!!! > > I think the code should be : > > uint8_t key[(I40E_VFQF_HKEY_MAX_INDEX > I40E_PFQF_HKEY_MAX_INDEX ? > I40E_VFQF_HKEY_MAX_INDEX : I40E_PFQF_HKEY_MAX_INDEX + 1) * > sizeof(uint32_t)]; /* Hash key. */ > > If you agree and permit, I WILL commit a patch to fix this bug. > Thank you! Whoops, dumb mistake, nice catch. If you take care of it, please add: Fixes: ac8d22de2394 ("ethdev: flatten RSS configuration in flow API") > > <snip> > > > There is another problem with ixgbe nic: > > > ./usertools/dpdk-devbind.py -b igb_uio 07:00.0 07:00.1 > > > ./x86_64-native-linuxapp-gcc/app/testpmd -c 0x1fffe -n 4 -- -i > > > --nb-cores=8 --rxq=8 --txq=8 --disable-rss --port-topology=chained > > > testpmd> flow create 0 ingress pattern end actions rss queues 5 6 > > > testpmd> 7 end / end > > > Caught error type 2 (flow rule (handle)): Failed to create flow. > > > The rule setting command can be executed successfully with older > > > dpdk > > version. > > > > > > Could you help to check if there is a relationship between the > > > bugs and this > > patch? > > > > Perhaps a similar issue since testpmd now provides default values > > for unspecified fields of the RSS action, that is, a default hash > > key with a PMD- returned default length and the global "rss_hf" > > value for types (here 0 due to --disable-rss). > > > > Try appending the following arguments to the RSS action: > > > > key_len 0 types ip udp end > > > > If it works, it probably means the issue was always present, it just > > never showed up due to the inability to validate RSS action parameters previously. > > You should make sure ixgbe supports them. No comment regarding ixgbe? -- Adrien Mazarguil 6WIND ^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [dpdk-dev] [PATCH v6 07/16] ethdev: flatten RSS configuration in flow API 2018-05-04 9:44 ` Adrien Mazarguil 2018-05-07 7:42 ` Peng, Yuan @ 2018-05-07 8:11 ` Peng, Yuan 2018-05-07 8:16 ` Zhao1, Wei 2 siblings, 0 replies; 157+ messages in thread From: Peng, Yuan @ 2018-05-07 8:11 UTC (permalink / raw) To: Adrien Mazarguil, Zhao1, Wei Cc: dev, Xu, Qian Q, Liu, Yu Y, Lu, Wenzhuo, Wu, Jingjing Hi Adrien, I configure the command as: testpmd> flow create 0 ingress pattern end actions rss types udp end queues 5 end / end Flow rule #0 created The rule can be set successfully. It seems like you have added several parameter to the feature, and modified the command format. testpmd> flow create 0 ingress pattern end actions rss func [TOKEN]: RSS hash function to apply level [TOKEN]: encapsulation level for "types" types [TOKEN]: specific RSS hash types key [TOKEN]: RSS hash key key_len [TOKEN]: RSS hash key length in bytes queues [TOKEN]: queue indices to use / [TOKEN]: specify next action Could you send me and Zhao Wei a user guideline? Thank you. Yuan. -----Original Message----- From: Peng, Yuan Sent: Monday, May 7, 2018 3:42 PM To: 'Adrien Mazarguil' <adrien.mazarguil@6wind.com>; Zhao1, Wei <wei.zhao1@intel.com> Cc: dev@dpdk.org; Xu, Qian Q <qian.q.xu@intel.com>; Liu, Yu Y <yu.y.liu@intel.com>; Lu, Wenzhuo <wenzhuo.lu@intel.com>; Wu, Jingjing <jingjing.wu@intel.com> Subject: RE: [dpdk-dev] [PATCH v6 07/16] ethdev: flatten RSS configuration in flow API Hi Adrien, The third problem which use ixgbe NIC: I add " key_len 0 types ip udp end " to the command "flow create 0 ingress pattern end actions rss queues 5 6 7 end / end" It shows: testpmd> flow create 0 ingress pattern end actions rss queues 5 6 7 end testpmd> / key_len 0 types ip udp end / end Bad arguments testpmd> flow create 0 ingress pattern end actions rss queues 5 6 7 / testpmd> key_len 0 types ip udp end / end Bad arguments testpmd> key_len 0 types ip udp end Command not found Could you show me the correct command? Thanks. Yuan. -----Original Message----- From: Adrien Mazarguil [mailto:adrien.mazarguil@6wind.com] Sent: Friday, May 4, 2018 5:45 PM To: Zhao1, Wei <wei.zhao1@intel.com> Cc: Peng, Yuan <yuan.peng@intel.com>; dev@dpdk.org; Xu, Qian Q <qian.q.xu@intel.com>; Liu, Yu Y <yu.y.liu@intel.com>; Lu, Wenzhuo <wenzhuo.lu@intel.com>; Wu, Jingjing <jingjing.wu@intel.com> Subject: Re: [dpdk-dev] [PATCH v6 07/16] ethdev: flatten RSS configuration in flow API On Fri, May 04, 2018 at 09:31:05AM +0000, Zhao1, Wei wrote: > Hi, Adrien Mazarguil > > > -----Original Message----- > > From: Adrien Mazarguil [mailto:adrien.mazarguil@6wind.com] > > Sent: Thursday, May 3, 2018 8:48 PM > > To: Peng, Yuan <yuan.peng@intel.com> > > Cc: Zhao1, Wei <wei.zhao1@intel.com>; dev@dpdk.org; Xu, Qian Q > > <qian.q.xu@intel.com>; Liu, Yu Y <yu.y.liu@intel.com>; Lu, Wenzhuo > > <wenzhuo.lu@intel.com>; Wu, Jingjing <jingjing.wu@intel.com> > > Subject: Re: [dpdk-dev] [PATCH v6 07/16] ethdev: flatten RSS > > configuration in flow API > > > > Hi Peng Yuan, > > > > Apologies for the delay, I'll answer below to the entire thread. > > > > On Sat, Apr 28, 2018 at 07:45:31AM +0000, Peng, Yuan wrote: > > > Hi,Adrien Mazarguil > > > > > > There is a bug of queue region with 18.05-rc1 The test steps are > > > as > > > below: > > > ./usertools/dpdk-devbind.py -b igb_uio 05:00.0 > > > ./x86_64-native-linuxapp-gcc/app/testpmd -c 1ffff -n 4 -- -i > > > --rxq=16 > > > --txq=16 > > > testpmd> port config all rss all > > > Configuration of RSS hash at ethernet port 0 failed with error > > > (22): Invalid > > argument. > > > > I assume this issue is related rte_eth_dev_configure() which was > > recently fixed [1], right? > > > > [1] "ethdev: fix applications failure on configure" > > http://dpdk.org/ml/archives/dev/2018-May/099858.html > > > > <snip> > > > There is a bug present with 18.05-rci when I test the feature > > > "Move RSS to rte_flow" in i40e NIC The test steps are as below: > > > ./usertools/dpdk-devbind.py -b igb_uio 05:00.0 05:00.1 > > > ./x86_64-native-linuxapp-gcc/app/testpmd -c 0x1fffe -n 4 -- -i > > > --nb-cores=8 --rxq=8 --txq=8 --port-topology=chained > > > testpmd> set fwd rxonly > > > Set rxonly packet forwarding mode > > > testpmd> set verbose 1 > > > Change verbose level from 0 to 1 > > > testpmd> start > > > testpmd> flow create 0 ingress pattern end actions rss queues 0 4 > > > testpmd> 7 end / end > > > Caught error type 16 (specific action): cause: 0x7fff84e33658, RSS > > > hash key too large > > > > > > The rss rule can be set successfully when I test it yesterday with > > > older dpdk > > version without this patch. > > > > Regarding this issue, the testpmd flow command now requests hash key > > length from the PMD by default [2] if left unspecified by user. This > > value is taken from the "hash_key_size" field returned by rte_eth_dev_infos_get(). > > > > While most PMDs return 40 here, i40e returns: > > > > (I40E_PFQF_HKEY_MAX_INDEX + 1) * sizeof(uint32_t) > > /* that is, (12 + 1) * 4 => 52 */ > > > > Is this correct and really supported by i40e? Otherwise I'd suggest > > to fix the PMD as it may also confuse applications other than testpmd. > > > > Note that you should be able to revert to the old behavior with the > > PMD- specific default key by specifying a "key_len 0" parameter to the RSS action. > > > > [2] http://dpdk.org/browse/dpdk/tree/app/test- > > pmd/cmdline_flow.c?id=v18.05-rc2#n2780 > > > This is the root cause for this issue, although i40 return : > > dev_info->hash_key_size = (I40E_PFQF_HKEY_MAX_INDEX + 1) * > sizeof(uint32_t); > > that is 52 byte, but " RTE_DIM(rss_config->key)" , which is > > uint8_t key[(I40E_VFQF_HKEY_MAX_INDEX > I40E_PFQF_HKEY_MAX_INDEX ? > I40E_VFQF_HKEY_MAX_INDEX : I40E_PFQF_HKEY_MAX_INDEX) + 1 * > sizeof(uint32_t)]; /* Hash key. */ is not 52!!! > > I think the code should be : > > uint8_t key[(I40E_VFQF_HKEY_MAX_INDEX > I40E_PFQF_HKEY_MAX_INDEX ? > I40E_VFQF_HKEY_MAX_INDEX : I40E_PFQF_HKEY_MAX_INDEX + 1) * > sizeof(uint32_t)]; /* Hash key. */ > > If you agree and permit, I WILL commit a patch to fix this bug. > Thank you! Whoops, dumb mistake, nice catch. If you take care of it, please add: Fixes: ac8d22de2394 ("ethdev: flatten RSS configuration in flow API") > > <snip> > > > There is another problem with ixgbe nic: > > > ./usertools/dpdk-devbind.py -b igb_uio 07:00.0 07:00.1 > > > ./x86_64-native-linuxapp-gcc/app/testpmd -c 0x1fffe -n 4 -- -i > > > --nb-cores=8 --rxq=8 --txq=8 --disable-rss --port-topology=chained > > > testpmd> flow create 0 ingress pattern end actions rss queues 5 6 > > > testpmd> 7 end / end > > > Caught error type 2 (flow rule (handle)): Failed to create flow. > > > The rule setting command can be executed successfully with older > > > dpdk > > version. > > > > > > Could you help to check if there is a relationship between the > > > bugs and this > > patch? > > > > Perhaps a similar issue since testpmd now provides default values > > for unspecified fields of the RSS action, that is, a default hash > > key with a PMD- returned default length and the global "rss_hf" > > value for types (here 0 due to --disable-rss). > > > > Try appending the following arguments to the RSS action: > > > > key_len 0 types ip udp end > > > > If it works, it probably means the issue was always present, it just > > never showed up due to the inability to validate RSS action parameters previously. > > You should make sure ixgbe supports them. No comment regarding ixgbe? -- Adrien Mazarguil 6WIND ^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [dpdk-dev] [PATCH v6 07/16] ethdev: flatten RSS configuration in flow API 2018-05-04 9:44 ` Adrien Mazarguil 2018-05-07 7:42 ` Peng, Yuan 2018-05-07 8:11 ` Peng, Yuan @ 2018-05-07 8:16 ` Zhao1, Wei 2 siblings, 0 replies; 157+ messages in thread From: Zhao1, Wei @ 2018-05-07 8:16 UTC (permalink / raw) To: Adrien Mazarguil Cc: Peng, Yuan, dev, Xu, Qian Q, Liu, Yu Y, Lu, Wenzhuo, Wu, Jingjing > -----Original Message----- > From: Adrien Mazarguil [mailto:adrien.mazarguil@6wind.com] > Sent: Friday, May 4, 2018 5:45 PM > To: Zhao1, Wei <wei.zhao1@intel.com> > Cc: Peng, Yuan <yuan.peng@intel.com>; dev@dpdk.org; Xu, Qian Q > <qian.q.xu@intel.com>; Liu, Yu Y <yu.y.liu@intel.com>; Lu, Wenzhuo > <wenzhuo.lu@intel.com>; Wu, Jingjing <jingjing.wu@intel.com> > Subject: Re: [dpdk-dev] [PATCH v6 07/16] ethdev: flatten RSS configuration > in flow API > > On Fri, May 04, 2018 at 09:31:05AM +0000, Zhao1, Wei wrote: > > Hi, Adrien Mazarguil > > > > > -----Original Message----- > > > From: Adrien Mazarguil [mailto:adrien.mazarguil@6wind.com] > > > Sent: Thursday, May 3, 2018 8:48 PM > > > To: Peng, Yuan <yuan.peng@intel.com> > > > Cc: Zhao1, Wei <wei.zhao1@intel.com>; dev@dpdk.org; Xu, Qian Q > > > <qian.q.xu@intel.com>; Liu, Yu Y <yu.y.liu@intel.com>; Lu, Wenzhuo > > > <wenzhuo.lu@intel.com>; Wu, Jingjing <jingjing.wu@intel.com> > > > Subject: Re: [dpdk-dev] [PATCH v6 07/16] ethdev: flatten RSS > > > configuration in flow API > > > > > > Hi Peng Yuan, > > > > > > Apologies for the delay, I'll answer below to the entire thread. > > > > > > On Sat, Apr 28, 2018 at 07:45:31AM +0000, Peng, Yuan wrote: > > > > Hi,Adrien Mazarguil > > > > > > > > There is a bug of queue region with 18.05-rc1 The test steps are > > > > as > > > > below: > > > > ./usertools/dpdk-devbind.py -b igb_uio 05:00.0 > > > > ./x86_64-native-linuxapp-gcc/app/testpmd -c 1ffff -n 4 -- -i > > > > --rxq=16 > > > > --txq=16 > > > > testpmd> port config all rss all > > > > Configuration of RSS hash at ethernet port 0 failed with error > > > > (22): Invalid > > > argument. > > > > > > I assume this issue is related rte_eth_dev_configure() which was > > > recently fixed [1], right? > > > > > > [1] "ethdev: fix applications failure on configure" > > > http://dpdk.org/ml/archives/dev/2018-May/099858.html > > > > > > <snip> > > > > There is a bug present with 18.05-rci when I test the feature > > > > "Move RSS to rte_flow" in i40e NIC The test steps are as below: > > > > ./usertools/dpdk-devbind.py -b igb_uio 05:00.0 05:00.1 > > > > ./x86_64-native-linuxapp-gcc/app/testpmd -c 0x1fffe -n 4 -- -i > > > > --nb-cores=8 --rxq=8 --txq=8 --port-topology=chained > > > > testpmd> set fwd rxonly > > > > Set rxonly packet forwarding mode > > > > testpmd> set verbose 1 > > > > Change verbose level from 0 to 1 > > > > testpmd> start > > > > testpmd> flow create 0 ingress pattern end actions rss queues 0 4 > > > > testpmd> 7 end / end > > > > Caught error type 16 (specific action): cause: 0x7fff84e33658, RSS > > > > hash key too large > > > > > > > > The rss rule can be set successfully when I test it yesterday with > > > > older dpdk > > > version without this patch. > > > > > > Regarding this issue, the testpmd flow command now requests hash key > > > length from the PMD by default [2] if left unspecified by user. This > > > value is taken from the "hash_key_size" field returned by > rte_eth_dev_infos_get(). > > > > > > While most PMDs return 40 here, i40e returns: > > > > > > (I40E_PFQF_HKEY_MAX_INDEX + 1) * sizeof(uint32_t) > > > /* that is, (12 + 1) * 4 => 52 */ > > > > > > Is this correct and really supported by i40e? Otherwise I'd suggest > > > to fix the PMD as it may also confuse applications other than testpmd. > > > > > > Note that you should be able to revert to the old behavior with the > > > PMD- specific default key by specifying a "key_len 0" parameter to the > RSS action. > > > > > > [2] http://dpdk.org/browse/dpdk/tree/app/test- > > > pmd/cmdline_flow.c?id=v18.05-rc2#n2780 > > > > > > This is the root cause for this issue, although i40 return : > > > > dev_info->hash_key_size = (I40E_PFQF_HKEY_MAX_INDEX + 1) * > > sizeof(uint32_t); > > > > that is 52 byte, but " RTE_DIM(rss_config->key)" , which is > > > > uint8_t key[(I40E_VFQF_HKEY_MAX_INDEX > > I40E_PFQF_HKEY_MAX_INDEX ? > > I40E_VFQF_HKEY_MAX_INDEX : > I40E_PFQF_HKEY_MAX_INDEX) + 1 * > > sizeof(uint32_t)]; /* Hash key. */ is not 52!!! > > > > I think the code should be : > > > > uint8_t key[(I40E_VFQF_HKEY_MAX_INDEX > > I40E_PFQF_HKEY_MAX_INDEX ? > > I40E_VFQF_HKEY_MAX_INDEX : > I40E_PFQF_HKEY_MAX_INDEX + 1) * > > sizeof(uint32_t)]; /* Hash key. */ > > > > If you agree and permit, I WILL commit a patch to fix this bug. > > Thank you! > > Whoops, dumb mistake, nice catch. If you take care of it, please add: > > Fixes: ac8d22de2394 ("ethdev: flatten RSS configuration in flow API") Thank you, a fix patch has been commit. > > > > <snip> > > > > There is another problem with ixgbe nic: > > > > ./usertools/dpdk-devbind.py -b igb_uio 07:00.0 07:00.1 > > > > ./x86_64-native-linuxapp-gcc/app/testpmd -c 0x1fffe -n 4 -- -i > > > > --nb-cores=8 --rxq=8 --txq=8 --disable-rss --port-topology=chained > > > > testpmd> flow create 0 ingress pattern end actions rss queues 5 6 > > > > testpmd> 7 end / end > > > > Caught error type 2 (flow rule (handle)): Failed to create flow. > > > > The rule setting command can be executed successfully with older > > > > dpdk > > > version. > > > > > > > > Could you help to check if there is a relationship between the > > > > bugs and this > > > patch? > > > > > > Perhaps a similar issue since testpmd now provides default values > > > for unspecified fields of the RSS action, that is, a default hash > > > key with a PMD- returned default length and the global "rss_hf" > > > value for types (here 0 due to --disable-rss). > > > > > > Try appending the following arguments to the RSS action: > > > > > > key_len 0 types ip udp end > > > > > > If it works, it probably means the issue was always present, it just > > > never showed up due to the inability to validate RSS action parameters > previously. > > > You should make sure ixgbe supports them. > > No comment regarding ixgbe? This seems to be caused by new command input methord for rte_flow. I have try " flow create 2 ingress pattern end actions rss types udp tcp end queues 5 6 7 end / end " This can be input well. I have tell Peng yuan about this. > > -- > Adrien Mazarguil > 6WIND ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v6 08/16] ethdev: add hash function to RSS flow API action 2018-04-25 15:27 ` [dpdk-dev] [PATCH v6 00/16] Flow API overhaul for switch offloads Adrien Mazarguil ` (6 preceding siblings ...) 2018-04-25 15:27 ` [dpdk-dev] [PATCH v6 07/16] ethdev: flatten RSS configuration in " Adrien Mazarguil @ 2018-04-25 15:27 ` Adrien Mazarguil 2018-04-25 15:27 ` [dpdk-dev] [PATCH v6 09/16] ethdev: add encap level " Adrien Mazarguil ` (8 subsequent siblings) 16 siblings, 0 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-25 15:27 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev Cc: Wenzhuo Lu, Jingjing Wu, Beilei Xing, Qi Zhang, Konstantin Ananyev, Nelio Laranjeiro, Yongseok Koh, Andrew Rybchenko, Pascal Mazon By definition, RSS involves some kind of hash algorithm, usually Toeplitz. Until now it could not be modified on a flow rule basis and PMDs had to always assume RTE_ETH_HASH_FUNCTION_DEFAULT, which remains the default behavior when unspecified (0). This breaks ABI compatibility for the following public functions: - rte_flow_copy() - rte_flow_create() - rte_flow_query() - rte_flow_validate() Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Acked-by: Andrew Rybchenko <arybchenko@solarflare.com> Cc: Ferruh Yigit <ferruh.yigit@intel.com> Cc: Thomas Monjalon <thomas@monjalon.net> Cc: Wenzhuo Lu <wenzhuo.lu@intel.com> Cc: Jingjing Wu <jingjing.wu@intel.com> Cc: Beilei Xing <beilei.xing@intel.com> Cc: Qi Zhang <qi.z.zhang@intel.com> Cc: Konstantin Ananyev <konstantin.ananyev@intel.com> Cc: Nelio Laranjeiro <nelio.laranjeiro@6wind.com> Cc: Yongseok Koh <yskoh@mellanox.com> Cc: Andrew Rybchenko <arybchenko@solarflare.com> Cc: Pascal Mazon <pascal.mazon@6wind.com> --- v6 changes: Updated API changes section in release notes. v3 changes: - Although RTE_ETH_HASH_FUNCTION_DEFAULT is defined as 0, made comparisons more explicit where doing so would clarify the code. - Updated sfc to include Toeplitz as the other allowed value. Both according to Andrew's suggestions [1]. [1] http://dpdk.org/ml/archives/dev/2018-April/095840.html --- app/test-pmd/cmdline_flow.c | 72 ++++++++++++++++++++++++ app/test-pmd/config.c | 1 + doc/guides/prog_guide/rte_flow.rst | 2 + doc/guides/rel_notes/release_18_05.rst | 3 +- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 3 + drivers/net/e1000/igb_flow.c | 4 ++ drivers/net/e1000/igb_rxtx.c | 4 +- drivers/net/i40e/i40e_ethdev.c | 4 +- drivers/net/i40e/i40e_flow.c | 4 ++ drivers/net/ixgbe/ixgbe_flow.c | 4 ++ drivers/net/ixgbe/ixgbe_rxtx.c | 4 +- drivers/net/mlx4/mlx4_flow.c | 7 +++ drivers/net/mlx5/mlx5_flow.c | 13 +++++ drivers/net/sfc/sfc_flow.c | 8 +++ drivers/net/tap/tap_flow.c | 6 ++ lib/librte_ether/rte_flow.c | 1 + lib/librte_ether/rte_flow.h | 2 + 17 files changed, 138 insertions(+), 4 deletions(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index c9c2c3ad9..7436e0356 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -14,6 +14,7 @@ #include <sys/socket.h> #include <rte_common.h> +#include <rte_eth_ctrl.h> #include <rte_ethdev.h> #include <rte_byteorder.h> #include <cmdline_parse.h> @@ -165,6 +166,10 @@ enum index { ACTION_DROP, ACTION_COUNT, ACTION_RSS, + ACTION_RSS_FUNC, + ACTION_RSS_FUNC_DEFAULT, + ACTION_RSS_FUNC_TOEPLITZ, + ACTION_RSS_FUNC_SIMPLE_XOR, ACTION_RSS_TYPES, ACTION_RSS_TYPE, ACTION_RSS_KEY, @@ -632,6 +637,7 @@ static const enum index action_queue[] = { }; static const enum index action_rss[] = { + ACTION_RSS_FUNC, ACTION_RSS_TYPES, ACTION_RSS_KEY, ACTION_RSS_KEY_LEN, @@ -666,6 +672,9 @@ static int parse_vc_conf(struct context *, const struct token *, static int parse_vc_action_rss(struct context *, const struct token *, const char *, unsigned int, void *, unsigned int); +static int parse_vc_action_rss_func(struct context *, const struct token *, + const char *, unsigned int, void *, + unsigned int); static int parse_vc_action_rss_type(struct context *, const struct token *, const char *, unsigned int, void *, unsigned int); @@ -1584,6 +1593,29 @@ static const struct token token_list[] = { .next = NEXT(action_rss), .call = parse_vc_action_rss, }, + [ACTION_RSS_FUNC] = { + .name = "func", + .help = "RSS hash function to apply", + .next = NEXT(action_rss, + NEXT_ENTRY(ACTION_RSS_FUNC_DEFAULT, + ACTION_RSS_FUNC_TOEPLITZ, + ACTION_RSS_FUNC_SIMPLE_XOR)), + }, + [ACTION_RSS_FUNC_DEFAULT] = { + .name = "default", + .help = "default hash function", + .call = parse_vc_action_rss_func, + }, + [ACTION_RSS_FUNC_TOEPLITZ] = { + .name = "toeplitz", + .help = "Toeplitz hash function", + .call = parse_vc_action_rss_func, + }, + [ACTION_RSS_FUNC_SIMPLE_XOR] = { + .name = "simple_xor", + .help = "simple XOR hash function", + .call = parse_vc_action_rss_func, + }, [ACTION_RSS_TYPES] = { .name = "types", .help = "specific RSS hash types", @@ -2074,6 +2106,7 @@ parse_vc_action_rss(struct context *ctx, const struct token *token, action_rss_data = ctx->object; *action_rss_data = (struct action_rss_data){ .conf = (struct rte_flow_action_rss){ + .func = RTE_ETH_HASH_FUNCTION_DEFAULT, .types = rss_hf, .key_len = sizeof(action_rss_data->key), .queue_num = RTE_MIN(nb_rxq, ACTION_RSS_QUEUE_NUM), @@ -2099,6 +2132,45 @@ parse_vc_action_rss(struct context *ctx, const struct token *token, } /** + * Parse func field for RSS action. + * + * The RTE_ETH_HASH_FUNCTION_* value to assign is derived from the + * ACTION_RSS_FUNC_* index that called this function. + */ +static int +parse_vc_action_rss_func(struct context *ctx, const struct token *token, + const char *str, unsigned int len, + void *buf, unsigned int size) +{ + struct action_rss_data *action_rss_data; + enum rte_eth_hash_function func; + + (void)buf; + (void)size; + /* Token name must match. */ + if (parse_default(ctx, token, str, len, NULL, 0) < 0) + return -1; + switch (ctx->curr) { + case ACTION_RSS_FUNC_DEFAULT: + func = RTE_ETH_HASH_FUNCTION_DEFAULT; + break; + case ACTION_RSS_FUNC_TOEPLITZ: + func = RTE_ETH_HASH_FUNCTION_TOEPLITZ; + break; + case ACTION_RSS_FUNC_SIMPLE_XOR: + func = RTE_ETH_HASH_FUNCTION_SIMPLE_XOR; + break; + default: + return -1; + } + if (!ctx->object) + return len; + action_rss_data = ctx->object; + action_rss_data->conf.func = func; + return len; +} + +/** * Parse type field for RSS action. * * Valid tokens are type field names and the "end" token. diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 4700dd674..89dc3c9b7 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -1117,6 +1117,7 @@ flow_action_conf_copy(void *buf, const struct rte_flow_action *action) off = 0; if (dst.rss) *dst.rss = (struct rte_flow_action_rss){ + .func = src.rss->func, .types = src.rss->types, .key_len = src.rss->key_len, .queue_num = src.rss->queue_num, diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index cf252eeba..e0c68495c 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -1318,6 +1318,8 @@ field only, both can be requested simultaneously. +---------------+---------------------------------------------+ | Field | Value | +===============+=============================================+ + | ``func`` | RSS hash function to apply | + +---------------+---------------------------------------------+ | ``types`` | specific RSS hash types (see ``ETH_RSS_*``) | +---------------+---------------------------------------------+ | ``key_len`` | hash key length in bytes | diff --git a/doc/guides/rel_notes/release_18_05.rst b/doc/guides/rel_notes/release_18_05.rst index b702ac66a..edf53c031 100644 --- a/doc/guides/rel_notes/release_18_05.rst +++ b/doc/guides/rel_notes/release_18_05.rst @@ -260,7 +260,8 @@ API Changes (``rss_conf->rss_key`` => ``key``, ``rss_conf->rss_key_len`` => ``key_len``, ``rss_conf->rss_hf`` => ``types``, - ``num`` => ``queue_num``). + ``num`` => ``queue_num``), and the addition of missing RSS parameters + (``func`` for RSS hash function to apply). ABI Changes diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index a12e0267a..12933ef1e 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3422,6 +3422,9 @@ This section lists supported actions and their attributes, if any. - ``rss``: spread packets among several queues. + - ``func {hash function}``: RSS hash function to apply, allowed tokens are + the same as `set_hash_global_config`_. + - ``types [{RSS hash type} [...]] end``: specific RSS hash types, allowed tokens are the same as `set_hash_input_set`_, except that an empty list does not disable RSS but instead requests unspecified "best-effort" diff --git a/drivers/net/e1000/igb_flow.c b/drivers/net/e1000/igb_flow.c index 8dc5f75f2..82307ec5d 100644 --- a/drivers/net/e1000/igb_flow.c +++ b/drivers/net/e1000/igb_flow.c @@ -1310,6 +1310,10 @@ igb_parse_rss_filter(struct rte_eth_dev *dev, } } + if (rss->func != RTE_ETH_HASH_FUNCTION_DEFAULT) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, + "non-default RSS hash functions are not supported"); if (rss->key_len && rss->key_len != RTE_DIM(rss_conf->key)) return rte_flow_error_set (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, diff --git a/drivers/net/e1000/igb_rxtx.c b/drivers/net/e1000/igb_rxtx.c index 45bb3455c..d5c1cd3d3 100644 --- a/drivers/net/e1000/igb_rxtx.c +++ b/drivers/net/e1000/igb_rxtx.c @@ -2905,6 +2905,7 @@ igb_rss_conf_init(struct igb_rte_flow_rss_conf *out, in->queue_num > RTE_DIM(out->queue)) return -EINVAL; out->conf = (struct rte_flow_action_rss){ + .func = in->func, .types = in->types, .key_len = in->key_len, .queue_num = in->queue_num, @@ -2919,7 +2920,8 @@ int igb_action_rss_same(const struct rte_flow_action_rss *comp, const struct rte_flow_action_rss *with) { - return (comp->types == with->types && + return (comp->func == with->func && + comp->types == with->types && comp->key_len == with->key_len && comp->queue_num == with->queue_num && !memcmp(comp->key, with->key, with->key_len) && diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index 50e77901c..cf19649dc 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c @@ -12190,6 +12190,7 @@ i40e_rss_conf_init(struct i40e_rte_flow_rss_conf *out, in->queue_num > RTE_DIM(out->queue)) return -EINVAL; out->conf = (struct rte_flow_action_rss){ + .func = in->func, .types = in->types, .key_len = in->key_len, .queue_num = in->queue_num, @@ -12204,7 +12205,8 @@ int i40e_action_rss_same(const struct rte_flow_action_rss *comp, const struct rte_flow_action_rss *with) { - return (comp->types == with->types && + return (comp->func == with->func && + comp->types == with->types && comp->key_len == with->key_len && comp->queue_num == with->queue_num && !memcmp(comp->key, with->key, with->key_len) && diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c index ec6231003..897989bbd 100644 --- a/drivers/net/i40e/i40e_flow.c +++ b/drivers/net/i40e/i40e_flow.c @@ -4376,6 +4376,10 @@ i40e_flow_parse_rss_action(struct rte_eth_dev *dev, } /* Parse RSS related parameters from configuration */ + if (rss->func != RTE_ETH_HASH_FUNCTION_DEFAULT) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, + "non-default RSS hash functions are not supported"); if (rss->key_len && rss->key_len > RTE_DIM(rss_config->key)) return rte_flow_error_set (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, diff --git a/drivers/net/ixgbe/ixgbe_flow.c b/drivers/net/ixgbe/ixgbe_flow.c index 4e31c7c56..00d975b93 100644 --- a/drivers/net/ixgbe/ixgbe_flow.c +++ b/drivers/net/ixgbe/ixgbe_flow.c @@ -2779,6 +2779,10 @@ ixgbe_parse_rss_filter(struct rte_eth_dev *dev, } } + if (rss->func != RTE_ETH_HASH_FUNCTION_DEFAULT) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, + "non-default RSS hash functions are not supported"); if (rss->key_len && rss->key_len != RTE_DIM(rss_conf->key)) return rte_flow_error_set (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, diff --git a/drivers/net/ixgbe/ixgbe_rxtx.c b/drivers/net/ixgbe/ixgbe_rxtx.c index 9fbd7dbd7..e91e7f746 100644 --- a/drivers/net/ixgbe/ixgbe_rxtx.c +++ b/drivers/net/ixgbe/ixgbe_rxtx.c @@ -5683,6 +5683,7 @@ ixgbe_rss_conf_init(struct ixgbe_rte_flow_rss_conf *out, in->queue_num > RTE_DIM(out->queue)) return -EINVAL; out->conf = (struct rte_flow_action_rss){ + .func = in->func, .types = in->types, .key_len = in->key_len, .queue_num = in->queue_num, @@ -5697,7 +5698,8 @@ int ixgbe_action_rss_same(const struct rte_flow_action_rss *comp, const struct rte_flow_action_rss *with) { - return (comp->types == with->types && + return (comp->func == with->func && + comp->types == with->types && comp->key_len == with->key_len && comp->queue_num == with->queue_num && !memcmp(comp->key, with->key, with->key_len) && diff --git a/drivers/net/mlx4/mlx4_flow.c b/drivers/net/mlx4/mlx4_flow.c index dd86e4ce7..002003235 100644 --- a/drivers/net/mlx4/mlx4_flow.c +++ b/drivers/net/mlx4/mlx4_flow.c @@ -790,6 +790,12 @@ mlx4_flow_prepare(struct priv *priv, " of the context size"; goto exit_action_not_supported; } + if (rss->func && + rss->func != RTE_ETH_HASH_FUNCTION_TOEPLITZ) { + msg = "the only supported RSS hash function" + " is Toeplitz"; + goto exit_action_not_supported; + } rte_errno = 0; fields = mlx4_conv_rss_types(priv, rss->types); if (fields == (uint64_t)-1 && rte_errno) { @@ -1283,6 +1289,7 @@ mlx4_flow_internal(struct priv *priv, struct rte_flow_error *error) rte_align32pow2(priv->dev->data->nb_rx_queues + 1) >> 1; uint16_t queue[queues]; struct rte_flow_action_rss action_rss = { + .func = RTE_ETH_HASH_FUNCTION_DEFAULT, .types = -1, .key_len = MLX4_RSS_HASH_KEY_SIZE, .queue_num = queues, diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index af8853e09..093e3a228 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -18,6 +18,7 @@ #endif #include <rte_common.h> +#include <rte_eth_ctrl.h> #include <rte_ethdev_driver.h> #include <rte_flow.h> #include <rte_flow_driver.h> @@ -642,6 +643,15 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, if (overlap & FATE) goto exit_action_overlap; overlap |= FATE; + if (rss->func && + rss->func != RTE_ETH_HASH_FUNCTION_TOEPLITZ) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION, + actions, + "the only supported RSS hash" + " function is Toeplitz"); + return -rte_errno; + } if (rss->types & MLX5_RSS_HF_MASK) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, @@ -691,6 +701,7 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, } } parser->rss_conf = (struct rte_flow_action_rss){ + .func = RTE_ETH_HASH_FUNCTION_DEFAULT, .types = rss->types, .key_len = rss_key_len, .queue_num = rss->queue_num, @@ -1925,6 +1936,7 @@ mlx5_flow_list_create(struct rte_eth_dev *dev, /* Copy configuration. */ flow->queues = (uint16_t (*)[])(flow + 1); flow->rss_conf = (struct rte_flow_action_rss){ + .func = RTE_ETH_HASH_FUNCTION_DEFAULT, .types = parser.rss_conf.types, .key_len = parser.rss_conf.key_len, .queue_num = parser.rss_conf.queue_num, @@ -2439,6 +2451,7 @@ mlx5_ctrl_flow_vlan(struct rte_eth_dev *dev, }; uint16_t queue[priv->reta_idx_n]; struct rte_flow_action_rss action_rss = { + .func = RTE_ETH_HASH_FUNCTION_DEFAULT, .types = priv->rss_conf.rss_hf, .key_len = priv->rss_conf.rss_key_len, .queue_num = priv->reta_idx_n, diff --git a/drivers/net/sfc/sfc_flow.c b/drivers/net/sfc/sfc_flow.c index 1a2c0299c..779edad0c 100644 --- a/drivers/net/sfc/sfc_flow.c +++ b/drivers/net/sfc/sfc_flow.c @@ -1261,6 +1261,14 @@ sfc_flow_parse_rss(struct sfc_adapter *sa, rxq_hw_index_max = rxq->hw_index; } + switch (rss->func) { + case RTE_ETH_HASH_FUNCTION_DEFAULT: + case RTE_ETH_HASH_FUNCTION_TOEPLITZ: + break; + default: + return -EINVAL; + } + if ((rss->types & ~SFC_RSS_OFFLOADS) != 0) return -EINVAL; diff --git a/drivers/net/tap/tap_flow.c b/drivers/net/tap/tap_flow.c index 67146aaba..845031a31 100644 --- a/drivers/net/tap/tap_flow.c +++ b/drivers/net/tap/tap_flow.c @@ -2055,6 +2055,12 @@ static int rss_add_actions(struct rte_flow *flow, struct pmd_internals *pmd, struct rss_key rss_entry = { .hash_fields = 0, .key_size = 0 }; + /* Check supported hash functions */ + if (rss->func != RTE_ETH_HASH_FUNCTION_DEFAULT) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, + "non-default RSS hash functions are not supported"); + /* Get a new map key for a new RSS rule */ err = bpf_rss_key(KEY_CMD_GET, &flow->key_idx); if (err < 0) { diff --git a/lib/librte_ether/rte_flow.c b/lib/librte_ether/rte_flow.c index cc7819b6a..a2b51f1e0 100644 --- a/lib/librte_ether/rte_flow.c +++ b/lib/librte_ether/rte_flow.c @@ -330,6 +330,7 @@ flow_action_conf_copy(void *buf, const struct rte_flow_action *action) off = 0; if (dst.rss) *dst.rss = (struct rte_flow_action_rss){ + .func = src.rss->func, .types = src.rss->types, .key_len = src.rss->key_len, .queue_num = src.rss->queue_num, diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index bbc408fa6..97d7d3594 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -19,6 +19,7 @@ #include <rte_arp.h> #include <rte_ether.h> +#include <rte_eth_ctrl.h> #include <rte_icmp.h> #include <rte_ip.h> #include <rte_sctp.h> @@ -1044,6 +1045,7 @@ struct rte_flow_query_count { * both can be requested simultaneously. */ struct rte_flow_action_rss { + enum rte_eth_hash_function func; /**< RSS hash function to apply. */ uint64_t types; /**< Specific RSS hash types (see ETH_RSS_*). */ uint32_t key_len; /**< Hash key length in bytes. */ uint32_t queue_num; /**< Number of entries in @p queue. */ -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v6 09/16] ethdev: add encap level to RSS flow API action 2018-04-25 15:27 ` [dpdk-dev] [PATCH v6 00/16] Flow API overhaul for switch offloads Adrien Mazarguil ` (7 preceding siblings ...) 2018-04-25 15:27 ` [dpdk-dev] [PATCH v6 08/16] ethdev: add hash function to RSS flow API action Adrien Mazarguil @ 2018-04-25 15:27 ` Adrien Mazarguil 2018-04-25 15:27 ` [dpdk-dev] [PATCH v6 10/16] ethdev: fix TPID handling in flow API Adrien Mazarguil ` (7 subsequent siblings) 16 siblings, 0 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-25 15:27 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev Cc: Xueming Li, Wenzhuo Lu, Jingjing Wu, Beilei Xing, Qi Zhang, Konstantin Ananyev, Nelio Laranjeiro, Yongseok Koh, Andrew Rybchenko, Pascal Mazon RSS hash types (ETH_RSS_* macros defined in rte_ethdev.h) describe the protocol header fields of a packet that must be taken into account while computing RSS. When facing encapsulated (e.g. tunneled) packets, there is an ambiguity as to whether these should apply to inner or outer packets. Applications need the ability to tell exactly "where" RSS must be performed. This is addressed by adding encapsulation level information to the RSS flow action. Its default value is 0 and stands for the usual unspecified behavior. Other values provide a specific encapsulation level. Contrary to the change announced by commit 676b605182a5 ("doc: announce ethdev API change for RSS configuration"), this patch does not affect struct rte_eth_rss_conf but struct rte_flow_action_rss as the former is not used anymore by the RSS flow action. ABI impact is therefore limited to rte_flow. This breaks ABI compatibility for the following public functions: - rte_flow_copy() - rte_flow_create() - rte_flow_query() - rte_flow_validate() Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Acked-by: Andrew Rybchenko <arybchenko@solarflare.com> Cc: Xueming Li <xuemingl@mellanox.com> Cc: Ferruh Yigit <ferruh.yigit@intel.com> Cc: Thomas Monjalon <thomas@monjalon.net> Cc: Wenzhuo Lu <wenzhuo.lu@intel.com> Cc: Jingjing Wu <jingjing.wu@intel.com> Cc: Beilei Xing <beilei.xing@intel.com> Cc: Qi Zhang <qi.z.zhang@intel.com> Cc: Konstantin Ananyev <konstantin.ananyev@intel.com> Cc: Nelio Laranjeiro <nelio.laranjeiro@6wind.com> Cc: Yongseok Koh <yskoh@mellanox.com> Cc: Andrew Rybchenko <arybchenko@solarflare.com> Cc: Pascal Mazon <pascal.mazon@6wind.com> --- v6 changes: - Removed deprecation notice for RSS configuration structure in this patch instead of Xueming's series [1]. - Updated API changes section in release notes. [1] http://dpdk.org/ml/archives/dev/2018-April/098670.html --- app/test-pmd/cmdline_flow.c | 13 ++++++++++++ app/test-pmd/config.c | 1 + doc/guides/prog_guide/rte_flow.rst | 24 ++++++++++++++++++++++ doc/guides/rel_notes/deprecation.rst | 4 ---- doc/guides/rel_notes/release_18_05.rst | 3 ++- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 2 ++ drivers/net/e1000/igb_flow.c | 4 ++++ drivers/net/e1000/igb_rxtx.c | 2 ++ drivers/net/i40e/i40e_ethdev.c | 2 ++ drivers/net/i40e/i40e_flow.c | 4 ++++ drivers/net/ixgbe/ixgbe_flow.c | 4 ++++ drivers/net/ixgbe/ixgbe_rxtx.c | 2 ++ drivers/net/mlx4/mlx4_flow.c | 6 ++++++ drivers/net/mlx5/mlx5_flow.c | 11 ++++++++++ drivers/net/sfc/sfc_flow.c | 3 +++ drivers/net/tap/tap_flow.c | 6 +++++- lib/librte_ether/rte_flow.c | 1 + lib/librte_ether/rte_flow.h | 26 ++++++++++++++++++++++++ 18 files changed, 112 insertions(+), 6 deletions(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 7436e0356..976fde7cd 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -167,6 +167,7 @@ enum index { ACTION_COUNT, ACTION_RSS, ACTION_RSS_FUNC, + ACTION_RSS_LEVEL, ACTION_RSS_FUNC_DEFAULT, ACTION_RSS_FUNC_TOEPLITZ, ACTION_RSS_FUNC_SIMPLE_XOR, @@ -638,6 +639,7 @@ static const enum index action_queue[] = { static const enum index action_rss[] = { ACTION_RSS_FUNC, + ACTION_RSS_LEVEL, ACTION_RSS_TYPES, ACTION_RSS_KEY, ACTION_RSS_KEY_LEN, @@ -1616,6 +1618,16 @@ static const struct token token_list[] = { .help = "simple XOR hash function", .call = parse_vc_action_rss_func, }, + [ACTION_RSS_LEVEL] = { + .name = "level", + .help = "encapsulation level for \"types\"", + .next = NEXT(action_rss, NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY_ARB + (offsetof(struct action_rss_data, conf) + + offsetof(struct rte_flow_action_rss, level), + sizeof(((struct rte_flow_action_rss *)0)-> + level))), + }, [ACTION_RSS_TYPES] = { .name = "types", .help = "specific RSS hash types", @@ -2107,6 +2119,7 @@ parse_vc_action_rss(struct context *ctx, const struct token *token, *action_rss_data = (struct action_rss_data){ .conf = (struct rte_flow_action_rss){ .func = RTE_ETH_HASH_FUNCTION_DEFAULT, + .level = 0, .types = rss_hf, .key_len = sizeof(action_rss_data->key), .queue_num = RTE_MIN(nb_rxq, ACTION_RSS_QUEUE_NUM), diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 89dc3c9b7..4b121aa79 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -1118,6 +1118,7 @@ flow_action_conf_copy(void *buf, const struct rte_flow_action *action) if (dst.rss) *dst.rss = (struct rte_flow_action_rss){ .func = src.rss->func, + .level = src.rss->level, .types = src.rss->types, .key_len = src.rss->key_len, .queue_num = src.rss->queue_num, diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index e0c68495c..1a09e8a0f 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -1311,6 +1311,28 @@ Note: RSS hash result is stored in the ``hash.rss`` mbuf field which overlaps ``hash.fdir.lo``. Since `Action: MARK`_ sets the ``hash.fdir.hi`` field only, both can be requested simultaneously. +Also, regarding packet encapsulation ``level``: + +- ``0`` requests the default behavior. Depending on the packet type, it can + mean outermost, innermost, anything in between or even no RSS. + + It basically stands for the innermost encapsulation level RSS can be + performed on according to PMD and device capabilities. + +- ``1`` requests RSS to be performed on the outermost packet encapsulation + level. + +- ``2`` and subsequent values request RSS to be performed on the specified + inner packet encapsulation level, from outermost to innermost (lower to + higher values). + +Values other than ``0`` are not necessarily supported. + +Requesting a specific RSS level on unrecognized traffic results in undefined +behavior. For predictable results, it is recommended to make the flow rule +pattern match packet headers up to the requested encapsulation level so that +only matching traffic goes through. + .. _table_rte_flow_action_rss: .. table:: RSS @@ -1320,6 +1342,8 @@ field only, both can be requested simultaneously. +===============+=============================================+ | ``func`` | RSS hash function to apply | +---------------+---------------------------------------------+ + | ``level`` | encapsulation level for ``types`` | + +---------------+---------------------------------------------+ | ``types`` | specific RSS hash types (see ``ETH_RSS_*``) | +---------------+---------------------------------------------+ | ``key_len`` | hash key length in bytes | diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst index bce97a2a9..7ed890871 100644 --- a/doc/guides/rel_notes/deprecation.rst +++ b/doc/guides/rel_notes/deprecation.rst @@ -71,10 +71,6 @@ Deprecation Notices Target release for removal of the legacy API will be defined once most PMDs have switched to rte_flow. -* ethdev: A new rss level field planned in 18.05. - The new API add rss_level field to ``rte_eth_rss_conf`` to enable a choice - of RSS hash calculation on outer or inner header of tunneled packet. - * ethdev: A work is being planned for 18.05 to expose VF port representors as a mean to perform control and data path operation on the different VFs. As VF representor is an ethdev port, new fields are needed in order to map diff --git a/doc/guides/rel_notes/release_18_05.rst b/doc/guides/rel_notes/release_18_05.rst index edf53c031..e1419f925 100644 --- a/doc/guides/rel_notes/release_18_05.rst +++ b/doc/guides/rel_notes/release_18_05.rst @@ -261,7 +261,8 @@ API Changes ``rss_conf->rss_key_len`` => ``key_len``, ``rss_conf->rss_hf`` => ``types``, ``num`` => ``queue_num``), and the addition of missing RSS parameters - (``func`` for RSS hash function to apply). + (``func`` for RSS hash function to apply and ``level`` for the + encapsulation level). ABI Changes diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index 12933ef1e..c5e399f3b 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3425,6 +3425,8 @@ This section lists supported actions and their attributes, if any. - ``func {hash function}``: RSS hash function to apply, allowed tokens are the same as `set_hash_global_config`_. + - ``level {unsigned}``: encapsulation level for ``types``. + - ``types [{RSS hash type} [...]] end``: specific RSS hash types, allowed tokens are the same as `set_hash_input_set`_, except that an empty list does not disable RSS but instead requests unspecified "best-effort" diff --git a/drivers/net/e1000/igb_flow.c b/drivers/net/e1000/igb_flow.c index 82307ec5d..d1c0b4b8d 100644 --- a/drivers/net/e1000/igb_flow.c +++ b/drivers/net/e1000/igb_flow.c @@ -1314,6 +1314,10 @@ igb_parse_rss_filter(struct rte_eth_dev *dev, return rte_flow_error_set (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, "non-default RSS hash functions are not supported"); + if (rss->level) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, + "a nonzero RSS encapsulation level is not supported"); if (rss->key_len && rss->key_len != RTE_DIM(rss_conf->key)) return rte_flow_error_set (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, diff --git a/drivers/net/e1000/igb_rxtx.c b/drivers/net/e1000/igb_rxtx.c index d5c1cd3d3..a3776a0d7 100644 --- a/drivers/net/e1000/igb_rxtx.c +++ b/drivers/net/e1000/igb_rxtx.c @@ -2906,6 +2906,7 @@ igb_rss_conf_init(struct igb_rte_flow_rss_conf *out, return -EINVAL; out->conf = (struct rte_flow_action_rss){ .func = in->func, + .level = in->level, .types = in->types, .key_len = in->key_len, .queue_num = in->queue_num, @@ -2921,6 +2922,7 @@ igb_action_rss_same(const struct rte_flow_action_rss *comp, const struct rte_flow_action_rss *with) { return (comp->func == with->func && + comp->level == with->level && comp->types == with->types && comp->key_len == with->key_len && comp->queue_num == with->queue_num && diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index cf19649dc..685b9ca25 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c @@ -12191,6 +12191,7 @@ i40e_rss_conf_init(struct i40e_rte_flow_rss_conf *out, return -EINVAL; out->conf = (struct rte_flow_action_rss){ .func = in->func, + .level = in->level, .types = in->types, .key_len = in->key_len, .queue_num = in->queue_num, @@ -12206,6 +12207,7 @@ i40e_action_rss_same(const struct rte_flow_action_rss *comp, const struct rte_flow_action_rss *with) { return (comp->func == with->func && + comp->level == with->level && comp->types == with->types && comp->key_len == with->key_len && comp->queue_num == with->queue_num && diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c index 897989bbd..db668835d 100644 --- a/drivers/net/i40e/i40e_flow.c +++ b/drivers/net/i40e/i40e_flow.c @@ -4380,6 +4380,10 @@ i40e_flow_parse_rss_action(struct rte_eth_dev *dev, return rte_flow_error_set (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, "non-default RSS hash functions are not supported"); + if (rss->level) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, + "a nonzero RSS encapsulation level is not supported"); if (rss->key_len && rss->key_len > RTE_DIM(rss_config->key)) return rte_flow_error_set (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, diff --git a/drivers/net/ixgbe/ixgbe_flow.c b/drivers/net/ixgbe/ixgbe_flow.c index 00d975b93..438bfcdfb 100644 --- a/drivers/net/ixgbe/ixgbe_flow.c +++ b/drivers/net/ixgbe/ixgbe_flow.c @@ -2783,6 +2783,10 @@ ixgbe_parse_rss_filter(struct rte_eth_dev *dev, return rte_flow_error_set (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, "non-default RSS hash functions are not supported"); + if (rss->level) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, + "a nonzero RSS encapsulation level is not supported"); if (rss->key_len && rss->key_len != RTE_DIM(rss_conf->key)) return rte_flow_error_set (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act, diff --git a/drivers/net/ixgbe/ixgbe_rxtx.c b/drivers/net/ixgbe/ixgbe_rxtx.c index e91e7f746..2892436e9 100644 --- a/drivers/net/ixgbe/ixgbe_rxtx.c +++ b/drivers/net/ixgbe/ixgbe_rxtx.c @@ -5684,6 +5684,7 @@ ixgbe_rss_conf_init(struct ixgbe_rte_flow_rss_conf *out, return -EINVAL; out->conf = (struct rte_flow_action_rss){ .func = in->func, + .level = in->level, .types = in->types, .key_len = in->key_len, .queue_num = in->queue_num, @@ -5699,6 +5700,7 @@ ixgbe_action_rss_same(const struct rte_flow_action_rss *comp, const struct rte_flow_action_rss *with) { return (comp->func == with->func && + comp->level == with->level && comp->types == with->types && comp->key_len == with->key_len && comp->queue_num == with->queue_num && diff --git a/drivers/net/mlx4/mlx4_flow.c b/drivers/net/mlx4/mlx4_flow.c index 002003235..ce36ac715 100644 --- a/drivers/net/mlx4/mlx4_flow.c +++ b/drivers/net/mlx4/mlx4_flow.c @@ -796,6 +796,11 @@ mlx4_flow_prepare(struct priv *priv, " is Toeplitz"; goto exit_action_not_supported; } + if (rss->level) { + msg = "a nonzero RSS encapsulation level is" + " not supported"; + goto exit_action_not_supported; + } rte_errno = 0; fields = mlx4_conv_rss_types(priv, rss->types); if (fields == (uint64_t)-1 && rte_errno) { @@ -1290,6 +1295,7 @@ mlx4_flow_internal(struct priv *priv, struct rte_flow_error *error) uint16_t queue[queues]; struct rte_flow_action_rss action_rss = { .func = RTE_ETH_HASH_FUNCTION_DEFAULT, + .level = 0, .types = -1, .key_len = MLX4_RSS_HASH_KEY_SIZE, .queue_num = queues, diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 093e3a228..cf38ceaa1 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -652,6 +652,14 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, " function is Toeplitz"); return -rte_errno; } + if (rss->level) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION, + actions, + "a nonzero RSS encapsulation" + " level is not supported"); + return -rte_errno; + } if (rss->types & MLX5_RSS_HF_MASK) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, @@ -702,6 +710,7 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev, } parser->rss_conf = (struct rte_flow_action_rss){ .func = RTE_ETH_HASH_FUNCTION_DEFAULT, + .level = 0, .types = rss->types, .key_len = rss_key_len, .queue_num = rss->queue_num, @@ -1937,6 +1946,7 @@ mlx5_flow_list_create(struct rte_eth_dev *dev, flow->queues = (uint16_t (*)[])(flow + 1); flow->rss_conf = (struct rte_flow_action_rss){ .func = RTE_ETH_HASH_FUNCTION_DEFAULT, + .level = 0, .types = parser.rss_conf.types, .key_len = parser.rss_conf.key_len, .queue_num = parser.rss_conf.queue_num, @@ -2452,6 +2462,7 @@ mlx5_ctrl_flow_vlan(struct rte_eth_dev *dev, uint16_t queue[priv->reta_idx_n]; struct rte_flow_action_rss action_rss = { .func = RTE_ETH_HASH_FUNCTION_DEFAULT, + .level = 0, .types = priv->rss_conf.rss_hf, .key_len = priv->rss_conf.rss_key_len, .queue_num = priv->reta_idx_n, diff --git a/drivers/net/sfc/sfc_flow.c b/drivers/net/sfc/sfc_flow.c index 779edad0c..3028efbf9 100644 --- a/drivers/net/sfc/sfc_flow.c +++ b/drivers/net/sfc/sfc_flow.c @@ -1269,6 +1269,9 @@ sfc_flow_parse_rss(struct sfc_adapter *sa, return -EINVAL; } + if (rss->level) + return -EINVAL; + if ((rss->types & ~SFC_RSS_OFFLOADS) != 0) return -EINVAL; diff --git a/drivers/net/tap/tap_flow.c b/drivers/net/tap/tap_flow.c index 845031a31..7dfaf9ac5 100644 --- a/drivers/net/tap/tap_flow.c +++ b/drivers/net/tap/tap_flow.c @@ -2055,11 +2055,15 @@ static int rss_add_actions(struct rte_flow *flow, struct pmd_internals *pmd, struct rss_key rss_entry = { .hash_fields = 0, .key_size = 0 }; - /* Check supported hash functions */ + /* Check supported RSS features */ if (rss->func != RTE_ETH_HASH_FUNCTION_DEFAULT) return rte_flow_error_set (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, "non-default RSS hash functions are not supported"); + if (rss->level) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, + "a nonzero RSS encapsulation level is not supported"); /* Get a new map key for a new RSS rule */ err = bpf_rss_key(KEY_CMD_GET, &flow->key_idx); diff --git a/lib/librte_ether/rte_flow.c b/lib/librte_ether/rte_flow.c index a2b51f1e0..83b733ff0 100644 --- a/lib/librte_ether/rte_flow.c +++ b/lib/librte_ether/rte_flow.c @@ -331,6 +331,7 @@ flow_action_conf_copy(void *buf, const struct rte_flow_action *action) if (dst.rss) *dst.rss = (struct rte_flow_action_rss){ .func = src.rss->func, + .level = src.rss->level, .types = src.rss->types, .key_len = src.rss->key_len, .queue_num = src.rss->queue_num, diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index 97d7d3594..d0ff26aa3 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -1046,6 +1046,32 @@ struct rte_flow_query_count { */ struct rte_flow_action_rss { enum rte_eth_hash_function func; /**< RSS hash function to apply. */ + /** + * Packet encapsulation level RSS hash @p types apply to. + * + * - @p 0 requests the default behavior. Depending on the packet + * type, it can mean outermost, innermost, anything in between or + * even no RSS. + * + * It basically stands for the innermost encapsulation level RSS + * can be performed on according to PMD and device capabilities. + * + * - @p 1 requests RSS to be performed on the outermost packet + * encapsulation level. + * + * - @p 2 and subsequent values request RSS to be performed on the + * specified inner packet encapsulation level, from outermost to + * innermost (lower to higher values). + * + * Values other than @p 0 are not necessarily supported. + * + * Requesting a specific RSS level on unrecognized traffic results + * in undefined behavior. For predictable results, it is recommended + * to make the flow rule pattern match packet headers up to the + * requested encapsulation level so that only matching traffic goes + * through. + */ + uint32_t level; uint64_t types; /**< Specific RSS hash types (see ETH_RSS_*). */ uint32_t key_len; /**< Hash key length in bytes. */ uint32_t queue_num; /**< Number of entries in @p queue. */ -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v6 10/16] ethdev: fix TPID handling in flow API 2018-04-25 15:27 ` [dpdk-dev] [PATCH v6 00/16] Flow API overhaul for switch offloads Adrien Mazarguil ` (8 preceding siblings ...) 2018-04-25 15:27 ` [dpdk-dev] [PATCH v6 09/16] ethdev: add encap level " Adrien Mazarguil @ 2018-04-25 15:27 ` Adrien Mazarguil 2018-04-25 16:10 ` Adrien Mazarguil 2018-04-25 15:27 ` [dpdk-dev] [PATCH v6 11/16] ethdev: fix default VLAN TCI mask " Adrien Mazarguil ` (6 subsequent siblings) 16 siblings, 1 reply; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-25 15:27 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev Cc: Wenzhuo Lu, Jingjing Wu, Ajit Khaparde, Somnath Kotur, John Daley, Hyong Youb Kim, Beilei Xing, Qi Zhang, Konstantin Ananyev, Nelio Laranjeiro, Yongseok Koh, Tomasz Duszynski, Dmitri Epshtein, Natalie Samsonov, Jianbo Liu, Andrew Rybchenko, Pascal Mazon TPID handling in rte_flow VLAN and E_TAG pattern item definitions is not consistent with the normal stacking order of pattern items, which is confusing to applications. Problem is that when followed by one of these layers, the EtherType field of the preceding layer keeps its "inner" definition, and the "outer" TPID is provided by the subsequent layer, the reverse of how a packet looks like on the wire: Wire: [ ETH TPID = A | VLAN EtherType = B | B DATA ] rte_flow: [ ETH EtherType = B | VLAN TPID = A | B DATA ] Worse, when QinQ is involved, the stacking order of VLAN layers is unspecified. It is unclear whether it should be reversed (innermost to outermost) as well given TPID applies to the previous layer: Wire: [ ETH TPID = A | VLAN TPID = B | VLAN EtherType = C | C DATA ] rte_flow 1: [ ETH EtherType = C | VLAN TPID = B | VLAN TPID = A | C DATA ] rte_flow 2: [ ETH EtherType = C | VLAN TPID = A | VLAN TPID = B | C DATA ] While specifying EtherType/TPID is hopefully rarely necessary, the stacking order in case of QinQ and the lack of documentation remain an issue. This patch replaces TPID in the VLAN pattern item with an inner EtherType/TPID as is usually done everywhere else (e.g. struct vlan_hdr), clarifies documentation and updates all relevant code. It breaks ABI compatibility for the following public functions: - rte_flow_copy() - rte_flow_create() - rte_flow_query() - rte_flow_validate() Summary of changes for PMDs that implement ETH, VLAN or E_TAG pattern items: - bnxt: EtherType matching is supported with and without VLAN, but TPID matching is not and triggers an error. - e1000: EtherType matching is only supported with the ETHERTYPE filter, which does not support VLAN matching, therefore no impact. - enic: same as bnxt. - i40e: same as bnxt with existing FDIR limitations on allowed EtherType values. The remaining filter types (VXLAN, NVGRE, QINQ) do not support EtherType matching. - ixgbe: same as e1000, with additional minor change to rely on the new E-Tag macro definition. - mlx4: EtherType/TPID matching is not supported, no impact. - mlx5: same as bnxt. - mvpp2: same as bnxt. - sfc: same as bnxt. - tap: same as bnxt. Fixes: b1a4b4cbc0a8 ("ethdev: introduce generic flow API") Fixes: 99e7003831c3 ("net/ixgbe: parse L2 tunnel filter") Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Acked-by: Andrew Rybchenko <arybchenko@solarflare.com> Cc: Ferruh Yigit <ferruh.yigit@intel.com> Cc: Thomas Monjalon <thomas@monjalon.net> Cc: Wenzhuo Lu <wenzhuo.lu@intel.com> Cc: Jingjing Wu <jingjing.wu@intel.com> Cc: Ajit Khaparde <ajit.khaparde@broadcom.com> Cc: Somnath Kotur <somnath.kotur@broadcom.com> Cc: John Daley <johndale@cisco.com> Cc: Hyong Youb Kim <hyonkim@cisco.com> Cc: Beilei Xing <beilei.xing@intel.com> Cc: Qi Zhang <qi.z.zhang@intel.com> Cc: Konstantin Ananyev <konstantin.ananyev@intel.com> Cc: Nelio Laranjeiro <nelio.laranjeiro@6wind.com> Cc: Yongseok Koh <yskoh@mellanox.com> Cc: Tomasz Duszynski <tdu@semihalf.com> Cc: Dmitri Epshtein <dima@marvell.com> Cc: Natalie Samsonov <nsamsono@marvell.com> Cc: Jianbo Liu <jianbo.liu@arm.com> Cc: Andrew Rybchenko <arybchenko@solarflare.com> Cc: Pascal Mazon <pascal.mazon@6wind.com> --- v6 changes: - Reworded patch title as a "fix" (not candidate for backports) since it addresses a flaw in the original API definition. - Updated API and ABI changes sections in release notes. v3 changes: Updated mrvl to mvpp2. Moved unrelated default TCI mask update to separate patch. Fixed sfc according to Andrew's comments [1], which made so much sense that I standardized on the same behavior for all other PMDs: matching outer TPID is never supported when a VLAN pattern item is present. This is done because many devices accept several TPIDs but do not provide means to match a given one explicitly, it's all or nothing, and that makes the resulting flow rule inaccurate. [1] http://dpdk.org/ml/archives/dev/2018-April/095870.html --- app/test-pmd/cmdline_flow.c | 17 +++---- doc/guides/nics/tap.rst | 2 +- doc/guides/prog_guide/rte_flow.rst | 19 ++++++-- doc/guides/rel_notes/release_18_05.rst | 7 ++- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 4 +- drivers/net/bnxt/bnxt_filter.c | 35 +++++++++++--- drivers/net/enic/enic_flow.c | 19 +++++--- drivers/net/i40e/i40e_flow.c | 60 ++++++++++++++++++++---- drivers/net/ixgbe/ixgbe_ethdev.c | 3 +- drivers/net/mlx5/mlx5_flow.c | 13 ++++- drivers/net/mvpp2/mrvl_flow.c | 26 +++++++--- drivers/net/sfc/sfc_flow.c | 18 +++++++ drivers/net/tap/tap_flow.c | 14 ++++-- lib/librte_ether/rte_flow.h | 22 ++++++--- lib/librte_net/rte_ether.h | 1 + 15 files changed, 203 insertions(+), 57 deletions(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 976fde7cd..f8f2a559e 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -99,11 +99,11 @@ enum index { ITEM_ETH_SRC, ITEM_ETH_TYPE, ITEM_VLAN, - ITEM_VLAN_TPID, ITEM_VLAN_TCI, ITEM_VLAN_PCP, ITEM_VLAN_DEI, ITEM_VLAN_VID, + ITEM_VLAN_INNER_TYPE, ITEM_IPV4, ITEM_IPV4_TOS, ITEM_IPV4_TTL, @@ -505,11 +505,11 @@ static const enum index item_eth[] = { }; static const enum index item_vlan[] = { - ITEM_VLAN_TPID, ITEM_VLAN_TCI, ITEM_VLAN_PCP, ITEM_VLAN_DEI, ITEM_VLAN_VID, + ITEM_VLAN_INNER_TYPE, ITEM_NEXT, ZERO, }; @@ -1142,12 +1142,6 @@ static const struct token token_list[] = { .next = NEXT(item_vlan), .call = parse_vc, }, - [ITEM_VLAN_TPID] = { - .name = "tpid", - .help = "tag protocol identifier", - .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param), - .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vlan, tpid)), - }, [ITEM_VLAN_TCI] = { .name = "tci", .help = "tag control information", @@ -1175,6 +1169,13 @@ static const struct token token_list[] = { .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan, tci, "\x0f\xff")), }, + [ITEM_VLAN_INNER_TYPE] = { + .name = "inner_type", + .help = "inner EtherType", + .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vlan, + inner_type)), + }, [ITEM_IPV4] = { .name = "ipv4", .help = "match IPv4 header", diff --git a/doc/guides/nics/tap.rst b/doc/guides/nics/tap.rst index 3e038cc5e..dca64c98d 100644 --- a/doc/guides/nics/tap.rst +++ b/doc/guides/nics/tap.rst @@ -108,7 +108,7 @@ The kernel support can be checked with this command:: Supported items: - eth: src and dst (with variable masks), and eth_type (0xffff mask). -- vlan: vid, pcp, tpid, but not eid. (requires kernel 4.9) +- vlan: vid, pcp, but not eid. (requires kernel 4.9) - ipv4/6: src and dst (with variable masks), and ip_proto (0xffff mask). - udp/tcp: src and dst port (0xffff) mask. diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 1a09e8a0f..fd317b48c 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -784,9 +784,15 @@ Item: ``ETH`` Matches an Ethernet header. +The ``type`` field either stands for "EtherType" or "TPID" when followed by +so-called layer 2.5 pattern items such as ``RTE_FLOW_ITEM_TYPE_VLAN``. In +the latter case, ``type`` refers to that of the outer header, with the inner +EtherType/TPID provided by the subsequent pattern item. This is the same +order as on the wire. + - ``dst``: destination MAC. - ``src``: source MAC. -- ``type``: EtherType. +- ``type``: EtherType or TPID. - Default ``mask`` matches destination and source addresses only. Item: ``VLAN`` @@ -794,8 +800,12 @@ Item: ``VLAN`` Matches an 802.1Q/ad VLAN tag. -- ``tpid``: tag protocol identifier. +The corresponding standard outer EtherType (TPID) values are +``ETHER_TYPE_VLAN`` or ``ETHER_TYPE_QINQ``. It can be overridden by the +preceding pattern item. + - ``tci``: tag control information. +- ``inner_type``: inner EtherType or TPID. - Default ``mask`` matches TCI only. Item: ``IPV4`` @@ -866,12 +876,15 @@ Item: ``E_TAG`` Matches an IEEE 802.1BR E-Tag header. -- ``tpid``: tag protocol identifier (0x893F) +The corresponding standard outer EtherType (TPID) value is +``ETHER_TYPE_ETAG``. It can be overridden by the preceding pattern item. + - ``epcp_edei_in_ecid_b``: E-Tag control information (E-TCI), E-PCP (3b), E-DEI (1b), ingress E-CID base (12b). - ``rsvd_grp_ecid_b``: reserved (2b), GRP (2b), E-CID base (12b). - ``in_ecid_e``: ingress E-CID ext. - ``ecid_e``: E-CID ext. +- ``inner_type``: inner EtherType or TPID. - Default ``mask`` simultaneously matches GRP and E-CID base. Item: ``NVGRE`` diff --git a/doc/guides/rel_notes/release_18_05.rst b/doc/guides/rel_notes/release_18_05.rst index e1419f925..a980a23ae 100644 --- a/doc/guides/rel_notes/release_18_05.rst +++ b/doc/guides/rel_notes/release_18_05.rst @@ -263,6 +263,8 @@ API Changes ``num`` => ``queue_num``), and the addition of missing RSS parameters (``func`` for RSS hash function to apply and ``level`` for the encapsulation level). + * The VLAN pattern item (``struct rte_flow_item_vlan``) was modified to + include inner EtherType instead of outer TPID. ABI Changes @@ -312,8 +314,9 @@ ABI Changes changes in error type definitions (``enum rte_flow_error_type``), removal of the unused DUP action (``enum rte_flow_action_type``), modified behavior for flow rule actions (see API changes), removal of C99 flexible - array from RAW pattern item (``struct rte_flow_item_raw``) and complete - rework of the RSS action definition (``struct rte_flow_action_rss``). + array from RAW pattern item (``struct rte_flow_item_raw``), complete + rework of the RSS action definition (``struct rte_flow_action_rss``) and + sanity fix in the VLAN pattern item (``struct rte_flow_item_vlan``). Removed Items diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index c5e399f3b..007b24ff3 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3247,15 +3247,15 @@ This section lists supported pattern items and their attributes, if any. - ``dst {MAC-48}``: destination MAC. - ``src {MAC-48}``: source MAC. - - ``type {unsigned}``: EtherType. + - ``type {unsigned}``: EtherType or TPID. - ``vlan``: match 802.1Q/ad VLAN tag. - - ``tpid {unsigned}``: tag protocol identifier. - ``tci {unsigned}``: tag control information. - ``pcp {unsigned}``: priority code point. - ``dei {unsigned}``: drop eligible indicator. - ``vid {unsigned}``: VLAN identifier. + - ``inner_type {unsigned}``: inner EtherType or TPID. - ``ipv4``: match IPv4 header. diff --git a/drivers/net/bnxt/bnxt_filter.c b/drivers/net/bnxt/bnxt_filter.c index fdd94bf02..25806bdc0 100644 --- a/drivers/net/bnxt/bnxt_filter.c +++ b/drivers/net/bnxt/bnxt_filter.c @@ -307,6 +307,7 @@ bnxt_validate_and_parse_flow_type(struct bnxt *bp, uint32_t vf = 0; int use_ntuple; uint32_t en = 0; + uint32_t en_ethertype; int dflt_vnic; use_ntuple = bnxt_filter_type_check(pattern, error); @@ -316,6 +317,9 @@ bnxt_validate_and_parse_flow_type(struct bnxt *bp, filter->filter_type = use_ntuple ? HWRM_CFA_NTUPLE_FILTER : HWRM_CFA_EM_FILTER; + en_ethertype = use_ntuple ? + NTUPLE_FLTR_ALLOC_INPUT_EN_ETHERTYPE : + EM_FLOW_ALLOC_INPUT_EN_ETHERTYPE; while (item->type != RTE_FLOW_ITEM_TYPE_END) { if (item->last) { @@ -385,30 +389,49 @@ bnxt_validate_and_parse_flow_type(struct bnxt *bp, if (eth_mask->type) { filter->ethertype = rte_be_to_cpu_16(eth_spec->type); - en |= use_ntuple ? - NTUPLE_FLTR_ALLOC_INPUT_EN_ETHERTYPE : - EM_FLOW_ALLOC_INPUT_EN_ETHERTYPE; + en |= en_ethertype; } break; case RTE_FLOW_ITEM_TYPE_VLAN: vlan_spec = item->spec; vlan_mask = item->mask; + if (en & en_ethertype) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, + item, + "VLAN TPID matching is not" + " supported"); + return -rte_errno; + } if (vlan_mask->tci && - vlan_mask->tci == RTE_BE16(0x0fff) && - !vlan_mask->tpid) { + vlan_mask->tci == RTE_BE16(0x0fff)) { /* Only the VLAN ID can be matched. */ filter->l2_ovlan = rte_be_to_cpu_16(vlan_spec->tci & RTE_BE16(0x0fff)); en |= EM_FLOW_ALLOC_INPUT_EN_OVLAN_VID; - } else if (vlan_mask->tci || vlan_mask->tpid) { + } else if (vlan_mask->tci) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM, item, "VLAN mask is invalid"); return -rte_errno; } + if (vlan_mask->inner_type && + vlan_mask->inner_type != RTE_BE16(0xffff)) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, + item, + "inner ethertype mask not" + " valid"); + return -rte_errno; + } + if (vlan_mask->inner_type) { + filter->ethertype = + rte_be_to_cpu_16(vlan_spec->inner_type); + en |= en_ethertype; + } break; case RTE_FLOW_ITEM_TYPE_IPV4: diff --git a/drivers/net/enic/enic_flow.c b/drivers/net/enic/enic_flow.c index c34ae84d1..eea14ee73 100644 --- a/drivers/net/enic/enic_flow.c +++ b/drivers/net/enic/enic_flow.c @@ -557,16 +557,21 @@ enic_copy_item_vlan_v2(const struct rte_flow_item *item, if (!spec) return 0; - /* Don't support filtering in tpid */ - if (mask) { - if (mask->tpid != 0) - return ENOTSUP; - } else { + if (!mask) mask = &rte_flow_item_vlan_mask; - RTE_ASSERT(mask->tpid == 0); - } if (*inner_ofst == 0) { + struct ether_hdr *eth_mask = + (void *)gp->layer[FILTER_GENERIC_1_L2].mask; + struct ether_hdr *eth_val = + (void *)gp->layer[FILTER_GENERIC_1_L2].val; + + /* Outer TPID cannot be matched */ + if (eth_mask->ether_type) + return ENOTSUP; + eth_mask->ether_type = mask->inner_type; + eth_val->ether_type = spec->inner_type; + /* Outer header. Use the vlan mask/val fields */ gp->mask_vlan = mask->tci; gp->val_vlan = spec->tci; diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c index db668835d..470ab93d6 100644 --- a/drivers/net/i40e/i40e_flow.c +++ b/drivers/net/i40e/i40e_flow.c @@ -10,6 +10,7 @@ #include <unistd.h> #include <stdarg.h> +#include <rte_debug.h> #include <rte_ether.h> #include <rte_ethdev_driver.h> #include <rte_log.h> @@ -2491,16 +2492,22 @@ i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev, "Invalid MAC_addr mask."); return -rte_errno; } + } + if (eth_spec && eth_mask && eth_mask->type) { + enum rte_flow_item_type next = (item + 1)->type; - if ((eth_mask->type & UINT16_MAX) == - UINT16_MAX) { - input_set |= I40E_INSET_LAST_ETHER_TYPE; - filter->input.flow.l2_flow.ether_type = - eth_spec->type; + if (eth_mask->type != RTE_BE16(0xffff)) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, + item, + "Invalid type mask."); + return -rte_errno; } ether_type = rte_be_to_cpu_16(eth_spec->type); - if (ether_type == ETHER_TYPE_IPv4 || + + if (next == RTE_FLOW_ITEM_TYPE_VLAN || + ether_type == ETHER_TYPE_IPv4 || ether_type == ETHER_TYPE_IPv6 || ether_type == ETHER_TYPE_ARP || ether_type == outer_tpid) { @@ -2510,6 +2517,9 @@ i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev, "Unsupported ether_type."); return -rte_errno; } + input_set |= I40E_INSET_LAST_ETHER_TYPE; + filter->input.flow.l2_flow.ether_type = + eth_spec->type; } pctype = I40E_FILTER_PCTYPE_L2_PAYLOAD; @@ -2519,6 +2529,8 @@ i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev, case RTE_FLOW_ITEM_TYPE_VLAN: vlan_spec = item->spec; vlan_mask = item->mask; + + RTE_ASSERT(!(input_set & I40E_INSET_LAST_ETHER_TYPE)); if (vlan_spec && vlan_mask) { if (vlan_mask->tci == rte_cpu_to_be_16(I40E_TCI_MASK)) { @@ -2527,6 +2539,33 @@ i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev, vlan_spec->tci; } } + if (vlan_spec && vlan_mask && vlan_mask->inner_type) { + if (vlan_mask->inner_type != RTE_BE16(0xffff)) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, + item, + "Invalid inner_type" + " mask."); + return -rte_errno; + } + + ether_type = + rte_be_to_cpu_16(vlan_spec->inner_type); + + if (ether_type == ETHER_TYPE_IPv4 || + ether_type == ETHER_TYPE_IPv6 || + ether_type == ETHER_TYPE_ARP || + ether_type == outer_tpid) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, + item, + "Unsupported inner_type."); + return -rte_errno; + } + input_set |= I40E_INSET_LAST_ETHER_TYPE; + filter->input.flow.l2_flow.ether_type = + vlan_spec->inner_type; + } pctype = I40E_FILTER_PCTYPE_L2_PAYLOAD; layer_idx = I40E_FLXPLD_L2_IDX; @@ -3285,7 +3324,8 @@ i40e_flow_parse_vxlan_pattern(__rte_unused struct rte_eth_dev *dev, case RTE_FLOW_ITEM_TYPE_VLAN: vlan_spec = item->spec; vlan_mask = item->mask; - if (!(vlan_spec && vlan_mask)) { + if (!(vlan_spec && vlan_mask) || + vlan_mask->inner_type) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM, item, @@ -3515,7 +3555,8 @@ i40e_flow_parse_nvgre_pattern(__rte_unused struct rte_eth_dev *dev, case RTE_FLOW_ITEM_TYPE_VLAN: vlan_spec = item->spec; vlan_mask = item->mask; - if (!(vlan_spec && vlan_mask)) { + if (!(vlan_spec && vlan_mask) || + vlan_mask->inner_type) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM, item, @@ -4023,7 +4064,8 @@ i40e_flow_parse_qinq_pattern(__rte_unused struct rte_eth_dev *dev, vlan_spec = item->spec; vlan_mask = item->mask; - if (!(vlan_spec && vlan_mask)) { + if (!(vlan_spec && vlan_mask) || + vlan_mask->inner_type) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM, item, diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c index c00bdae3d..98a78755d 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.c +++ b/drivers/net/ixgbe/ixgbe_ethdev.c @@ -115,7 +115,6 @@ #define IXGBE_VT_CTL_POOLING_MODE_MASK 0x00030000 #define IXGBE_VT_CTL_POOLING_MODE_ETAG 0x00010000 -#define DEFAULT_ETAG_ETYPE 0x893f #define IXGBE_ETAG_ETYPE 0x00005084 #define IXGBE_ETAG_ETYPE_MASK 0x0000ffff #define IXGBE_ETAG_ETYPE_VALID 0x80000000 @@ -1488,7 +1487,7 @@ static int ixgbe_l2_tn_filter_init(struct rte_eth_dev *eth_dev) } l2_tn_info->e_tag_en = FALSE; l2_tn_info->e_tag_fwd_en = FALSE; - l2_tn_info->e_tag_ether_type = DEFAULT_ETAG_ETYPE; + l2_tn_info->e_tag_ether_type = ETHER_TYPE_ETAG; return 0; } diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index cf38ceaa1..d77598b2d 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -18,6 +18,7 @@ #endif #include <rte_common.h> +#include <rte_ether.h> #include <rte_eth_ctrl.h> #include <rte_ethdev_driver.h> #include <rte_flow.h> @@ -306,6 +307,7 @@ static const struct mlx5_flow_items mlx5_flow_items[] = { .actions = valid_actions, .mask = &(const struct rte_flow_item_vlan){ .tci = -1, + .inner_type = -1, }, .default_mask = &rte_flow_item_vlan_mask, .mask_sz = sizeof(struct rte_flow_item_vlan), @@ -1295,6 +1297,7 @@ mlx5_flow_create_vlan(const struct rte_flow_item *item, struct mlx5_flow_parse *parser = data->parser; struct ibv_flow_spec_eth *eth; const unsigned int eth_size = sizeof(struct ibv_flow_spec_eth); + const char *msg = "VLAN cannot be empty"; if (spec) { unsigned int i; @@ -1316,12 +1319,20 @@ mlx5_flow_create_vlan(const struct rte_flow_item *item, */ if (!eth->mask.vlan_tag) goto error; + /* Outer TPID cannot be matched. */ + if (eth->mask.ether_type) { + msg = "VLAN TPID matching is not supported"; + goto error; + } + eth->val.ether_type = spec->inner_type; + eth->mask.ether_type = mask->inner_type; + eth->val.ether_type &= eth->mask.ether_type; } return 0; } error: return rte_flow_error_set(data->error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM, - item, "VLAN cannot be empty"); + item, msg); } /** diff --git a/drivers/net/mvpp2/mrvl_flow.c b/drivers/net/mvpp2/mrvl_flow.c index 8fd4dbfb1..6478eb2fe 100644 --- a/drivers/net/mvpp2/mrvl_flow.c +++ b/drivers/net/mvpp2/mrvl_flow.c @@ -1091,12 +1091,6 @@ mrvl_parse_vlan(const struct rte_flow_item *item, if (ret) return ret; - if (mask->tpid) { - rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM, - NULL, "Not supported by classifier\n"); - return -rte_errno; - } - m = rte_be_to_cpu_16(mask->tci); if (m & MRVL_VLAN_ID_MASK) { RTE_LOG(WARNING, PMD, "vlan id mask is ignored\n"); @@ -1112,6 +1106,26 @@ mrvl_parse_vlan(const struct rte_flow_item *item, goto out; } + if (flow->pattern & F_TYPE) { + rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ITEM, item, + "VLAN TPID matching is not supported\n"); + return -rte_errno; + } + if (mask->inner_type) { + struct rte_flow_item_eth spec_eth = { + .type = spec->inner_type, + }; + struct rte_flow_item_eth mask_eth = { + .type = mask->inner_type, + }; + + RTE_LOG(WARNING, PMD, "inner eth type mask is ignored\n"); + ret = mrvl_parse_type(spec_eth, mask_eth, flow); + if (ret) + goto out; + } + return 0; out: rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, diff --git a/drivers/net/sfc/sfc_flow.c b/drivers/net/sfc/sfc_flow.c index 3028efbf9..cd6a61b39 100644 --- a/drivers/net/sfc/sfc_flow.c +++ b/drivers/net/sfc/sfc_flow.c @@ -7,6 +7,7 @@ * for Solarflare) and Solarflare Communications, Inc. */ +#include <rte_byteorder.h> #include <rte_tailq.h> #include <rte_common.h> #include <rte_ethdev_driver.h> @@ -351,6 +352,7 @@ sfc_flow_parse_vlan(const struct rte_flow_item *item, const struct rte_flow_item_vlan *mask = NULL; const struct rte_flow_item_vlan supp_mask = { .tci = rte_cpu_to_be_16(ETH_VLAN_ID_MAX), + .inner_type = RTE_BE16(0xffff), }; rc = sfc_flow_parse_init(item, @@ -393,6 +395,22 @@ sfc_flow_parse_vlan(const struct rte_flow_item *item, return -rte_errno; } + if (efx_spec->efs_match_flags & EFX_FILTER_MATCH_ETHER_TYPE) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, item, + "VLAN TPID matching is not supported"); + return -rte_errno; + } + if (mask->inner_type == supp_mask.inner_type) { + efx_spec->efs_match_flags |= EFX_FILTER_MATCH_ETHER_TYPE; + efx_spec->efs_ether_type = rte_bswap16(spec->inner_type); + } else if (mask->inner_type) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, item, + "Bad mask for VLAN inner_type"); + return -rte_errno; + } + return 0; } diff --git a/drivers/net/tap/tap_flow.c b/drivers/net/tap/tap_flow.c index 7dfaf9ac5..dff09313a 100644 --- a/drivers/net/tap/tap_flow.c +++ b/drivers/net/tap/tap_flow.c @@ -270,13 +270,13 @@ static const struct tap_flow_items tap_flow_items[] = { .items = ITEMS(RTE_FLOW_ITEM_TYPE_IPV4, RTE_FLOW_ITEM_TYPE_IPV6), .mask = &(const struct rte_flow_item_vlan){ - .tpid = -1, /* DEI matching is not supported */ #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN .tci = 0xffef, #else .tci = 0xefff, #endif + .inner_type = -1, }, .mask_sz = sizeof(struct rte_flow_item_vlan), .default_mask = &rte_flow_item_vlan_mask, @@ -578,13 +578,19 @@ tap_flow_create_vlan(const struct rte_flow_item *item, void *data) /* use default mask if none provided */ if (!mask) mask = tap_flow_items[RTE_FLOW_ITEM_TYPE_VLAN].default_mask; - /* TC does not support tpid masking. Only accept if exact match. */ - if (mask->tpid && mask->tpid != 0xffff) + /* Outer TPID cannot be matched. */ + if (info->eth_type) return -1; /* Double-tagging not supported. */ - if (spec && mask->tpid && spec->tpid != htons(ETH_P_8021Q)) + if (info->vlan) return -1; info->vlan = 1; + if (mask->inner_type) { + /* TC does not support partial eth_type masking */ + if (mask->inner_type != RTE_BE16(0xffff)) + return -1; + info->eth_type = spec->inner_type; + } if (!flow) return 0; msg = &flow->msg; diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index d0ff26aa3..8e50384d0 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -454,11 +454,17 @@ static const struct rte_flow_item_raw rte_flow_item_raw_mask = { * RTE_FLOW_ITEM_TYPE_ETH * * Matches an Ethernet header. + * + * The @p type field either stands for "EtherType" or "TPID" when followed + * by so-called layer 2.5 pattern items such as RTE_FLOW_ITEM_TYPE_VLAN. In + * the latter case, @p type refers to that of the outer header, with the + * inner EtherType/TPID provided by the subsequent pattern item. This is the + * same order as on the wire. */ struct rte_flow_item_eth { struct ether_addr dst; /**< Destination MAC. */ struct ether_addr src; /**< Source MAC. */ - rte_be16_t type; /**< EtherType. */ + rte_be16_t type; /**< EtherType or TPID. */ }; /** Default mask for RTE_FLOW_ITEM_TYPE_ETH. */ @@ -475,19 +481,20 @@ static const struct rte_flow_item_eth rte_flow_item_eth_mask = { * * Matches an 802.1Q/ad VLAN tag. * - * This type normally follows either RTE_FLOW_ITEM_TYPE_ETH or - * RTE_FLOW_ITEM_TYPE_VLAN. + * The corresponding standard outer EtherType (TPID) values are + * ETHER_TYPE_VLAN or ETHER_TYPE_QINQ. It can be overridden by the preceding + * pattern item. */ struct rte_flow_item_vlan { - rte_be16_t tpid; /**< Tag protocol identifier. */ rte_be16_t tci; /**< Tag control information. */ + rte_be16_t inner_type; /**< Inner EtherType or TPID. */ }; /** Default mask for RTE_FLOW_ITEM_TYPE_VLAN. */ #ifndef __cplusplus static const struct rte_flow_item_vlan rte_flow_item_vlan_mask = { - .tpid = RTE_BE16(0x0000), .tci = RTE_BE16(0xffff), + .inner_type = RTE_BE16(0x0000), }; #endif @@ -636,9 +643,11 @@ static const struct rte_flow_item_vxlan rte_flow_item_vxlan_mask = { * RTE_FLOW_ITEM_TYPE_E_TAG. * * Matches a E-tag header. + * + * The corresponding standard outer EtherType (TPID) value is + * ETHER_TYPE_ETAG. It can be overridden by the preceding pattern item. */ struct rte_flow_item_e_tag { - rte_be16_t tpid; /**< Tag protocol identifier (0x893F). */ /** * E-Tag control information (E-TCI). * E-PCP (3b), E-DEI (1b), ingress E-CID base (12b). @@ -648,6 +657,7 @@ struct rte_flow_item_e_tag { rte_be16_t rsvd_grp_ecid_b; uint8_t in_ecid_e; /**< Ingress E-CID ext. */ uint8_t ecid_e; /**< E-CID ext. */ + rte_be16_t inner_type; /**< Inner EtherType or TPID. */ }; /** Default mask for RTE_FLOW_ITEM_TYPE_E_TAG. */ diff --git a/lib/librte_net/rte_ether.h b/lib/librte_net/rte_ether.h index 45daa911a..a271d1c86 100644 --- a/lib/librte_net/rte_ether.h +++ b/lib/librte_net/rte_ether.h @@ -301,6 +301,7 @@ struct vxlan_hdr { #define ETHER_TYPE_RARP 0x8035 /**< Reverse Arp Protocol. */ #define ETHER_TYPE_VLAN 0x8100 /**< IEEE 802.1Q VLAN tagging. */ #define ETHER_TYPE_QINQ 0x88A8 /**< IEEE 802.1ad QinQ tagging. */ +#define ETHER_TYPE_ETAG 0x893F /**< IEEE 802.1BR E-Tag. */ #define ETHER_TYPE_1588 0x88F7 /**< IEEE 802.1AS 1588 Precise Time Protocol. */ #define ETHER_TYPE_SLOW 0x8809 /**< Slow protocols (LACP and Marker). */ #define ETHER_TYPE_TEB 0x6558 /**< Transparent Ethernet Bridging. */ -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [dpdk-dev] [PATCH v6 10/16] ethdev: fix TPID handling in flow API 2018-04-25 15:27 ` [dpdk-dev] [PATCH v6 10/16] ethdev: fix TPID handling in flow API Adrien Mazarguil @ 2018-04-25 16:10 ` Adrien Mazarguil 2018-04-25 16:15 ` Ferruh Yigit 0 siblings, 1 reply; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-25 16:10 UTC (permalink / raw) To: Ferruh Yigit, dev Cc: Jacek Siuda, Tomasz Duszynski, Dmitri Epshtein, Natalie Samsonov, Jianbo Liu On Wed, Apr 25, 2018 at 05:27:56PM +0200, Adrien Mazarguil wrote: > TPID handling in rte_flow VLAN and E_TAG pattern item definitions is not > consistent with the normal stacking order of pattern items, which is > confusing to applications. > > Problem is that when followed by one of these layers, the EtherType field > of the preceding layer keeps its "inner" definition, and the "outer" TPID > is provided by the subsequent layer, the reverse of how a packet looks like > on the wire: > > Wire: [ ETH TPID = A | VLAN EtherType = B | B DATA ] > rte_flow: [ ETH EtherType = B | VLAN TPID = A | B DATA ] > > Worse, when QinQ is involved, the stacking order of VLAN layers is > unspecified. It is unclear whether it should be reversed (innermost to > outermost) as well given TPID applies to the previous layer: > > Wire: [ ETH TPID = A | VLAN TPID = B | VLAN EtherType = C | C DATA ] > rte_flow 1: [ ETH EtherType = C | VLAN TPID = B | VLAN TPID = A | C DATA ] > rte_flow 2: [ ETH EtherType = C | VLAN TPID = A | VLAN TPID = B | C DATA ] > > While specifying EtherType/TPID is hopefully rarely necessary, the stacking > order in case of QinQ and the lack of documentation remain an issue. > > This patch replaces TPID in the VLAN pattern item with an inner > EtherType/TPID as is usually done everywhere else (e.g. struct vlan_hdr), > clarifies documentation and updates all relevant code. > > It breaks ABI compatibility for the following public functions: > > - rte_flow_copy() > - rte_flow_create() > - rte_flow_query() > - rte_flow_validate() > > Summary of changes for PMDs that implement ETH, VLAN or E_TAG pattern > items: > > - bnxt: EtherType matching is supported with and without VLAN, but TPID > matching is not and triggers an error. > > - e1000: EtherType matching is only supported with the ETHERTYPE filter, > which does not support VLAN matching, therefore no impact. > > - enic: same as bnxt. > > - i40e: same as bnxt with existing FDIR limitations on allowed EtherType > values. The remaining filter types (VXLAN, NVGRE, QINQ) do not support > EtherType matching. > > - ixgbe: same as e1000, with additional minor change to rely on the new > E-Tag macro definition. > > - mlx4: EtherType/TPID matching is not supported, no impact. > > - mlx5: same as bnxt. > > - mvpp2: same as bnxt. > > - sfc: same as bnxt. > > - tap: same as bnxt. > > Fixes: b1a4b4cbc0a8 ("ethdev: introduce generic flow API") > Fixes: 99e7003831c3 ("net/ixgbe: parse L2 tunnel filter") > > Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> > Acked-by: Andrew Rybchenko <arybchenko@solarflare.com> > Cc: Ferruh Yigit <ferruh.yigit@intel.com> > Cc: Thomas Monjalon <thomas@monjalon.net> > Cc: Wenzhuo Lu <wenzhuo.lu@intel.com> > Cc: Jingjing Wu <jingjing.wu@intel.com> > Cc: Ajit Khaparde <ajit.khaparde@broadcom.com> > Cc: Somnath Kotur <somnath.kotur@broadcom.com> > Cc: John Daley <johndale@cisco.com> > Cc: Hyong Youb Kim <hyonkim@cisco.com> > Cc: Beilei Xing <beilei.xing@intel.com> > Cc: Qi Zhang <qi.z.zhang@intel.com> > Cc: Konstantin Ananyev <konstantin.ananyev@intel.com> > Cc: Nelio Laranjeiro <nelio.laranjeiro@6wind.com> > Cc: Yongseok Koh <yskoh@mellanox.com> > Cc: Tomasz Duszynski <tdu@semihalf.com> > Cc: Dmitri Epshtein <dima@marvell.com> > Cc: Natalie Samsonov <nsamsono@marvell.com> > Cc: Jianbo Liu <jianbo.liu@arm.com> > Cc: Andrew Rybchenko <arybchenko@solarflare.com> > Cc: Pascal Mazon <pascal.mazon@6wind.com> > > --- > > v6 changes: > > - Reworded patch title as a "fix" (not candidate for backports) since it > addresses a flaw in the original API definition. > - Updated API and ABI changes sections in release notes. > > v3 changes: > > Updated mrvl to mvpp2. > > Moved unrelated default TCI mask update to separate patch. > > Fixed sfc according to Andrew's comments [1], which made so much sense that > I standardized on the same behavior for all other PMDs: matching outer TPID > is never supported when a VLAN pattern item is present. > > This is done because many devices accept several TPIDs but do not provide > means to match a given one explicitly, it's all or nothing, and that makes > the resulting flow rule inaccurate. > > [1] http://dpdk.org/ml/archives/dev/2018-April/095870.html <snip> > diff --git a/drivers/net/mvpp2/mrvl_flow.c b/drivers/net/mvpp2/mrvl_flow.c <snip> > + if (mask->inner_type) { > + struct rte_flow_item_eth spec_eth = { > + .type = spec->inner_type, > + }; > + struct rte_flow_item_eth mask_eth = { > + .type = mask->inner_type, > + }; > + > + RTE_LOG(WARNING, PMD, "inner eth type mask is ignored\n"); > + ret = mrvl_parse_type(spec_eth, mask_eth, flow); Looks like there's a compilation issue left on the above line, which should obviously read: ret = mrvl_parse_type(&spec_eth, &mask_eth, flow); Ferruh, can you update it while applying? I'd hate to spam the world with v7 :) Thanks. -- Adrien Mazarguil 6WIND ^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [dpdk-dev] [PATCH v6 10/16] ethdev: fix TPID handling in flow API 2018-04-25 16:10 ` Adrien Mazarguil @ 2018-04-25 16:15 ` Ferruh Yigit 0 siblings, 0 replies; 157+ messages in thread From: Ferruh Yigit @ 2018-04-25 16:15 UTC (permalink / raw) To: Adrien Mazarguil, dev Cc: Jacek Siuda, Tomasz Duszynski, Dmitri Epshtein, Natalie Samsonov, Jianbo Liu On 4/25/2018 5:10 PM, Adrien Mazarguil wrote: > On Wed, Apr 25, 2018 at 05:27:56PM +0200, Adrien Mazarguil wrote: >> TPID handling in rte_flow VLAN and E_TAG pattern item definitions is not >> consistent with the normal stacking order of pattern items, which is >> confusing to applications. >> >> Problem is that when followed by one of these layers, the EtherType field >> of the preceding layer keeps its "inner" definition, and the "outer" TPID >> is provided by the subsequent layer, the reverse of how a packet looks like >> on the wire: >> >> Wire: [ ETH TPID = A | VLAN EtherType = B | B DATA ] >> rte_flow: [ ETH EtherType = B | VLAN TPID = A | B DATA ] >> >> Worse, when QinQ is involved, the stacking order of VLAN layers is >> unspecified. It is unclear whether it should be reversed (innermost to >> outermost) as well given TPID applies to the previous layer: >> >> Wire: [ ETH TPID = A | VLAN TPID = B | VLAN EtherType = C | C DATA ] >> rte_flow 1: [ ETH EtherType = C | VLAN TPID = B | VLAN TPID = A | C DATA ] >> rte_flow 2: [ ETH EtherType = C | VLAN TPID = A | VLAN TPID = B | C DATA ] >> >> While specifying EtherType/TPID is hopefully rarely necessary, the stacking >> order in case of QinQ and the lack of documentation remain an issue. >> >> This patch replaces TPID in the VLAN pattern item with an inner >> EtherType/TPID as is usually done everywhere else (e.g. struct vlan_hdr), >> clarifies documentation and updates all relevant code. >> >> It breaks ABI compatibility for the following public functions: >> >> - rte_flow_copy() >> - rte_flow_create() >> - rte_flow_query() >> - rte_flow_validate() >> >> Summary of changes for PMDs that implement ETH, VLAN or E_TAG pattern >> items: >> >> - bnxt: EtherType matching is supported with and without VLAN, but TPID >> matching is not and triggers an error. >> >> - e1000: EtherType matching is only supported with the ETHERTYPE filter, >> which does not support VLAN matching, therefore no impact. >> >> - enic: same as bnxt. >> >> - i40e: same as bnxt with existing FDIR limitations on allowed EtherType >> values. The remaining filter types (VXLAN, NVGRE, QINQ) do not support >> EtherType matching. >> >> - ixgbe: same as e1000, with additional minor change to rely on the new >> E-Tag macro definition. >> >> - mlx4: EtherType/TPID matching is not supported, no impact. >> >> - mlx5: same as bnxt. >> >> - mvpp2: same as bnxt. >> >> - sfc: same as bnxt. >> >> - tap: same as bnxt. >> >> Fixes: b1a4b4cbc0a8 ("ethdev: introduce generic flow API") >> Fixes: 99e7003831c3 ("net/ixgbe: parse L2 tunnel filter") >> >> Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> >> Acked-by: Andrew Rybchenko <arybchenko@solarflare.com> >> Cc: Ferruh Yigit <ferruh.yigit@intel.com> >> Cc: Thomas Monjalon <thomas@monjalon.net> >> Cc: Wenzhuo Lu <wenzhuo.lu@intel.com> >> Cc: Jingjing Wu <jingjing.wu@intel.com> >> Cc: Ajit Khaparde <ajit.khaparde@broadcom.com> >> Cc: Somnath Kotur <somnath.kotur@broadcom.com> >> Cc: John Daley <johndale@cisco.com> >> Cc: Hyong Youb Kim <hyonkim@cisco.com> >> Cc: Beilei Xing <beilei.xing@intel.com> >> Cc: Qi Zhang <qi.z.zhang@intel.com> >> Cc: Konstantin Ananyev <konstantin.ananyev@intel.com> >> Cc: Nelio Laranjeiro <nelio.laranjeiro@6wind.com> >> Cc: Yongseok Koh <yskoh@mellanox.com> >> Cc: Tomasz Duszynski <tdu@semihalf.com> >> Cc: Dmitri Epshtein <dima@marvell.com> >> Cc: Natalie Samsonov <nsamsono@marvell.com> >> Cc: Jianbo Liu <jianbo.liu@arm.com> >> Cc: Andrew Rybchenko <arybchenko@solarflare.com> >> Cc: Pascal Mazon <pascal.mazon@6wind.com> >> >> --- >> >> v6 changes: >> >> - Reworded patch title as a "fix" (not candidate for backports) since it >> addresses a flaw in the original API definition. >> - Updated API and ABI changes sections in release notes. >> >> v3 changes: >> >> Updated mrvl to mvpp2. >> >> Moved unrelated default TCI mask update to separate patch. >> >> Fixed sfc according to Andrew's comments [1], which made so much sense that >> I standardized on the same behavior for all other PMDs: matching outer TPID >> is never supported when a VLAN pattern item is present. >> >> This is done because many devices accept several TPIDs but do not provide >> means to match a given one explicitly, it's all or nothing, and that makes >> the resulting flow rule inaccurate. >> >> [1] http://dpdk.org/ml/archives/dev/2018-April/095870.html > <snip> >> diff --git a/drivers/net/mvpp2/mrvl_flow.c b/drivers/net/mvpp2/mrvl_flow.c > <snip> >> + if (mask->inner_type) { >> + struct rte_flow_item_eth spec_eth = { >> + .type = spec->inner_type, >> + }; >> + struct rte_flow_item_eth mask_eth = { >> + .type = mask->inner_type, >> + }; >> + >> + RTE_LOG(WARNING, PMD, "inner eth type mask is ignored\n"); >> + ret = mrvl_parse_type(spec_eth, mask_eth, flow); > > Looks like there's a compilation issue left on the above line, which should > obviously read: > > ret = mrvl_parse_type(&spec_eth, &mask_eth, flow); > > Ferruh, can you update it while applying? > I'd hate to spam the world with v7 :) OK, will update while applying. > > Thanks. > ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v6 11/16] ethdev: fix default VLAN TCI mask in flow API 2018-04-25 15:27 ` [dpdk-dev] [PATCH v6 00/16] Flow API overhaul for switch offloads Adrien Mazarguil ` (9 preceding siblings ...) 2018-04-25 15:27 ` [dpdk-dev] [PATCH v6 10/16] ethdev: fix TPID handling in flow API Adrien Mazarguil @ 2018-04-25 15:27 ` Adrien Mazarguil 2018-04-25 15:28 ` [dpdk-dev] [PATCH v6 12/16] ethdev: add transfer attribute to " Adrien Mazarguil ` (5 subsequent siblings) 16 siblings, 0 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-25 15:27 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev Cc: Wenzhuo Lu, Jingjing Wu, Ajit Khaparde, Somnath Kotur, John Daley, Hyong Youb Kim, Beilei Xing, Qi Zhang, Konstantin Ananyev, Nelio Laranjeiro, Yongseok Koh, Tomasz Duszynski, Dmitri Epshtein, Natalie Samsonov, Jianbo Liu, Andrew Rybchenko, Pascal Mazon VLAN TCI is a 16-bit field broken down as PCP (3b), DEI (1b) and VID (12b). The default mask used by PMDs for the VLAN pattern when one isn't provided by the application comprises the entire TCI, which is problematic because most devices only support VID matching. This forces applications to always provide a mask limited to the VID part in order to successfully apply a flow rule with a VLAN pattern item. Moreover, applications rarely want to match PCP and DEI intentionally. Given the above and since VID is what is commonly referred to when talking about VLAN, this commit excludes PCP and DEI from the default mask. Fixes: 6de5c0f1302c ("ethdev: define default item masks in flow API") Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Acked-by: Andrew Rybchenko <arybchenko@solarflare.com> Cc: Ferruh Yigit <ferruh.yigit@intel.com> Cc: Thomas Monjalon <thomas@monjalon.net> Cc: Wenzhuo Lu <wenzhuo.lu@intel.com> Cc: Jingjing Wu <jingjing.wu@intel.com> Cc: Ajit Khaparde <ajit.khaparde@broadcom.com> Cc: Somnath Kotur <somnath.kotur@broadcom.com> Cc: John Daley <johndale@cisco.com> Cc: Hyong Youb Kim <hyonkim@cisco.com> Cc: Beilei Xing <beilei.xing@intel.com> Cc: Qi Zhang <qi.z.zhang@intel.com> Cc: Konstantin Ananyev <konstantin.ananyev@intel.com> Cc: Nelio Laranjeiro <nelio.laranjeiro@6wind.com> Cc: Yongseok Koh <yskoh@mellanox.com> Cc: Tomasz Duszynski <tdu@semihalf.com> Cc: Dmitri Epshtein <dima@marvell.com> Cc: Natalie Samsonov <nsamsono@marvell.com> Cc: Jianbo Liu <jianbo.liu@arm.com> Cc: Andrew Rybchenko <arybchenko@solarflare.com> Cc: Pascal Mazon <pascal.mazon@6wind.com> --- v6 changes: - Reworded patch title as a "fix" (not candidate for backports) since it addresses a flaw in the original API definition. - Updated API changes section in release notes. v3 changes: These changes were previously mistakenly made part of the previous patch ("ethdev: refine TPID handling in flow API") from which they were split following Andrew's rightful comment [1]. [1] http://dpdk.org/ml/archives/dev/2018-April/095870.html --- doc/guides/prog_guide/rte_flow.rst | 2 +- doc/guides/rel_notes/release_18_05.rst | 3 ++- lib/librte_ether/rte_flow.h | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index fd317b48c..c62a80566 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -806,7 +806,7 @@ preceding pattern item. - ``tci``: tag control information. - ``inner_type``: inner EtherType or TPID. -- Default ``mask`` matches TCI only. +- Default ``mask`` matches the VID part of TCI only (lower 12 bits). Item: ``IPV4`` ^^^^^^^^^^^^^^ diff --git a/doc/guides/rel_notes/release_18_05.rst b/doc/guides/rel_notes/release_18_05.rst index a980a23ae..9aca8b4c8 100644 --- a/doc/guides/rel_notes/release_18_05.rst +++ b/doc/guides/rel_notes/release_18_05.rst @@ -264,7 +264,8 @@ API Changes (``func`` for RSS hash function to apply and ``level`` for the encapsulation level). * The VLAN pattern item (``struct rte_flow_item_vlan``) was modified to - include inner EtherType instead of outer TPID. + include inner EtherType instead of outer TPID. Its default mask was also + modified to cover the VID part (lower 12 bits) of TCI only. ABI Changes diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index 8e50384d0..513734dce 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -493,7 +493,7 @@ struct rte_flow_item_vlan { /** Default mask for RTE_FLOW_ITEM_TYPE_VLAN. */ #ifndef __cplusplus static const struct rte_flow_item_vlan rte_flow_item_vlan_mask = { - .tci = RTE_BE16(0xffff), + .tci = RTE_BE16(0x0fff), .inner_type = RTE_BE16(0x0000), }; #endif -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v6 12/16] ethdev: add transfer attribute to flow API 2018-04-25 15:27 ` [dpdk-dev] [PATCH v6 00/16] Flow API overhaul for switch offloads Adrien Mazarguil ` (10 preceding siblings ...) 2018-04-25 15:27 ` [dpdk-dev] [PATCH v6 11/16] ethdev: fix default VLAN TCI mask " Adrien Mazarguil @ 2018-04-25 15:28 ` Adrien Mazarguil 2018-04-25 15:28 ` [dpdk-dev] [PATCH v6 13/16] ethdev: fix behavior of VF/PF in " Adrien Mazarguil ` (4 subsequent siblings) 16 siblings, 0 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-25 15:28 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev; +Cc: Andrew Rybchenko This new attribute enables applications to create flow rules that do not simply match traffic whose origin is specified in the pattern (e.g. some non-default physical port or VF), but actively affect it by applying the flow rule at the lowest possible level in the underlying device. It breaks ABI compatibility for the following public functions: - rte_flow_copy() - rte_flow_create() - rte_flow_validate() Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Cc: Andrew Rybchenko <arybchenko@solarflare.com> --- v6 changes: Updated API and ABI changes sections in release notes. v3 changes: Clarified definition for ingress and egress following Andrew's comment on subsequent patch. [1] http://dpdk.org/ml/archives/dev/2018-April/095961.html --- app/test-pmd/cmdline_flow.c | 11 +++++ app/test-pmd/config.c | 6 ++- doc/guides/prog_guide/rte_flow.rst | 26 +++++++++++- doc/guides/rel_notes/release_18_05.rst | 7 +++- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 11 ++--- drivers/net/bnxt/bnxt_filter.c | 8 ++++ drivers/net/e1000/igb_flow.c | 44 ++++++++++++++++++++ drivers/net/enic/enic_flow.c | 6 +++ drivers/net/i40e/i40e_flow.c | 8 ++++ drivers/net/ixgbe/ixgbe_flow.c | 53 ++++++++++++++++++++++++ drivers/net/mlx4/mlx4_flow.c | 4 ++ drivers/net/mlx5/mlx5_flow.c | 7 ++++ drivers/net/mvpp2/mrvl_flow.c | 6 +++ drivers/net/sfc/sfc_flow.c | 6 +++ drivers/net/tap/tap_flow.c | 6 +++ lib/librte_ether/rte_flow.h | 22 +++++++++- 16 files changed, 220 insertions(+), 11 deletions(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index f8f2a559e..1c6b5a112 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -69,6 +69,7 @@ enum index { PRIORITY, INGRESS, EGRESS, + TRANSFER, /* Validate/create pattern. */ PATTERN, @@ -407,6 +408,7 @@ static const enum index next_vc_attr[] = { PRIORITY, INGRESS, EGRESS, + TRANSFER, PATTERN, ZERO, }; @@ -960,6 +962,12 @@ static const struct token token_list[] = { .next = NEXT(next_vc_attr), .call = parse_vc, }, + [TRANSFER] = { + .name = "transfer", + .help = "apply rule directly to endpoints found in pattern", + .next = NEXT(next_vc_attr), + .call = parse_vc, + }, /* Validate/create pattern. */ [PATTERN] = { .name = "pattern", @@ -1945,6 +1953,9 @@ parse_vc(struct context *ctx, const struct token *token, case EGRESS: out->args.vc.attr.egress = 1; return len; + case TRANSFER: + out->args.vc.attr.transfer = 1; + return len; case PATTERN: out->args.vc.pattern = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1), diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 4b121aa79..a06514acc 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -1256,6 +1256,7 @@ port_flow_complain(struct rte_flow_error *error) [RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY] = "priority field", [RTE_FLOW_ERROR_TYPE_ATTR_INGRESS] = "ingress field", [RTE_FLOW_ERROR_TYPE_ATTR_EGRESS] = "egress field", + [RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER] = "transfer field", [RTE_FLOW_ERROR_TYPE_ATTR] = "attributes structure", [RTE_FLOW_ERROR_TYPE_ITEM_NUM] = "pattern length", [RTE_FLOW_ERROR_TYPE_ITEM_SPEC] = "item specification", @@ -1521,12 +1522,13 @@ port_flow_list(portid_t port_id, uint32_t n, const uint32_t group[n]) const struct rte_flow_item *item = pf->pattern; const struct rte_flow_action *action = pf->actions; - printf("%" PRIu32 "\t%" PRIu32 "\t%" PRIu32 "\t%c%c\t", + printf("%" PRIu32 "\t%" PRIu32 "\t%" PRIu32 "\t%c%c%c\t", pf->id, pf->attr.group, pf->attr.priority, pf->attr.ingress ? 'i' : '-', - pf->attr.egress ? 'e' : '-'); + pf->attr.egress ? 'e' : '-', + pf->attr.transfer ? 't' : '-'); while (item->type != RTE_FLOW_ITEM_TYPE_END) { if (item->type != RTE_FLOW_ITEM_TYPE_VOID) printf("%s ", flow_item[item->type].name); diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index c62a80566..550a4c95b 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -170,7 +170,13 @@ Note that support for more than a single priority level is not guaranteed. Attribute: Traffic direction ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Flow rules can apply to inbound and/or outbound traffic (ingress/egress). +Flow rule patterns apply to inbound and/or outbound traffic. + +In the context of this API, **ingress** and **egress** respectively stand +for **inbound** and **outbound** based on the standpoint of the application +creating a flow rule. + +There are no exceptions to this definition. Several pattern items and actions are valid and can be used in both directions. At least one direction must be specified. @@ -178,6 +184,24 @@ directions. At least one direction must be specified. Specifying both directions at once for a given rule is not recommended but may be valid in a few cases (e.g. shared counters). +Attribute: Transfer +^^^^^^^^^^^^^^^^^^^ + +Instead of simply matching the properties of traffic as it would appear on a +given DPDK port ID, enabling this attribute transfers a flow rule to the +lowest possible level of any device endpoints found in the pattern. + +When supported, this effectively enables an application to reroute traffic +not necessarily intended for it (e.g. coming from or addressed to different +physical ports, VFs or applications) at the device level. + +It complements the behavior of some pattern items such as `Item: PORT`_ and +is meaningless without them. + +When transferring flow rules, **ingress** and **egress** attributes +(`Attribute: Traffic direction`_) keep their original meaning, as if +processing traffic emitted or received by the application. + Pattern item ~~~~~~~~~~~~ diff --git a/doc/guides/rel_notes/release_18_05.rst b/doc/guides/rel_notes/release_18_05.rst index 9aca8b4c8..635b69aa1 100644 --- a/doc/guides/rel_notes/release_18_05.rst +++ b/doc/guides/rel_notes/release_18_05.rst @@ -266,6 +266,8 @@ API Changes * The VLAN pattern item (``struct rte_flow_item_vlan``) was modified to include inner EtherType instead of outer TPID. Its default mask was also modified to cover the VID part (lower 12 bits) of TCI only. + * A new transfer attribute was added to ``struct rte_flow_attr`` in order + to clarify the behavior of some pattern items. ABI Changes @@ -316,8 +318,9 @@ ABI Changes of the unused DUP action (``enum rte_flow_action_type``), modified behavior for flow rule actions (see API changes), removal of C99 flexible array from RAW pattern item (``struct rte_flow_item_raw``), complete - rework of the RSS action definition (``struct rte_flow_action_rss``) and - sanity fix in the VLAN pattern item (``struct rte_flow_item_vlan``). + rework of the RSS action definition (``struct rte_flow_action_rss``), + sanity fix in the VLAN pattern item (``struct rte_flow_item_vlan``) and + new transfer attribute (``struct rte_flow_attr``). Removed Items diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index 007b24ff3..454157dd4 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -2994,14 +2994,14 @@ following sections. - Check whether a flow rule can be created:: flow validate {port_id} - [group {group_id}] [priority {level}] [ingress] [egress] + [group {group_id}] [priority {level}] [ingress] [egress] [transfer] pattern {item} [/ {item} [...]] / end actions {action} [/ {action} [...]] / end - Create a flow rule:: flow create {port_id} - [group {group_id}] [priority {level}] [ingress] [egress] + [group {group_id}] [priority {level}] [ingress] [egress] [transfer] pattern {item} [/ {item} [...]] / end actions {action} [/ {action} [...]] / end @@ -3034,7 +3034,7 @@ underlying device in its current state but stops short of creating it. It is bound to ``rte_flow_validate()``:: flow validate {port_id} - [group {group_id}] [priority {level}] [ingress] [egress] + [group {group_id}] [priority {level}] [ingress] [egress] [transfer] pattern {item} [/ {item} [...]] / end actions {action} [/ {action} [...]] / end @@ -3071,7 +3071,7 @@ Creating flow rules to ``rte_flow_create()``:: flow create {port_id} - [group {group_id}] [priority {level}] [ingress] [egress] + [group {group_id}] [priority {level}] [ingress] [egress] [transfer] pattern {item} [/ {item} [...]] / end actions {action} [/ {action} [...]] / end @@ -3085,7 +3085,7 @@ Otherwise it will show an error message of the form:: Parameters describe in the following order: -- Attributes (*group*, *priority*, *ingress*, *egress* tokens). +- Attributes (*group*, *priority*, *ingress*, *egress*, *transfer* tokens). - A matching pattern, starting with the *pattern* token and terminated by an *end* pattern item. - Actions, starting with the *actions* token and terminated by an *end* @@ -3113,6 +3113,7 @@ specified before the ``pattern`` token. - ``priority {level}``: priority level within group. - ``ingress``: rule applies to ingress traffic. - ``egress``: rule applies to egress traffic. +- ``transfer``: apply rule directly to endpoints found in pattern. Each instance of an attribute specified several times overrides the previous value as shown below (group 4 is used):: diff --git a/drivers/net/bnxt/bnxt_filter.c b/drivers/net/bnxt/bnxt_filter.c index 25806bdc0..68deb3445 100644 --- a/drivers/net/bnxt/bnxt_filter.c +++ b/drivers/net/bnxt/bnxt_filter.c @@ -754,6 +754,14 @@ bnxt_flow_parse_attr(const struct rte_flow_attr *attr, } /* Not supported */ + if (attr->transfer) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + attr, "No support for transfer."); + return -rte_errno; + } + + /* Not supported */ if (attr->priority) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, diff --git a/drivers/net/e1000/igb_flow.c b/drivers/net/e1000/igb_flow.c index d1c0b4b8d..073852913 100644 --- a/drivers/net/e1000/igb_flow.c +++ b/drivers/net/e1000/igb_flow.c @@ -379,6 +379,15 @@ cons_parse_ntuple_filter(const struct rte_flow_attr *attr, return -rte_errno; } + /* not supported */ + if (attr->transfer) { + memset(filter, 0, sizeof(struct rte_eth_ntuple_filter)); + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + attr, "No support for transfer."); + return -rte_errno; + } + if (attr->priority > 0xFFFF) { memset(filter, 0, sizeof(struct rte_eth_ntuple_filter)); rte_flow_error_set(error, EINVAL, @@ -624,6 +633,14 @@ cons_parse_ethertype_filter(const struct rte_flow_attr *attr, } /* Not supported */ + if (attr->transfer) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + attr, "No support for transfer."); + return -rte_errno; + } + + /* Not supported */ if (attr->priority) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, @@ -923,6 +940,15 @@ cons_parse_syn_filter(const struct rte_flow_attr *attr, return -rte_errno; } + /* not supported */ + if (attr->transfer) { + memset(filter, 0, sizeof(struct rte_eth_syn_filter)); + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + attr, "No support for transfer."); + return -rte_errno; + } + /* Support 2 priorities, the lowest or highest. */ if (!attr->priority) { filter->hig_pri = 0; @@ -1211,6 +1237,15 @@ cons_parse_flex_filter(const struct rte_flow_attr *attr, return -rte_errno; } + /* not supported */ + if (attr->transfer) { + memset(filter, 0, sizeof(struct rte_eth_flex_filter)); + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + attr, "No support for transfer."); + return -rte_errno; + } + if (attr->priority > 0xFFFF) { memset(filter, 0, sizeof(struct rte_eth_flex_filter)); rte_flow_error_set(error, EINVAL, @@ -1361,6 +1396,15 @@ igb_parse_rss_filter(struct rte_eth_dev *dev, return -rte_errno; } + /* not supported */ + if (attr->transfer) { + memset(rss_conf, 0, sizeof(struct igb_rte_flow_rss_conf)); + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + attr, "No support for transfer."); + return -rte_errno; + } + if (attr->priority > 0xFFFF) { memset(rss_conf, 0, sizeof(struct igb_rte_flow_rss_conf)); rte_flow_error_set(error, EINVAL, diff --git a/drivers/net/enic/enic_flow.c b/drivers/net/enic/enic_flow.c index eea14ee73..525f3dd7c 100644 --- a/drivers/net/enic/enic_flow.c +++ b/drivers/net/enic/enic_flow.c @@ -1318,6 +1318,12 @@ enic_flow_parse(struct rte_eth_dev *dev, NULL, "egress is not supported"); return -rte_errno; + } else if (attrs->transfer) { + rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + NULL, + "transfer is not supported"); + return -rte_errno; } else if (!attrs->ingress) { rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c index 470ab93d6..f416b6a00 100644 --- a/drivers/net/i40e/i40e_flow.c +++ b/drivers/net/i40e/i40e_flow.c @@ -1918,6 +1918,14 @@ i40e_flow_parse_attr(const struct rte_flow_attr *attr, } /* Not supported */ + if (attr->transfer) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + attr, "No support for transfer."); + return -rte_errno; + } + + /* Not supported */ if (attr->priority) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, diff --git a/drivers/net/ixgbe/ixgbe_flow.c b/drivers/net/ixgbe/ixgbe_flow.c index 438bfcdfb..eb0644c82 100644 --- a/drivers/net/ixgbe/ixgbe_flow.c +++ b/drivers/net/ixgbe/ixgbe_flow.c @@ -557,6 +557,15 @@ cons_parse_ntuple_filter(const struct rte_flow_attr *attr, return -rte_errno; } + /* not supported */ + if (attr->transfer) { + memset(filter, 0, sizeof(struct rte_eth_ntuple_filter)); + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + attr, "No support for transfer."); + return -rte_errno; + } + if (attr->priority > 0xFFFF) { memset(filter, 0, sizeof(struct rte_eth_ntuple_filter)); rte_flow_error_set(error, EINVAL, @@ -787,6 +796,14 @@ cons_parse_ethertype_filter(const struct rte_flow_attr *attr, } /* Not supported */ + if (attr->transfer) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + attr, "No support for transfer."); + return -rte_errno; + } + + /* Not supported */ if (attr->priority) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, @@ -1078,6 +1095,15 @@ cons_parse_syn_filter(const struct rte_flow_attr *attr, return -rte_errno; } + /* not supported */ + if (attr->transfer) { + memset(filter, 0, sizeof(struct rte_eth_syn_filter)); + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + attr, "No support for transfer."); + return -rte_errno; + } + /* Support 2 priorities, the lowest or highest. */ if (!attr->priority) { filter->hig_pri = 0; @@ -1250,6 +1276,15 @@ cons_parse_l2_tn_filter(struct rte_eth_dev *dev, } /* not supported */ + if (attr->transfer) { + memset(filter, 0, sizeof(struct rte_eth_l2_tunnel_conf)); + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + attr, "No support for transfer."); + return -rte_errno; + } + + /* not supported */ if (attr->priority) { memset(filter, 0, sizeof(struct rte_eth_l2_tunnel_conf)); rte_flow_error_set(error, EINVAL, @@ -1354,6 +1389,15 @@ ixgbe_parse_fdir_act_attr(const struct rte_flow_attr *attr, } /* not supported */ + if (attr->transfer) { + memset(rule, 0, sizeof(struct ixgbe_fdir_rule)); + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + attr, "No support for transfer."); + return -rte_errno; + } + + /* not supported */ if (attr->priority) { memset(rule, 0, sizeof(struct ixgbe_fdir_rule)); rte_flow_error_set(error, EINVAL, @@ -2829,6 +2873,15 @@ ixgbe_parse_rss_filter(struct rte_eth_dev *dev, return -rte_errno; } + /* not supported */ + if (attr->transfer) { + memset(rss_conf, 0, sizeof(struct ixgbe_rte_flow_rss_conf)); + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + attr, "No support for transfer."); + return -rte_errno; + } + if (attr->priority > 0xFFFF) { memset(rss_conf, 0, sizeof(struct ixgbe_rte_flow_rss_conf)); rte_flow_error_set(error, EINVAL, diff --git a/drivers/net/mlx4/mlx4_flow.c b/drivers/net/mlx4/mlx4_flow.c index ce36ac715..e3d7aa8ef 100644 --- a/drivers/net/mlx4/mlx4_flow.c +++ b/drivers/net/mlx4/mlx4_flow.c @@ -652,6 +652,10 @@ mlx4_flow_prepare(struct priv *priv, return rte_flow_error_set (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, NULL, "egress is not supported"); + if (attr->transfer) + return rte_flow_error_set + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + NULL, "transfer is not supported"); if (!attr->ingress) return rte_flow_error_set (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index d77598b2d..41a7c6477 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -576,6 +576,13 @@ mlx5_flow_convert_attributes(const struct rte_flow_attr *attr, "egress is not supported"); return -rte_errno; } + if (attr->transfer) { + rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + NULL, + "transfer is not supported"); + return -rte_errno; + } if (!attr->ingress) { rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, diff --git a/drivers/net/mvpp2/mrvl_flow.c b/drivers/net/mvpp2/mrvl_flow.c index 6478eb2fe..a2e2129cc 100644 --- a/drivers/net/mvpp2/mrvl_flow.c +++ b/drivers/net/mvpp2/mrvl_flow.c @@ -2187,6 +2187,12 @@ mrvl_flow_parse_attr(struct mrvl_priv *priv __rte_unused, "Egress is not supported"); return -rte_errno; } + if (attr->transfer) { + rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, NULL, + "Transfer is not supported"); + return -rte_errno; + } return 0; } diff --git a/drivers/net/sfc/sfc_flow.c b/drivers/net/sfc/sfc_flow.c index cd6a61b39..bcde2c2f7 100644 --- a/drivers/net/sfc/sfc_flow.c +++ b/drivers/net/sfc/sfc_flow.c @@ -1116,6 +1116,12 @@ sfc_flow_parse_attr(const struct rte_flow_attr *attr, "Egress is not supported"); return -rte_errno; } + if (attr->transfer != 0) { + rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, attr, + "Transfer is not supported"); + return -rte_errno; + } if (attr->ingress == 0) { rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, attr, diff --git a/drivers/net/tap/tap_flow.c b/drivers/net/tap/tap_flow.c index dff09313a..ad2ba9f4e 100644 --- a/drivers/net/tap/tap_flow.c +++ b/drivers/net/tap/tap_flow.c @@ -1039,6 +1039,12 @@ priv_flow_process(struct pmd_internals *pmd, }; int action = 0; /* Only one action authorized for now */ + if (attr->transfer) { + rte_flow_error_set( + error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + NULL, "transfer is not supported"); + return -rte_errno; + } if (attr->group > MAX_GROUP) { rte_flow_error_set( error, EINVAL, RTE_FLOW_ERROR_TYPE_ATTR_GROUP, diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index 513734dce..ab2bf2dce 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -72,7 +72,26 @@ struct rte_flow_attr { uint32_t priority; /**< Priority level within group. */ uint32_t ingress:1; /**< Rule applies to ingress traffic. */ uint32_t egress:1; /**< Rule applies to egress traffic. */ - uint32_t reserved:30; /**< Reserved, must be zero. */ + /** + * Instead of simply matching the properties of traffic as it would + * appear on a given DPDK port ID, enabling this attribute transfers + * a flow rule to the lowest possible level of any device endpoints + * found in the pattern. + * + * When supported, this effectively enables an application to + * re-route traffic not necessarily intended for it (e.g. coming + * from or addressed to different physical ports, VFs or + * applications) at the device level. + * + * It complements the behavior of some pattern items such as + * RTE_FLOW_ITEM_TYPE_PORT and is meaningless without them. + * + * When transferring flow rules, ingress and egress attributes keep + * their original meaning, as if processing traffic emitted or + * received by the application. + */ + uint32_t transfer:1; + uint32_t reserved:29; /**< Reserved, must be zero. */ }; /** @@ -1181,6 +1200,7 @@ enum rte_flow_error_type { RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, /**< Priority field. */ RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, /**< Ingress field. */ RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, /**< Egress field. */ + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, /**< Transfer field. */ RTE_FLOW_ERROR_TYPE_ATTR, /**< Attributes structure. */ RTE_FLOW_ERROR_TYPE_ITEM_NUM, /**< Pattern length. */ RTE_FLOW_ERROR_TYPE_ITEM_SPEC, /**< Item specification. */ -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v6 13/16] ethdev: fix behavior of VF/PF in flow API 2018-04-25 15:27 ` [dpdk-dev] [PATCH v6 00/16] Flow API overhaul for switch offloads Adrien Mazarguil ` (11 preceding siblings ...) 2018-04-25 15:28 ` [dpdk-dev] [PATCH v6 12/16] ethdev: add transfer attribute to " Adrien Mazarguil @ 2018-04-25 15:28 ` Adrien Mazarguil 2018-04-25 15:28 ` [dpdk-dev] [PATCH v6 14/16] ethdev: rename physical port item " Adrien Mazarguil ` (3 subsequent siblings) 16 siblings, 0 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-25 15:28 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev Cc: Ajit Khaparde, Somnath Kotur, Beilei Xing, Qi Zhang Contrary to all other pattern items, these are inconsistently documented as affecting traffic instead of simply matching its origin, without provision for the latter. This commit clarifies documentation and updates PMDs since the original behavior now has to be explicitly requested using the new transfer attribute. It breaks ABI compatibility for the following public functions: - rte_flow_create() - rte_flow_validate() Impacted PMDs are bnxt and i40e, for which the VF pattern item is now only supported when a transfer attribute is also present. Fixes: b1a4b4cbc0a8 ("ethdev: introduce generic flow API") Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Cc: Ajit Khaparde <ajit.khaparde@broadcom.com> Cc: Somnath Kotur <somnath.kotur@broadcom.com> Cc: Beilei Xing <beilei.xing@intel.com> Cc: Qi Zhang <qi.z.zhang@intel.com> --- v6 changes: - Reworded patch title as a "fix" (not candidate for backports) since it addresses a flaw in the original API definition. - Updated API changes section in release notes. --- app/test-pmd/cmdline_flow.c | 12 +++--- doc/guides/prog_guide/rte_flow.rst | 36 +++++++++--------- doc/guides/rel_notes/release_18_05.rst | 3 ++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 12 +++--- drivers/net/bnxt/bnxt_filter.c | 22 ++++++----- drivers/net/i40e/i40e_flow.c | 23 +++++++----- lib/librte_ether/rte_flow.h | 47 ++++++++++-------------- 7 files changed, 80 insertions(+), 75 deletions(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 1c6b5a112..41103de67 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -1041,21 +1041,21 @@ static const struct token token_list[] = { }, [ITEM_PF] = { .name = "pf", - .help = "match packets addressed to the physical function", + .help = "match traffic from/to the physical function", .priv = PRIV_ITEM(PF, 0), .next = NEXT(NEXT_ENTRY(ITEM_NEXT)), .call = parse_vc, }, [ITEM_VF] = { .name = "vf", - .help = "match packets addressed to a virtual function ID", + .help = "match traffic from/to a virtual function ID", .priv = PRIV_ITEM(VF, sizeof(struct rte_flow_item_vf)), .next = NEXT(item_vf), .call = parse_vc, }, [ITEM_VF_ID] = { .name = "id", - .help = "destination VF ID", + .help = "VF ID", .next = NEXT(item_vf, NEXT_ENTRY(UNSIGNED), item_param), .args = ARGS(ARGS_ENTRY(struct rte_flow_item_vf, id)), }, @@ -1686,14 +1686,14 @@ static const struct token token_list[] = { }, [ACTION_PF] = { .name = "pf", - .help = "redirect packets to physical device function", + .help = "direct traffic to physical function", .priv = PRIV_ACTION(PF, 0), .next = NEXT(NEXT_ENTRY(ACTION_NEXT)), .call = parse_vc, }, [ACTION_VF] = { .name = "vf", - .help = "redirect packets to virtual device function", + .help = "direct traffic to a virtual function ID", .priv = PRIV_ACTION(VF, sizeof(struct rte_flow_action_vf)), .next = NEXT(action_vf), .call = parse_vc, @@ -1708,7 +1708,7 @@ static const struct token token_list[] = { }, [ACTION_VF_ID] = { .name = "id", - .help = "VF ID to redirect packets to", + .help = "VF ID", .next = NEXT(action_vf, NEXT_ENTRY(UNSIGNED)), .args = ARGS(ARGS_ENTRY(struct rte_flow_action_vf, id)), .call = parse_vc_conf, diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 550a4c95b..a0a124aa2 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -528,15 +528,12 @@ Usage example, matching non-TCPv4 packets only: Item: ``PF`` ^^^^^^^^^^^^ -Matches packets addressed to the physical function of the device. +Matches traffic originating from (ingress) or going to (egress) the physical +function of the current device. -If the underlying device function differs from the one that would normally -receive the matched traffic, specifying this item prevents it from reaching -that device unless the flow rule contains a `Action: PF`_. Packets are not -duplicated between device instances by default. +If supported, should work even if the physical function is not managed by +the application and thus not associated with a DPDK port ID. -- Likely to return an error or never match any traffic if applied to a VF - device. - Can be combined with any number of `Item: VF`_ to match both PF and VF traffic. - ``spec``, ``last`` and ``mask`` must not be set. @@ -558,15 +555,15 @@ duplicated between device instances by default. Item: ``VF`` ^^^^^^^^^^^^ -Matches packets addressed to a virtual function ID of the device. +Matches traffic originating from (ingress) or going to (egress) a given +virtual function of the current device. -If the underlying device function differs from the one that would normally -receive the matched traffic, specifying this item prevents it from reaching -that device unless the flow rule contains a `Action: VF`_. Packets are not -duplicated between device instances by default. +If supported, should work even if the virtual function is not managed by the +application and thus not associated with a DPDK port ID. + +Note this pattern item does not match VF representors traffic which, as +separate entities, should be addressed through their own DPDK port IDs. -- Likely to return an error or never match any traffic if this causes a VF - device to match traffic addressed to a different VF. - Can be specified multiple times to match traffic addressed to several VF IDs. - Can be combined with a PF item to match both PF and VF traffic. @@ -1395,7 +1392,10 @@ only matching traffic goes through. Action: ``PF`` ^^^^^^^^^^^^^^ -Redirects packets to the physical function (PF) of the current device. +Directs matching traffic to the physical function (PF) of the current +device. + +See `Item: PF`_. - No configurable properties. @@ -1412,13 +1412,15 @@ Redirects packets to the physical function (PF) of the current device. Action: ``VF`` ^^^^^^^^^^^^^^ -Redirects packets to a virtual function (VF) of the current device. +Directs matching traffic to a given virtual function of the current device. Packets matched by a VF pattern item can be redirected to their original VF ID instead of the specified one. This parameter may not be available and is not guaranteed to work properly if the VF part is matched by a prior flow rule or if packets are not addressed to a VF in the first place. +See `Item: VF`_. + .. _table_rte_flow_action_vf: .. table:: VF @@ -1428,7 +1430,7 @@ rule or if packets are not addressed to a VF in the first place. +==============+================================+ | ``original`` | use original VF ID if possible | +--------------+--------------------------------+ - | ``vf`` | VF ID to redirect packets to | + | ``id`` | VF ID | +--------------+--------------------------------+ Action: ``METER`` diff --git a/doc/guides/rel_notes/release_18_05.rst b/doc/guides/rel_notes/release_18_05.rst index 635b69aa1..ea133971f 100644 --- a/doc/guides/rel_notes/release_18_05.rst +++ b/doc/guides/rel_notes/release_18_05.rst @@ -268,6 +268,9 @@ API Changes modified to cover the VID part (lower 12 bits) of TCI only. * A new transfer attribute was added to ``struct rte_flow_attr`` in order to clarify the behavior of some pattern items. + * PF and VF pattern items are now only accepted by PMDs that implement + them (bnxt and i40e) when the transfer attribute is also present for + consistency. ABI Changes diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index 454157dd4..396a0599a 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3226,11 +3226,11 @@ This section lists supported pattern items and their attributes, if any. - ``num {unsigned}``: number of layers covered. -- ``pf``: match packets addressed to the physical function. +- ``pf``: match traffic from/to the physical function. -- ``vf``: match packets addressed to a virtual function ID. +- ``vf``: match traffic from/to a virtual function ID. - - ``id {unsigned}``: destination VF ID. + - ``id {unsigned}``: VF ID. - ``port``: device-specific physical port index to use. @@ -3440,12 +3440,12 @@ This section lists supported actions and their attributes, if any. - ``queues [{unsigned} [...]] end``: queue indices to use. -- ``pf``: redirect packets to physical device function. +- ``pf``: direct traffic to physical function. -- ``vf``: redirect packets to virtual device function. +- ``vf``: direct traffic to a virtual function ID. - ``original {boolean}``: use original VF ID if possible. - - ``id {unsigned}``: VF ID to redirect packets to. + - ``id {unsigned}``: VF ID. Destroying flow rules ~~~~~~~~~~~~~~~~~~~~~ diff --git a/drivers/net/bnxt/bnxt_filter.c b/drivers/net/bnxt/bnxt_filter.c index 68deb3445..dadd1e32f 100644 --- a/drivers/net/bnxt/bnxt_filter.c +++ b/drivers/net/bnxt/bnxt_filter.c @@ -283,6 +283,7 @@ bnxt_filter_type_check(const struct rte_flow_item pattern[], static int bnxt_validate_and_parse_flow_type(struct bnxt *bp, + const struct rte_flow_attr *attr, const struct rte_flow_item pattern[], struct rte_flow_error *error, struct bnxt_filter_info *filter) @@ -707,6 +708,16 @@ bnxt_validate_and_parse_flow_type(struct bnxt *bp, return -rte_errno; } + if (!attr->transfer) { + rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ITEM, + item, + "Matching VF traffic without" + " affecting it (transfer attribute)" + " is unsupported"); + return -rte_errno; + } + filter->mirror_vnic_id = dflt_vnic = bnxt_hwrm_func_qcfg_vf_dflt_vnic_id(bp, vf); if (dflt_vnic < 0) { @@ -754,14 +765,6 @@ bnxt_flow_parse_attr(const struct rte_flow_attr *attr, } /* Not supported */ - if (attr->transfer) { - rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, - attr, "No support for transfer."); - return -rte_errno; - } - - /* Not supported */ if (attr->priority) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, @@ -841,7 +844,8 @@ bnxt_validate_and_parse_flow(struct rte_eth_dev *dev, goto ret; } - rc = bnxt_validate_and_parse_flow_type(bp, pattern, error, filter); + rc = bnxt_validate_and_parse_flow_type(bp, attr, pattern, error, + filter); if (rc != 0) goto ret; diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c index f416b6a00..057e4f96d 100644 --- a/drivers/net/i40e/i40e_flow.c +++ b/drivers/net/i40e/i40e_flow.c @@ -54,6 +54,7 @@ static int i40e_flow_parse_ethertype_action(struct rte_eth_dev *dev, struct rte_flow_error *error, struct rte_eth_ethertype_filter *filter); static int i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev, + const struct rte_flow_attr *attr, const struct rte_flow_item *pattern, struct rte_flow_error *error, struct i40e_fdir_filter_conf *filter); @@ -1918,14 +1919,6 @@ i40e_flow_parse_attr(const struct rte_flow_attr *attr, } /* Not supported */ - if (attr->transfer) { - rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, - attr, "No support for transfer."); - return -rte_errno; - } - - /* Not supported */ if (attr->priority) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, @@ -2429,6 +2422,7 @@ i40e_flow_fdir_get_pctype_value(struct i40e_pf *pf, */ static int i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev, + const struct rte_flow_attr *attr, const struct rte_flow_item *pattern, struct rte_flow_error *error, struct i40e_fdir_filter_conf *filter) @@ -2966,6 +2960,16 @@ i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev, break; case RTE_FLOW_ITEM_TYPE_VF: vf_spec = item->spec; + if (!attr->transfer) { + rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ITEM, + item, + "Matching VF traffic" + " without affecting it" + " (transfer attribute)" + " is unsupported"); + return -rte_errno; + } filter->input.flow_ext.is_vf = 1; filter->input.flow_ext.dst_id = vf_spec->id; if (filter->input.flow_ext.is_vf && @@ -3128,7 +3132,8 @@ i40e_flow_parse_fdir_filter(struct rte_eth_dev *dev, &filter->fdir_filter; int ret; - ret = i40e_flow_parse_fdir_pattern(dev, pattern, error, fdir_filter); + ret = i40e_flow_parse_fdir_pattern(dev, attr, pattern, error, + fdir_filter); if (ret) return ret; diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index ab2bf2dce..f1c7a664e 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -152,13 +152,8 @@ enum rte_flow_item_type { /** * [META] * - * Matches packets addressed to the physical function of the device. - * - * If the underlying device function differs from the one that would - * normally receive the matched traffic, specifying this item - * prevents it from reaching that device unless the flow rule - * contains a PF action. Packets are not duplicated between device - * instances by default. + * Matches traffic originating from (ingress) or going to (egress) + * the physical function of the current device. * * No associated specification structure. */ @@ -167,13 +162,8 @@ enum rte_flow_item_type { /** * [META] * - * Matches packets addressed to a virtual function ID of the device. - * - * If the underlying device function differs from the one that would - * normally receive the matched traffic, specifying this item - * prevents it from reaching that device unless the flow rule - * contains a VF action. Packets are not duplicated between device - * instances by default. + * Matches traffic originating from (ingress) or going to (egress) a + * given virtual function of the current device. * * See struct rte_flow_item_vf. */ @@ -371,15 +361,15 @@ static const struct rte_flow_item_any rte_flow_item_any_mask = { /** * RTE_FLOW_ITEM_TYPE_VF * - * Matches packets addressed to a virtual function ID of the device. + * Matches traffic originating from (ingress) or going to (egress) a given + * virtual function of the current device. * - * If the underlying device function differs from the one that would - * normally receive the matched traffic, specifying this item prevents it - * from reaching that device unless the flow rule contains a VF - * action. Packets are not duplicated between device instances by default. + * If supported, should work even if the virtual function is not managed by + * the application and thus not associated with a DPDK port ID. + * + * Note this pattern item does not match VF representors traffic which, as + * separate entities, should be addressed through their own DPDK port IDs. * - * - Likely to return an error or never match any traffic if this causes a - * VF device to match traffic addressed to a different VF. * - Can be specified multiple times to match traffic addressed to several * VF IDs. * - Can be combined with a PF item to match both PF and VF traffic. @@ -387,7 +377,7 @@ static const struct rte_flow_item_any rte_flow_item_any_mask = { * A zeroed mask can be used to match any VF ID. */ struct rte_flow_item_vf { - uint32_t id; /**< Destination VF ID. */ + uint32_t id; /**< VF ID. */ }; /** Default mask for RTE_FLOW_ITEM_TYPE_VF. */ @@ -988,16 +978,16 @@ enum rte_flow_action_type { RTE_FLOW_ACTION_TYPE_RSS, /** - * Redirects packets to the physical function (PF) of the current - * device. + * Directs matching traffic to the physical function (PF) of the + * current device. * * No associated configuration structure. */ RTE_FLOW_ACTION_TYPE_PF, /** - * Redirects packets to the virtual function (VF) of the current - * device with the specified ID. + * Directs matching traffic to a given virtual function of the + * current device. * * See struct rte_flow_action_vf. */ @@ -1111,7 +1101,8 @@ struct rte_flow_action_rss { /** * RTE_FLOW_ACTION_TYPE_VF * - * Redirects packets to a virtual function (VF) of the current device. + * Directs matching traffic to a given virtual function of the current + * device. * * Packets matched by a VF pattern item can be redirected to their original * VF ID instead of the specified one. This parameter may not be available @@ -1122,7 +1113,7 @@ struct rte_flow_action_rss { struct rte_flow_action_vf { uint32_t original:1; /**< Use original VF ID if possible. */ uint32_t reserved:31; /**< Reserved, must be zero. */ - uint32_t id; /**< VF ID to redirect packets to. */ + uint32_t id; /**< VF ID. */ }; /** -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v6 14/16] ethdev: rename physical port item in flow API 2018-04-25 15:27 ` [dpdk-dev] [PATCH v6 00/16] Flow API overhaul for switch offloads Adrien Mazarguil ` (12 preceding siblings ...) 2018-04-25 15:28 ` [dpdk-dev] [PATCH v6 13/16] ethdev: fix behavior of VF/PF in " Adrien Mazarguil @ 2018-04-25 15:28 ` Adrien Mazarguil 2018-04-25 15:28 ` [dpdk-dev] [PATCH v6 15/16] ethdev: add physical port action to " Adrien Mazarguil ` (2 subsequent siblings) 16 siblings, 0 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-25 15:28 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev While RTE_FLOW_ITEM_TYPE_PORT refers to physical ports of the underlying device using specific identifiers, these are often confused with DPDK port IDs exposed to applications in the global name space. Since this pattern item is seldom used, rename it RTE_FLOW_ITEM_PHY_PORT for better clarity. No ABI impact. Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Acked-by: Andrew Rybchenko <arybchenko@solarflare.com> --- v6 changes: Updated API changes section in release notes. --- app/test-pmd/cmdline_flow.c | 27 +++++++++++---------- app/test-pmd/config.c | 2 +- doc/guides/prog_guide/rte_flow.rst | 22 ++++++++--------- doc/guides/rel_notes/release_18_05.rst | 2 ++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 2 +- lib/librte_ether/rte_flow.c | 2 +- lib/librte_ether/rte_flow.h | 31 ++++++++++-------------- 7 files changed, 43 insertions(+), 45 deletions(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 41103de67..f9f937277 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -87,8 +87,8 @@ enum index { ITEM_PF, ITEM_VF, ITEM_VF_ID, - ITEM_PORT, - ITEM_PORT_INDEX, + ITEM_PHY_PORT, + ITEM_PHY_PORT_INDEX, ITEM_RAW, ITEM_RAW_RELATIVE, ITEM_RAW_SEARCH, @@ -441,7 +441,7 @@ static const enum index next_item[] = { ITEM_ANY, ITEM_PF, ITEM_VF, - ITEM_PORT, + ITEM_PHY_PORT, ITEM_RAW, ITEM_ETH, ITEM_VLAN, @@ -482,8 +482,8 @@ static const enum index item_vf[] = { ZERO, }; -static const enum index item_port[] = { - ITEM_PORT_INDEX, +static const enum index item_phy_port[] = { + ITEM_PHY_PORT_INDEX, ITEM_NEXT, ZERO, }; @@ -1059,18 +1059,19 @@ static const struct token token_list[] = { .next = NEXT(item_vf, NEXT_ENTRY(UNSIGNED), item_param), .args = ARGS(ARGS_ENTRY(struct rte_flow_item_vf, id)), }, - [ITEM_PORT] = { - .name = "port", - .help = "device-specific physical port index to use", - .priv = PRIV_ITEM(PORT, sizeof(struct rte_flow_item_port)), - .next = NEXT(item_port), + [ITEM_PHY_PORT] = { + .name = "phy_port", + .help = "match traffic from/to a specific physical port", + .priv = PRIV_ITEM(PHY_PORT, + sizeof(struct rte_flow_item_phy_port)), + .next = NEXT(item_phy_port), .call = parse_vc, }, - [ITEM_PORT_INDEX] = { + [ITEM_PHY_PORT_INDEX] = { .name = "index", .help = "physical port index", - .next = NEXT(item_port, NEXT_ENTRY(UNSIGNED), item_param), - .args = ARGS(ARGS_ENTRY(struct rte_flow_item_port, index)), + .next = NEXT(item_phy_port, NEXT_ENTRY(UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_phy_port, index)), }, [ITEM_RAW] = { .name = "raw", diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index a06514acc..d168e515d 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -993,7 +993,7 @@ static const struct { MK_FLOW_ITEM(ANY, sizeof(struct rte_flow_item_any)), MK_FLOW_ITEM(PF, 0), MK_FLOW_ITEM(VF, sizeof(struct rte_flow_item_vf)), - MK_FLOW_ITEM(PORT, sizeof(struct rte_flow_item_port)), + MK_FLOW_ITEM(PHY_PORT, sizeof(struct rte_flow_item_phy_port)), MK_FLOW_ITEM(RAW, sizeof(struct rte_flow_item_raw)), MK_FLOW_ITEM(ETH, sizeof(struct rte_flow_item_eth)), MK_FLOW_ITEM(VLAN, sizeof(struct rte_flow_item_vlan)), diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index a0a124aa2..4e053c24b 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -195,8 +195,8 @@ When supported, this effectively enables an application to reroute traffic not necessarily intended for it (e.g. coming from or addressed to different physical ports, VFs or applications) at the device level. -It complements the behavior of some pattern items such as `Item: PORT`_ and -is meaningless without them. +It complements the behavior of some pattern items such as `Item: PHY_PORT`_ +and is meaningless without them. When transferring flow rules, **ingress** and **egress** attributes (`Attribute: Traffic direction`_) keep their original meaning, as if @@ -583,15 +583,15 @@ separate entities, should be addressed through their own DPDK port IDs. | ``mask`` | ``id`` | zeroed to match any VF ID | +----------+----------+---------------------------+ -Item: ``PORT`` -^^^^^^^^^^^^^^ +Item: ``PHY_PORT`` +^^^^^^^^^^^^^^^^^^ -Matches packets coming from the specified physical port of the underlying -device. +Matches traffic originating from (ingress) or going to (egress) a physical +port of the underlying device. -The first PORT item overrides the physical port normally associated with the -specified DPDK input port (port_id). This item can be provided several times -to match additional physical ports. +The first PHY_PORT item overrides the physical port normally associated with +the specified DPDK input port (port_id). This item can be provided several +times to match additional physical ports. Note that physical ports are not necessarily tied to DPDK input ports (port_id) when those are not under DPDK control. Possible values are @@ -603,9 +603,9 @@ associated with a port_id should be retrieved by other means. - Default ``mask`` matches any port index. -.. _table_rte_flow_item_port: +.. _table_rte_flow_item_phy_port: -.. table:: PORT +.. table:: PHY_PORT +----------+-----------+--------------------------------+ | Field | Subfield | Value | diff --git a/doc/guides/rel_notes/release_18_05.rst b/doc/guides/rel_notes/release_18_05.rst index ea133971f..86dd710d2 100644 --- a/doc/guides/rel_notes/release_18_05.rst +++ b/doc/guides/rel_notes/release_18_05.rst @@ -271,6 +271,8 @@ API Changes * PF and VF pattern items are now only accepted by PMDs that implement them (bnxt and i40e) when the transfer attribute is also present for consistency. + * Pattern item PORT was renamed PHY_PORT to avoid confusion with DPDK port + IDs. ABI Changes diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index 396a0599a..51d36d346 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3232,7 +3232,7 @@ This section lists supported pattern items and their attributes, if any. - ``id {unsigned}``: VF ID. -- ``port``: device-specific physical port index to use. +- ``phy_port``: match traffic from/to a specific physical port. - ``index {unsigned}``: physical port index. diff --git a/lib/librte_ether/rte_flow.c b/lib/librte_ether/rte_flow.c index 83b733ff0..36e277a4f 100644 --- a/lib/librte_ether/rte_flow.c +++ b/lib/librte_ether/rte_flow.c @@ -38,7 +38,7 @@ static const struct rte_flow_desc_data rte_flow_desc_item[] = { MK_FLOW_ITEM(ANY, sizeof(struct rte_flow_item_any)), MK_FLOW_ITEM(PF, 0), MK_FLOW_ITEM(VF, sizeof(struct rte_flow_item_vf)), - MK_FLOW_ITEM(PORT, sizeof(struct rte_flow_item_port)), + MK_FLOW_ITEM(PHY_PORT, sizeof(struct rte_flow_item_phy_port)), MK_FLOW_ITEM(RAW, sizeof(struct rte_flow_item_raw)), MK_FLOW_ITEM(ETH, sizeof(struct rte_flow_item_eth)), MK_FLOW_ITEM(VLAN, sizeof(struct rte_flow_item_vlan)), diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index f1c7a664e..2c7c4d009 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -84,7 +84,7 @@ struct rte_flow_attr { * applications) at the device level. * * It complements the behavior of some pattern items such as - * RTE_FLOW_ITEM_TYPE_PORT and is meaningless without them. + * RTE_FLOW_ITEM_TYPE_PHY_PORT and is meaningless without them. * * When transferring flow rules, ingress and egress attributes keep * their original meaning, as if processing traffic emitted or @@ -172,17 +172,12 @@ enum rte_flow_item_type { /** * [META] * - * Matches packets coming from the specified physical port of the - * underlying device. - * - * The first PORT item overrides the physical port normally - * associated with the specified DPDK input port (port_id). This - * item can be provided several times to match additional physical - * ports. + * Matches traffic originating from (ingress) or going to (egress) a + * physical port of the underlying device. * - * See struct rte_flow_item_port. + * See struct rte_flow_item_phy_port. */ - RTE_FLOW_ITEM_TYPE_PORT, + RTE_FLOW_ITEM_TYPE_PHY_PORT, /** * Matches a byte string of a given length at a given offset. @@ -388,13 +383,13 @@ static const struct rte_flow_item_vf rte_flow_item_vf_mask = { #endif /** - * RTE_FLOW_ITEM_TYPE_PORT + * RTE_FLOW_ITEM_TYPE_PHY_PORT * - * Matches packets coming from the specified physical port of the underlying - * device. + * Matches traffic originating from (ingress) or going to (egress) a + * physical port of the underlying device. * - * The first PORT item overrides the physical port normally associated with - * the specified DPDK input port (port_id). This item can be provided + * The first PHY_PORT item overrides the physical port normally associated + * with the specified DPDK input port (port_id). This item can be provided * several times to match additional physical ports. * * Note that physical ports are not necessarily tied to DPDK input ports @@ -407,13 +402,13 @@ static const struct rte_flow_item_vf rte_flow_item_vf_mask = { * * A zeroed mask can be used to match any port index. */ -struct rte_flow_item_port { +struct rte_flow_item_phy_port { uint32_t index; /**< Physical port index. */ }; -/** Default mask for RTE_FLOW_ITEM_TYPE_PORT. */ +/** Default mask for RTE_FLOW_ITEM_TYPE_PHY_PORT. */ #ifndef __cplusplus -static const struct rte_flow_item_port rte_flow_item_port_mask = { +static const struct rte_flow_item_phy_port rte_flow_item_phy_port_mask = { .index = 0x00000000, }; #endif -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v6 15/16] ethdev: add physical port action to flow API 2018-04-25 15:27 ` [dpdk-dev] [PATCH v6 00/16] Flow API overhaul for switch offloads Adrien Mazarguil ` (13 preceding siblings ...) 2018-04-25 15:28 ` [dpdk-dev] [PATCH v6 14/16] ethdev: rename physical port item " Adrien Mazarguil @ 2018-04-25 15:28 ` Adrien Mazarguil 2018-04-25 15:28 ` [dpdk-dev] [PATCH v6 16/16] ethdev: add port ID item and " Adrien Mazarguil 2018-04-25 17:34 ` [dpdk-dev] [PATCH v6 00/16] Flow API overhaul for switch offloads Ferruh Yigit 16 siblings, 0 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-25 15:28 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev; +Cc: Zhang, Qi Z This patch adds the missing action counterpart to the PHY_PORT pattern item, that is, the ability to directly inject matching traffic into a physical port of the underlying device. It breaks ABI compatibility for the following public functions: - rte_flow_copy() - rte_flow_create() - rte_flow_query() - rte_flow_validate() Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Acked-by: Andrew Rybchenko <arybchenko@solarflare.com> Acked-by: Mohammad Abdul Awal <mohammad.abdul.awal@intel.com> Cc: "Zhang, Qi Z" <qi.z.zhang@intel.com> --- v6 changes: Updated API changes section in release notes. --- app/test-pmd/cmdline_flow.c | 35 ++++++++++++++++++++++++ app/test-pmd/config.c | 1 + doc/guides/prog_guide/rte_flow.rst | 20 ++++++++++++++ doc/guides/rel_notes/release_18_05.rst | 2 ++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 5 ++++ lib/librte_ether/rte_flow.c | 1 + lib/librte_ether/rte_flow.h | 22 +++++++++++++++ 7 files changed, 86 insertions(+) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index f9f937277..356714801 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -182,6 +182,9 @@ enum index { ACTION_VF, ACTION_VF_ORIGINAL, ACTION_VF_ID, + ACTION_PHY_PORT, + ACTION_PHY_PORT_ORIGINAL, + ACTION_PHY_PORT_INDEX, ACTION_METER, ACTION_METER_ID, }; @@ -623,6 +626,7 @@ static const enum index next_action[] = { ACTION_RSS, ACTION_PF, ACTION_VF, + ACTION_PHY_PORT, ACTION_METER, ZERO, }; @@ -657,6 +661,13 @@ static const enum index action_vf[] = { ZERO, }; +static const enum index action_phy_port[] = { + ACTION_PHY_PORT_ORIGINAL, + ACTION_PHY_PORT_INDEX, + ACTION_NEXT, + ZERO, +}; + static const enum index action_meter[] = { ACTION_METER_ID, ACTION_NEXT, @@ -1714,6 +1725,30 @@ static const struct token token_list[] = { .args = ARGS(ARGS_ENTRY(struct rte_flow_action_vf, id)), .call = parse_vc_conf, }, + [ACTION_PHY_PORT] = { + .name = "phy_port", + .help = "direct packets to physical port index", + .priv = PRIV_ACTION(PHY_PORT, + sizeof(struct rte_flow_action_phy_port)), + .next = NEXT(action_phy_port), + .call = parse_vc, + }, + [ACTION_PHY_PORT_ORIGINAL] = { + .name = "original", + .help = "use original port index if possible", + .next = NEXT(action_phy_port, NEXT_ENTRY(BOOLEAN)), + .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_phy_port, + original, 1)), + .call = parse_vc_conf, + }, + [ACTION_PHY_PORT_INDEX] = { + .name = "index", + .help = "physical port index", + .next = NEXT(action_phy_port, NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_phy_port, + index)), + .call = parse_vc_conf, + }, [ACTION_METER] = { .name = "meter", .help = "meter the directed packets at given id", diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index d168e515d..869c6663b 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -1091,6 +1091,7 @@ static const struct { MK_FLOW_ACTION(RSS, sizeof(struct rte_flow_action_rss)), MK_FLOW_ACTION(PF, 0), MK_FLOW_ACTION(VF, sizeof(struct rte_flow_action_vf)), + MK_FLOW_ACTION(PHY_PORT, sizeof(struct rte_flow_action_phy_port)), MK_FLOW_ACTION(METER, sizeof(struct rte_flow_action_meter)), }; diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 4e053c24b..a39c1e1b0 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -1433,6 +1433,26 @@ See `Item: VF`_. | ``id`` | VF ID | +--------------+--------------------------------+ +Action: ``PHY_PORT`` +^^^^^^^^^^^^^^^^^^^^ + +Directs matching traffic to a given physical port index of the underlying +device. + +See `Item: PHY_PORT`_. + +.. _table_rte_flow_action_phy_port: + +.. table:: PHY_PORT + + +--------------+-------------------------------------+ + | Field | Value | + +==============+=====================================+ + | ``original`` | use original port index if possible | + +--------------+-------------------------------------+ + | ``index`` | physical port index | + +--------------+-------------------------------------+ + Action: ``METER`` ^^^^^^^^^^^^^^^^^ diff --git a/doc/guides/rel_notes/release_18_05.rst b/doc/guides/rel_notes/release_18_05.rst index 86dd710d2..211f68da1 100644 --- a/doc/guides/rel_notes/release_18_05.rst +++ b/doc/guides/rel_notes/release_18_05.rst @@ -273,6 +273,8 @@ API Changes consistency. * Pattern item PORT was renamed PHY_PORT to avoid confusion with DPDK port IDs. + * An action counterpart to the PHY_PORT pattern item was added in order to + redirect matching traffic to a specific physical port. ABI Changes diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index 51d36d346..9733a7262 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3447,6 +3447,11 @@ This section lists supported actions and their attributes, if any. - ``original {boolean}``: use original VF ID if possible. - ``id {unsigned}``: VF ID. +- ``phy_port``: direct packets to physical port index. + + - ``original {boolean}``: use original port index if possible. + - ``index {unsigned}``: physical port index. + Destroying flow rules ~~~~~~~~~~~~~~~~~~~~~ diff --git a/lib/librte_ether/rte_flow.c b/lib/librte_ether/rte_flow.c index 36e277a4f..00989c73b 100644 --- a/lib/librte_ether/rte_flow.c +++ b/lib/librte_ether/rte_flow.c @@ -76,6 +76,7 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = { MK_FLOW_ACTION(RSS, sizeof(struct rte_flow_action_rss)), MK_FLOW_ACTION(PF, 0), MK_FLOW_ACTION(VF, sizeof(struct rte_flow_action_vf)), + MK_FLOW_ACTION(PHY_PORT, sizeof(struct rte_flow_action_phy_port)), }; static int diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index 2c7c4d009..58b75e934 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -989,6 +989,14 @@ enum rte_flow_action_type { RTE_FLOW_ACTION_TYPE_VF, /** + * Directs packets to a given physical port index of the underlying + * device. + * + * See struct rte_flow_action_phy_port. + */ + RTE_FLOW_ACTION_TYPE_PHY_PORT, + + /** * Traffic metering and policing (MTR). * * See struct rte_flow_action_meter. @@ -1112,6 +1120,20 @@ struct rte_flow_action_vf { }; /** + * RTE_FLOW_ACTION_TYPE_PHY_PORT + * + * Directs packets to a given physical port index of the underlying + * device. + * + * @see RTE_FLOW_ITEM_TYPE_PHY_PORT + */ +struct rte_flow_action_phy_port { + uint32_t original:1; /**< Use original port index if possible. */ + uint32_t reserved:31; /**< Reserved, must be zero. */ + uint32_t index; /**< Physical port index. */ +}; + +/** * RTE_FLOW_ACTION_TYPE_METER * * Traffic metering and policing (MTR). -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* [dpdk-dev] [PATCH v6 16/16] ethdev: add port ID item and action to flow API 2018-04-25 15:27 ` [dpdk-dev] [PATCH v6 00/16] Flow API overhaul for switch offloads Adrien Mazarguil ` (14 preceding siblings ...) 2018-04-25 15:28 ` [dpdk-dev] [PATCH v6 15/16] ethdev: add physical port action to " Adrien Mazarguil @ 2018-04-25 15:28 ` Adrien Mazarguil 2018-04-25 17:34 ` [dpdk-dev] [PATCH v6 00/16] Flow API overhaul for switch offloads Ferruh Yigit 16 siblings, 0 replies; 157+ messages in thread From: Adrien Mazarguil @ 2018-04-25 15:28 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, dev; +Cc: Zhang, Qi Z, Declan Doherty RTE_FLOW_ACTION_TYPE_PORT_ID brings the ability to inject matching traffic into a different device, as identified by its DPDK port ID. This is normally only supported when the target port ID has some kind of relationship with the port ID the flow rule is created against, such as being exposed by a common physical device (e.g. a different port of an Ethernet switch). The converse pattern item, RTE_FLOW_ITEM_TYPE_PORT_ID, makes the resulting flow rule match traffic whose origin is the specified port ID. Note that specifying a port ID that differs from the one the flow rule is created against is normally meaningless (if even accepted), but can make sense if combined with the transfer attribute. These must not be confused with their PHY_PORT counterparts, which refer to physical ports using device-specific indices, but unlike PORT_ID are not necessarily tied to DPDK port IDs. This breaks ABI compatibility for the following public functions: - rte_flow_copy() - rte_flow_create() - rte_flow_query() - rte_flow_validate() Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Reviewed-by: Qi Zhang <qi.z.zhang@intel.com> Acked-by: Andrew Rybchenko <arybchenko@solarflare.com> Cc: "Zhang, Qi Z" <qi.z.zhang@intel.com> Cc: Declan Doherty <declan.doherty@intel.com> --- v6 changes: Updated API changes section in release notes. v1: This patch provides the same functionality and supersedes Qi Zhang's "ether: add flow action to redirect packet to a port" [1]. The main differences are: - Action is named PORT_ID instead of PORT. - Addition of a PORT_ID pattern item. - More extensive documentation. - Testpmd support. - rte_flow_copy() support. [1] http://dpdk.org/ml/archives/dev/2018-April/094648.html --- app/test-pmd/cmdline_flow.c | 57 ++++++++++++++++++++++++ app/test-pmd/config.c | 2 + doc/guides/prog_guide/rte_flow.rst | 48 ++++++++++++++++++++ doc/guides/rel_notes/release_18_05.rst | 2 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 9 ++++ lib/librte_ether/rte_flow.c | 2 + lib/librte_ether/rte_flow.h | 56 +++++++++++++++++++++++ 7 files changed, 176 insertions(+) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 356714801..32fe6645a 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -89,6 +89,8 @@ enum index { ITEM_VF_ID, ITEM_PHY_PORT, ITEM_PHY_PORT_INDEX, + ITEM_PORT_ID, + ITEM_PORT_ID_ID, ITEM_RAW, ITEM_RAW_RELATIVE, ITEM_RAW_SEARCH, @@ -185,6 +187,9 @@ enum index { ACTION_PHY_PORT, ACTION_PHY_PORT_ORIGINAL, ACTION_PHY_PORT_INDEX, + ACTION_PORT_ID, + ACTION_PORT_ID_ORIGINAL, + ACTION_PORT_ID_ID, ACTION_METER, ACTION_METER_ID, }; @@ -445,6 +450,7 @@ static const enum index next_item[] = { ITEM_PF, ITEM_VF, ITEM_PHY_PORT, + ITEM_PORT_ID, ITEM_RAW, ITEM_ETH, ITEM_VLAN, @@ -491,6 +497,12 @@ static const enum index item_phy_port[] = { ZERO, }; +static const enum index item_port_id[] = { + ITEM_PORT_ID_ID, + ITEM_NEXT, + ZERO, +}; + static const enum index item_raw[] = { ITEM_RAW_RELATIVE, ITEM_RAW_SEARCH, @@ -627,6 +639,7 @@ static const enum index next_action[] = { ACTION_PF, ACTION_VF, ACTION_PHY_PORT, + ACTION_PORT_ID, ACTION_METER, ZERO, }; @@ -668,6 +681,13 @@ static const enum index action_phy_port[] = { ZERO, }; +static const enum index action_port_id[] = { + ACTION_PORT_ID_ORIGINAL, + ACTION_PORT_ID_ID, + ACTION_NEXT, + ZERO, +}; + static const enum index action_meter[] = { ACTION_METER_ID, ACTION_NEXT, @@ -1084,6 +1104,20 @@ static const struct token token_list[] = { .next = NEXT(item_phy_port, NEXT_ENTRY(UNSIGNED), item_param), .args = ARGS(ARGS_ENTRY(struct rte_flow_item_phy_port, index)), }, + [ITEM_PORT_ID] = { + .name = "port_id", + .help = "match traffic from/to a given DPDK port ID", + .priv = PRIV_ITEM(PORT_ID, + sizeof(struct rte_flow_item_port_id)), + .next = NEXT(item_port_id), + .call = parse_vc, + }, + [ITEM_PORT_ID_ID] = { + .name = "id", + .help = "DPDK port ID", + .next = NEXT(item_port_id, NEXT_ENTRY(UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_port_id, id)), + }, [ITEM_RAW] = { .name = "raw", .help = "match an arbitrary byte string", @@ -1749,6 +1783,29 @@ static const struct token token_list[] = { index)), .call = parse_vc_conf, }, + [ACTION_PORT_ID] = { + .name = "port_id", + .help = "direct matching traffic to a given DPDK port ID", + .priv = PRIV_ACTION(PORT_ID, + sizeof(struct rte_flow_action_port_id)), + .next = NEXT(action_port_id), + .call = parse_vc, + }, + [ACTION_PORT_ID_ORIGINAL] = { + .name = "original", + .help = "use original DPDK port ID if possible", + .next = NEXT(action_port_id, NEXT_ENTRY(BOOLEAN)), + .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_port_id, + original, 1)), + .call = parse_vc_conf, + }, + [ACTION_PORT_ID_ID] = { + .name = "id", + .help = "DPDK port ID", + .next = NEXT(action_port_id, NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_port_id, id)), + .call = parse_vc_conf, + }, [ACTION_METER] = { .name = "meter", .help = "meter the directed packets at given id", diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 869c6663b..8e56c0668 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -994,6 +994,7 @@ static const struct { MK_FLOW_ITEM(PF, 0), MK_FLOW_ITEM(VF, sizeof(struct rte_flow_item_vf)), MK_FLOW_ITEM(PHY_PORT, sizeof(struct rte_flow_item_phy_port)), + MK_FLOW_ITEM(PORT_ID, sizeof(struct rte_flow_item_port_id)), MK_FLOW_ITEM(RAW, sizeof(struct rte_flow_item_raw)), MK_FLOW_ITEM(ETH, sizeof(struct rte_flow_item_eth)), MK_FLOW_ITEM(VLAN, sizeof(struct rte_flow_item_vlan)), @@ -1092,6 +1093,7 @@ static const struct { MK_FLOW_ACTION(PF, 0), MK_FLOW_ACTION(VF, sizeof(struct rte_flow_action_vf)), MK_FLOW_ACTION(PHY_PORT, sizeof(struct rte_flow_action_phy_port)), + MK_FLOW_ACTION(PORT_ID, sizeof(struct rte_flow_action_port_id)), MK_FLOW_ACTION(METER, sizeof(struct rte_flow_action_meter)), }; diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index a39c1e1b0..2fb8e9c3f 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -617,6 +617,36 @@ associated with a port_id should be retrieved by other means. | ``mask`` | ``index`` | zeroed to match any port index | +----------+-----------+--------------------------------+ +Item: ``PORT_ID`` +^^^^^^^^^^^^^^^^^ + +Matches traffic originating from (ingress) or going to (egress) a given DPDK +port ID. + +Normally only supported if the port ID in question is known by the +underlying PMD and related to the device the flow rule is created against. + +This must not be confused with `Item: PHY_PORT`_ which refers to the +physical port of a device, whereas `Item: PORT_ID`_ refers to a ``struct +rte_eth_dev`` object on the application side (also known as "port +representor" depending on the kind of underlying device). + +- Default ``mask`` matches the specified DPDK port ID. + +.. _table_rte_flow_item_port_id: + +.. table:: PORT_ID + + +----------+----------+-----------------------------+ + | Field | Subfield | Value | + +==========+==========+=============================+ + | ``spec`` | ``id`` | DPDK port ID | + +----------+----------+-----------------------------+ + | ``last`` | ``id`` | upper range value | + +----------+----------+-----------------------------+ + | ``mask`` | ``id`` | zeroed to match any port ID | + +----------+----------+-----------------------------+ + Data matching item types ~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1453,6 +1483,24 @@ See `Item: PHY_PORT`_. | ``index`` | physical port index | +--------------+-------------------------------------+ +Action: ``PORT_ID`` +^^^^^^^^^^^^^^^^^^^ +Directs matching traffic to a given DPDK port ID. + +See `Item: PORT_ID`_. + +.. _table_rte_flow_action_port_id: + +.. table:: PORT_ID + + +--------------+---------------------------------------+ + | Field | Value | + +==============+=======================================+ + | ``original`` | use original DPDK port ID if possible | + +--------------+---------------------------------------+ + | ``id`` | DPDK port ID | + +--------------+---------------------------------------+ + Action: ``METER`` ^^^^^^^^^^^^^^^^^ diff --git a/doc/guides/rel_notes/release_18_05.rst b/doc/guides/rel_notes/release_18_05.rst index 211f68da1..b1b2fd00e 100644 --- a/doc/guides/rel_notes/release_18_05.rst +++ b/doc/guides/rel_notes/release_18_05.rst @@ -275,6 +275,8 @@ API Changes IDs. * An action counterpart to the PHY_PORT pattern item was added in order to redirect matching traffic to a specific physical port. + * PORT_ID pattern item and actions were added to match and target DPDK + port IDs at a higher level than PHY_PORT. ABI Changes diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index 9733a7262..f5565db29 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3236,6 +3236,10 @@ This section lists supported pattern items and their attributes, if any. - ``index {unsigned}``: physical port index. +- ``port_id``: match traffic from/to a given DPDK port ID. + + - ``id {unsigned}``: DPDK port ID. + - ``raw``: match an arbitrary byte string. - ``relative {boolean}``: look for pattern after the previous item. @@ -3452,6 +3456,11 @@ This section lists supported actions and their attributes, if any. - ``original {boolean}``: use original port index if possible. - ``index {unsigned}``: physical port index. +- ``port_id``: direct matching traffic to a given DPDK port ID. + + - ``original {boolean}``: use original DPDK port ID if possible. + - ``id {unsigned}``: DPDK port ID. + Destroying flow rules ~~~~~~~~~~~~~~~~~~~~~ diff --git a/lib/librte_ether/rte_flow.c b/lib/librte_ether/rte_flow.c index 00989c73b..cecab59f6 100644 --- a/lib/librte_ether/rte_flow.c +++ b/lib/librte_ether/rte_flow.c @@ -39,6 +39,7 @@ static const struct rte_flow_desc_data rte_flow_desc_item[] = { MK_FLOW_ITEM(PF, 0), MK_FLOW_ITEM(VF, sizeof(struct rte_flow_item_vf)), MK_FLOW_ITEM(PHY_PORT, sizeof(struct rte_flow_item_phy_port)), + MK_FLOW_ITEM(PORT_ID, sizeof(struct rte_flow_item_port_id)), MK_FLOW_ITEM(RAW, sizeof(struct rte_flow_item_raw)), MK_FLOW_ITEM(ETH, sizeof(struct rte_flow_item_eth)), MK_FLOW_ITEM(VLAN, sizeof(struct rte_flow_item_vlan)), @@ -77,6 +78,7 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = { MK_FLOW_ACTION(PF, 0), MK_FLOW_ACTION(VF, sizeof(struct rte_flow_action_vf)), MK_FLOW_ACTION(PHY_PORT, sizeof(struct rte_flow_action_phy_port)), + MK_FLOW_ACTION(PORT_ID, sizeof(struct rte_flow_action_port_id)), }; static int diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index 58b75e934..09a21e531 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -180,6 +180,16 @@ enum rte_flow_item_type { RTE_FLOW_ITEM_TYPE_PHY_PORT, /** + * [META] + * + * Matches traffic originating from (ingress) or going to (egress) a + * given DPDK port ID. + * + * See struct rte_flow_item_port_id. + */ + RTE_FLOW_ITEM_TYPE_PORT_ID, + + /** * Matches a byte string of a given length at a given offset. * * See struct rte_flow_item_raw. @@ -414,6 +424,32 @@ static const struct rte_flow_item_phy_port rte_flow_item_phy_port_mask = { #endif /** + * RTE_FLOW_ITEM_TYPE_PORT_ID + * + * Matches traffic originating from (ingress) or going to (egress) a given + * DPDK port ID. + * + * Normally only supported if the port ID in question is known by the + * underlying PMD and related to the device the flow rule is created + * against. + * + * This must not be confused with @p PHY_PORT which refers to the physical + * port of a device, whereas @p PORT_ID refers to a struct rte_eth_dev + * object on the application side (also known as "port representor" + * depending on the kind of underlying device). + */ +struct rte_flow_item_port_id { + uint32_t id; /**< DPDK port ID. */ +}; + +/** Default mask for RTE_FLOW_ITEM_TYPE_PORT_ID. */ +#ifndef __cplusplus +static const struct rte_flow_item_port_id rte_flow_item_port_id_mask = { + .id = 0xffffffff, +}; +#endif + +/** * RTE_FLOW_ITEM_TYPE_RAW * * Matches a byte string of a given length at a given offset. @@ -997,6 +1033,13 @@ enum rte_flow_action_type { RTE_FLOW_ACTION_TYPE_PHY_PORT, /** + * Directs matching traffic to a given DPDK port ID. + * + * See struct rte_flow_action_port_id. + */ + RTE_FLOW_ACTION_TYPE_PORT_ID, + + /** * Traffic metering and policing (MTR). * * See struct rte_flow_action_meter. @@ -1134,6 +1177,19 @@ struct rte_flow_action_phy_port { }; /** + * RTE_FLOW_ACTION_TYPE_PORT_ID + * + * Directs matching traffic to a given DPDK port ID. + * + * @see RTE_FLOW_ITEM_TYPE_PORT_ID + */ +struct rte_flow_action_port_id { + uint32_t original:1; /**< Use original DPDK port ID if possible. */ + uint32_t reserved:31; /**< Reserved, must be zero. */ + uint32_t id; /**< DPDK port ID. */ +}; + +/** * RTE_FLOW_ACTION_TYPE_METER * * Traffic metering and policing (MTR). -- 2.11.0 ^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [dpdk-dev] [PATCH v6 00/16] Flow API overhaul for switch offloads 2018-04-25 15:27 ` [dpdk-dev] [PATCH v6 00/16] Flow API overhaul for switch offloads Adrien Mazarguil ` (15 preceding siblings ...) 2018-04-25 15:28 ` [dpdk-dev] [PATCH v6 16/16] ethdev: add port ID item and " Adrien Mazarguil @ 2018-04-25 17:34 ` Ferruh Yigit 16 siblings, 0 replies; 157+ messages in thread From: Ferruh Yigit @ 2018-04-25 17:34 UTC (permalink / raw) To: Adrien Mazarguil, Thomas Monjalon, dev On 4/25/2018 4:27 PM, Adrien Mazarguil wrote: > As summarized in a prior RFC [1], the flow API (rte_flow) was chosen as a > means to manage switch offloads supported by many devices (usually going by > names such as E-Switch or vSwitch) through user-specified flow rules. > > Combined with the need to support encap/decap actions, this requires a > change in the way flow actions are processed (in order and possibly > repeated) which modifies the behavior of some of the existing actions, thus > warranting a major ABI breakage. > > Given this ABI breakage is also required by other work submitted for the > current release [2][3], this series addresses various longstanding issues > with the flow API and makes minor improvements in preparation for upcoming > features. > > Changes summary: > > - Additional error types. > - Clearer documentation. > - Improved C++ compatibility. > - Exhaustive RSS action. > - Consistent behavior of VLAN pattern item. > - New "transfer" attribute bringing consistency to VF/PF pattern items. > - Confusing "PORT" pattern item renamed "PHY_PORT", with new action > counterpart. > - New "PORT_ID" pattern item and action to be used with port representors. > > This series piggybacks on the major ABI update introduced by a prior > commit [4] for DPDK 18.05 and depends on several fixes [5] which must be > applied first. > > [1] "[RFC] Switch device offload with DPDK" > http://dpdk.org/ml/archives/dev/2018-March/092513.html > > [2] commit 676b605182a5 ("doc: announce ethdev API change for RSS > configuration") > > [3] "[PATCH v1 00/21] MLX5 tunnel Rx offloading" > http://dpdk.org/ml/archives/dev/2018-March/092264.html > > [4] commit 653e038efc9b ("ethdev: remove versioning of filter control > function") > > [5] "[PATCH v6 00/11] Bunch of flow API-related fixes" > http://dpdk.org/ml/archives/dev/2018-April/098035.html > > v6 changes: > > - Fixed mlx5 issue raised by Nelio in "ethdev: flatten RSS configuration in > flow API". > - Updated release notes (API update / ABI breakage) in relevant patches. > - Removed Xueming's deprecation notice in "ethdev: add encap level to RSS > flow API action" since it's covered by this series. > - Reworded a few patches as fixes since they address API flaws. > - Rebased series once again. > > v5 changes: > > - Fixed errors reported by GCC and Clang in patch 05/16 ("ethdev: alter > behavior of flow API actions"). > - Rebased series once again. > > v4 changes: > > - No change besides new acked-by lines, rebased series to address conflicts. > > v3 changes: > > - Rebased series, fixed latest conflicts. > - Addressed Andrew's comments, see affected patches for details: > - Empty RSS types in flow rule means PMD-specific RSS instead of no RSS. > - RSS hash function now explicitly compared against > RTE_ETH_HASH_FUNCTION_DEFAULT instead of 0 in all PMDs. > - sfc PMD updated to also accept Toeplitz. > - Implicit VLAN TPID matching now removed from all PMDs. > - Default mask upate for VLAN TCI now split as separate patch #11. > - Ingress/egress definition clarified in patch #12. > > v2 changes: > > - Squashed "ethdev: update ABI for flow API functions" in subsequent > patches. > - Emphasized ABI impact in relevant commit logs. > - Modified documentation in "ethdev: alter behavior of flow API actions" to > describe how terminating flow rules without any action of the fate kind > result in undefined behavior instead of dropping traffic. > - Fixed other minor documentation formatting issues. > - Modified "ethdev: refine TPID handling in flow API" as follows: > - Using standard macro definitions for VLAN, QinQ and E-Tag EtherTypes. > - Fixed endian conversion in sfc. > - Replaced a condition in VLAN pattern item processing with an assertion > check for i40e. > > Adrien Mazarguil (16): > ethdev: add error types to flow API > ethdev: clarify flow API pattern items and actions > doc: remove flow API migration section > ethdev: remove DUP action from flow API > ethdev: alter behavior of flow API actions > ethdev: fix C99 flexible arrays from flow API > ethdev: flatten RSS configuration in flow API > ethdev: add hash function to RSS flow API action > ethdev: add encap level to RSS flow API action > ethdev: fix TPID handling in flow API > ethdev: fix default VLAN TCI mask in flow API > ethdev: add transfer attribute to flow API > ethdev: fix behavior of VF/PF in flow API > ethdev: rename physical port item in flow API > ethdev: add physical port action to flow API > ethdev: add port ID item and action to flow API Series applied to dpdk-next-net/master, thanks. ^ permalink raw reply [flat|nested] 157+ messages in thread
end of thread, other threads:[~2018-05-07 8:17 UTC | newest] Thread overview: 157+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2018-04-04 15:56 [dpdk-dev] [PATCH v1 00/16] Flow API overhaul for switch offloads Adrien Mazarguil 2018-04-04 15:56 ` [dpdk-dev] [PATCH v1 01/16] ethdev: update ABI for flow API functions Adrien Mazarguil 2018-04-05 10:06 ` Thomas Monjalon 2018-04-05 12:44 ` Adrien Mazarguil 2018-04-05 13:36 ` Thomas Monjalon 2018-04-04 15:56 ` [dpdk-dev] [PATCH v1 02/16] ethdev: add error types to flow API Adrien Mazarguil 2018-04-04 15:56 ` [dpdk-dev] [PATCH v1 03/16] ethdev: clarify flow API pattern items and actions Adrien Mazarguil 2018-04-04 15:56 ` [dpdk-dev] [PATCH v1 04/16] doc: remove flow API migration section Adrien Mazarguil 2018-04-04 15:56 ` [dpdk-dev] [PATCH v1 05/16] ethdev: remove DUP action from flow API Adrien Mazarguil 2018-04-04 15:56 ` [dpdk-dev] [PATCH v1 06/16] ethdev: alter behavior of flow API actions Adrien Mazarguil 2018-04-04 15:56 ` [dpdk-dev] [PATCH v1 07/16] ethdev: remove C99 flexible arrays from flow API Adrien Mazarguil 2018-04-04 15:56 ` [dpdk-dev] [PATCH v1 08/16] ethdev: flatten RSS configuration in " Adrien Mazarguil 2018-04-04 15:56 ` [dpdk-dev] [PATCH v1 09/16] ethdev: add hash function to RSS flow API action Adrien Mazarguil 2018-04-04 15:56 ` [dpdk-dev] [PATCH v1 10/16] ethdev: add encap level " Adrien Mazarguil 2018-04-04 15:56 ` [dpdk-dev] [PATCH v1 11/16] ethdev: refine TPID handling in flow API Adrien Mazarguil 2018-04-05 9:55 ` Nélio Laranjeiro 2018-04-05 12:02 ` Adrien Mazarguil 2018-04-05 14:20 ` Zhang, Qi Z 2018-04-05 14:39 ` Adrien Mazarguil 2018-04-06 4:59 ` Zhang, Qi Z 2018-04-04 15:56 ` [dpdk-dev] [PATCH v1 12/16] ethdev: add transfer attribute to " Adrien Mazarguil 2018-04-04 15:56 ` [dpdk-dev] [PATCH v1 13/16] ethdev: update behavior of VF/PF in " Adrien Mazarguil 2018-04-04 15:56 ` [dpdk-dev] [PATCH v1 14/16] ethdev: rename physical port item " Adrien Mazarguil 2018-04-04 15:56 ` [dpdk-dev] [PATCH v1 15/16] ethdev: add physical port action to " Adrien Mazarguil 2018-04-04 15:56 ` [dpdk-dev] [PATCH v1 16/16] ethdev: add port ID item and " Adrien Mazarguil 2018-04-05 12:24 ` Zhang, Qi Z 2018-04-06 13:25 ` [dpdk-dev] [PATCH v2 00/15] Flow API overhaul for switch offloads Adrien Mazarguil 2018-04-06 13:25 ` [dpdk-dev] [PATCH v2 01/15] ethdev: add error types to flow API Adrien Mazarguil 2018-04-07 9:15 ` Andrew Rybchenko 2018-04-07 9:18 ` Andrew Rybchenko 2018-04-06 13:25 ` [dpdk-dev] [PATCH v2 02/15] ethdev: clarify flow API pattern items and actions Adrien Mazarguil 2018-04-07 9:21 ` Andrew Rybchenko 2018-04-06 13:25 ` [dpdk-dev] [PATCH v2 03/15] doc: remove flow API migration section Adrien Mazarguil 2018-04-07 9:22 ` Andrew Rybchenko 2018-04-06 13:25 ` [dpdk-dev] [PATCH v2 04/15] ethdev: remove DUP action from flow API Adrien Mazarguil 2018-04-07 9:23 ` Andrew Rybchenko 2018-04-06 13:25 ` [dpdk-dev] [PATCH v2 05/15] ethdev: alter behavior of flow API actions Adrien Mazarguil 2018-04-06 15:06 ` Andrew Rybchenko 2018-04-06 13:25 ` [dpdk-dev] [PATCH v2 06/15] ethdev: remove C99 flexible arrays from flow API Adrien Mazarguil 2018-04-06 13:25 ` [dpdk-dev] [PATCH v2 07/15] ethdev: flatten RSS configuration in " Adrien Mazarguil 2018-04-07 9:05 ` Andrew Rybchenko 2018-04-09 14:42 ` Adrien Mazarguil 2018-04-11 13:21 ` Andrew Rybchenko 2018-04-06 13:25 ` [dpdk-dev] [PATCH v2 08/15] ethdev: add hash function to RSS flow API action Adrien Mazarguil 2018-04-06 15:41 ` Andrew Rybchenko 2018-04-09 14:41 ` Adrien Mazarguil 2018-04-06 13:25 ` [dpdk-dev] [PATCH v2 09/15] ethdev: add encap level " Adrien Mazarguil 2018-04-07 8:27 ` Andrew Rybchenko 2018-04-06 13:25 ` [dpdk-dev] [PATCH v2 10/15] ethdev: refine TPID handling in flow API Adrien Mazarguil 2018-04-06 17:11 ` Andrew Rybchenko 2018-04-09 14:42 ` Adrien Mazarguil 2018-04-06 13:25 ` [dpdk-dev] [PATCH v2 11/15] ethdev: add transfer attribute to " Adrien Mazarguil 2018-04-06 13:25 ` [dpdk-dev] [PATCH v2 12/15] ethdev: update behavior of VF/PF in " Adrien Mazarguil 2018-04-07 9:41 ` Andrew Rybchenko 2018-04-09 14:49 ` Adrien Mazarguil 2018-04-06 13:25 ` [dpdk-dev] [PATCH v2 13/15] ethdev: rename physical port item " Adrien Mazarguil 2018-04-06 13:25 ` [dpdk-dev] [PATCH v2 14/15] ethdev: add physical port action to " Adrien Mazarguil 2018-04-07 9:51 ` Andrew Rybchenko 2018-04-09 15:00 ` Adrien Mazarguil 2018-04-06 13:25 ` [dpdk-dev] [PATCH v2 15/15] ethdev: add port ID item and " Adrien Mazarguil 2018-04-10 16:36 ` [dpdk-dev] [PATCH v3 00/16] Flow API overhaul for switch offloads Adrien Mazarguil 2018-04-10 16:36 ` [dpdk-dev] [PATCH v3 01/16] ethdev: add error types to flow API Adrien Mazarguil 2018-04-10 16:36 ` [dpdk-dev] [PATCH v3 02/16] ethdev: clarify flow API pattern items and actions Adrien Mazarguil 2018-04-10 16:36 ` [dpdk-dev] [PATCH v3 03/16] doc: remove flow API migration section Adrien Mazarguil 2018-04-10 16:36 ` [dpdk-dev] [PATCH v3 04/16] ethdev: remove DUP action from flow API Adrien Mazarguil 2018-04-10 16:36 ` [dpdk-dev] [PATCH v3 05/16] ethdev: alter behavior of flow API actions Adrien Mazarguil 2018-04-10 16:36 ` [dpdk-dev] [PATCH v3 06/16] ethdev: remove C99 flexible arrays from flow API Adrien Mazarguil 2018-04-10 16:36 ` [dpdk-dev] [PATCH v3 07/16] ethdev: flatten RSS configuration in " Adrien Mazarguil 2018-04-11 13:06 ` Andrew Rybchenko 2018-04-10 16:36 ` [dpdk-dev] [PATCH v3 08/16] ethdev: add hash function to RSS flow API action Adrien Mazarguil 2018-04-11 12:40 ` Andrew Rybchenko 2018-04-10 16:36 ` [dpdk-dev] [PATCH v3 09/16] ethdev: add encap level " Adrien Mazarguil 2018-04-10 16:36 ` [dpdk-dev] [PATCH v3 10/16] ethdev: refine TPID handling in flow API Adrien Mazarguil 2018-04-11 12:45 ` Andrew Rybchenko 2018-04-10 16:36 ` [dpdk-dev] [PATCH v3 11/16] ethdev: limit default VLAN TCI mask " Adrien Mazarguil 2018-04-11 12:48 ` Andrew Rybchenko 2018-04-10 16:37 ` [dpdk-dev] [PATCH v3 12/16] ethdev: add transfer attribute to " Adrien Mazarguil 2018-04-10 16:37 ` [dpdk-dev] [PATCH v3 13/16] ethdev: update behavior of VF/PF in " Adrien Mazarguil 2018-04-10 16:37 ` [dpdk-dev] [PATCH v3 14/16] ethdev: rename physical port item " Adrien Mazarguil 2018-04-11 12:57 ` Andrew Rybchenko 2018-04-10 16:37 ` [dpdk-dev] [PATCH v3 15/16] ethdev: add physical port action to " Adrien Mazarguil 2018-04-11 13:00 ` Andrew Rybchenko 2018-04-10 16:37 ` [dpdk-dev] [PATCH v3 16/16] ethdev: add port ID item and " Adrien Mazarguil 2018-04-11 13:02 ` Andrew Rybchenko 2018-04-16 16:22 ` [dpdk-dev] [PATCH v4 00/16] Flow API overhaul for switch offloads Adrien Mazarguil 2018-04-16 16:22 ` [dpdk-dev] [PATCH v4 01/16] ethdev: add error types to flow API Adrien Mazarguil 2018-04-17 19:37 ` Ferruh Yigit 2018-04-18 8:41 ` Adrien Mazarguil 2018-04-18 9:24 ` Ferruh Yigit 2018-04-19 9:48 ` Adrien Mazarguil 2018-04-16 16:22 ` [dpdk-dev] [PATCH v4 02/16] ethdev: clarify flow API pattern items and actions Adrien Mazarguil 2018-04-16 16:22 ` [dpdk-dev] [PATCH v4 03/16] doc: remove flow API migration section Adrien Mazarguil 2018-04-16 16:22 ` [dpdk-dev] [PATCH v4 04/16] ethdev: remove DUP action from flow API Adrien Mazarguil 2018-04-16 16:22 ` [dpdk-dev] [PATCH v4 05/16] ethdev: alter behavior of flow API actions Adrien Mazarguil 2018-04-18 12:26 ` Andrew Rybchenko 2018-04-18 14:58 ` Adrien Mazarguil 2018-04-16 16:22 ` [dpdk-dev] [PATCH v4 06/16] ethdev: remove C99 flexible arrays from flow API Adrien Mazarguil 2018-04-17 20:18 ` Thomas Monjalon 2018-04-18 6:45 ` Nélio Laranjeiro 2018-04-16 16:22 ` [dpdk-dev] [PATCH v4 07/16] ethdev: flatten RSS configuration in " Adrien Mazarguil 2018-04-16 16:22 ` [dpdk-dev] [PATCH v4 08/16] ethdev: add hash function to RSS flow API action Adrien Mazarguil 2018-04-16 16:22 ` [dpdk-dev] [PATCH v4 09/16] ethdev: add encap level " Adrien Mazarguil 2018-04-16 16:22 ` [dpdk-dev] [PATCH v4 10/16] ethdev: refine TPID handling in flow API Adrien Mazarguil 2018-04-16 16:22 ` [dpdk-dev] [PATCH v4 11/16] ethdev: limit default VLAN TCI mask " Adrien Mazarguil 2018-04-16 16:22 ` [dpdk-dev] [PATCH v4 12/16] ethdev: add transfer attribute to " Adrien Mazarguil 2018-04-16 16:22 ` [dpdk-dev] [PATCH v4 13/16] ethdev: update behavior of VF/PF in " Adrien Mazarguil 2018-04-16 16:22 ` [dpdk-dev] [PATCH v4 14/16] ethdev: rename physical port item " Adrien Mazarguil 2018-04-16 16:22 ` [dpdk-dev] [PATCH v4 15/16] ethdev: add physical port action to " Adrien Mazarguil 2018-04-17 9:08 ` Mohammad Abdul Awal 2018-04-16 16:23 ` [dpdk-dev] [PATCH v4 16/16] ethdev: add port ID item and " Adrien Mazarguil 2018-04-19 10:16 ` [dpdk-dev] [PATCH v5 00/16] Flow API overhaul for switch offloads Adrien Mazarguil 2018-04-19 10:16 ` [dpdk-dev] [PATCH v5 01/16] ethdev: add error types to flow API Adrien Mazarguil 2018-04-19 10:16 ` [dpdk-dev] [PATCH v5 02/16] ethdev: clarify flow API pattern items and actions Adrien Mazarguil 2018-04-19 10:16 ` [dpdk-dev] [PATCH v5 03/16] doc: remove flow API migration section Adrien Mazarguil 2018-04-19 10:16 ` [dpdk-dev] [PATCH v5 04/16] ethdev: remove DUP action from flow API Adrien Mazarguil 2018-04-19 10:16 ` [dpdk-dev] [PATCH v5 05/16] ethdev: alter behavior of flow API actions Adrien Mazarguil 2018-04-19 10:16 ` [dpdk-dev] [PATCH v5 06/16] ethdev: remove C99 flexible arrays from flow API Adrien Mazarguil 2018-04-19 10:16 ` [dpdk-dev] [PATCH v5 07/16] ethdev: flatten RSS configuration in " Adrien Mazarguil 2018-04-23 15:05 ` Nélio Laranjeiro 2018-04-19 10:16 ` [dpdk-dev] [PATCH v5 08/16] ethdev: add hash function to RSS flow API action Adrien Mazarguil 2018-04-19 10:16 ` [dpdk-dev] [PATCH v5 09/16] ethdev: add encap level " Adrien Mazarguil 2018-04-19 10:16 ` [dpdk-dev] [PATCH v5 10/16] ethdev: refine TPID handling in flow API Adrien Mazarguil 2018-04-19 10:16 ` [dpdk-dev] [PATCH v5 11/16] ethdev: limit default VLAN TCI mask " Adrien Mazarguil 2018-04-19 10:16 ` [dpdk-dev] [PATCH v5 12/16] ethdev: add transfer attribute to " Adrien Mazarguil 2018-04-19 10:16 ` [dpdk-dev] [PATCH v5 13/16] ethdev: update behavior of VF/PF in " Adrien Mazarguil 2018-04-19 10:16 ` [dpdk-dev] [PATCH v5 14/16] ethdev: rename physical port item " Adrien Mazarguil 2018-04-19 10:16 ` [dpdk-dev] [PATCH v5 15/16] ethdev: add physical port action to " Adrien Mazarguil 2018-04-19 10:16 ` [dpdk-dev] [PATCH v5 16/16] ethdev: add port ID item and " Adrien Mazarguil 2018-04-25 15:27 ` [dpdk-dev] [PATCH v6 00/16] Flow API overhaul for switch offloads Adrien Mazarguil 2018-04-25 15:27 ` [dpdk-dev] [PATCH v6 01/16] ethdev: add error types to flow API Adrien Mazarguil 2018-04-25 15:27 ` [dpdk-dev] [PATCH v6 02/16] ethdev: clarify flow API pattern items and actions Adrien Mazarguil 2018-04-25 15:27 ` [dpdk-dev] [PATCH v6 03/16] doc: remove flow API migration section Adrien Mazarguil 2018-04-25 15:27 ` [dpdk-dev] [PATCH v6 04/16] ethdev: remove DUP action from flow API Adrien Mazarguil 2018-04-25 15:27 ` [dpdk-dev] [PATCH v6 05/16] ethdev: alter behavior of flow API actions Adrien Mazarguil 2018-04-25 15:27 ` [dpdk-dev] [PATCH v6 06/16] ethdev: fix C99 flexible arrays from flow API Adrien Mazarguil 2018-04-25 15:27 ` [dpdk-dev] [PATCH v6 07/16] ethdev: flatten RSS configuration in " Adrien Mazarguil 2018-04-28 3:46 ` Zhao1, Wei 2018-04-28 5:28 ` Peng, Yuan 2018-04-28 7:45 ` Peng, Yuan 2018-05-03 12:48 ` Adrien Mazarguil 2018-05-04 9:31 ` Zhao1, Wei 2018-05-04 9:44 ` Adrien Mazarguil 2018-05-07 7:42 ` Peng, Yuan 2018-05-07 8:11 ` Peng, Yuan 2018-05-07 8:16 ` Zhao1, Wei 2018-04-25 15:27 ` [dpdk-dev] [PATCH v6 08/16] ethdev: add hash function to RSS flow API action Adrien Mazarguil 2018-04-25 15:27 ` [dpdk-dev] [PATCH v6 09/16] ethdev: add encap level " Adrien Mazarguil 2018-04-25 15:27 ` [dpdk-dev] [PATCH v6 10/16] ethdev: fix TPID handling in flow API Adrien Mazarguil 2018-04-25 16:10 ` Adrien Mazarguil 2018-04-25 16:15 ` Ferruh Yigit 2018-04-25 15:27 ` [dpdk-dev] [PATCH v6 11/16] ethdev: fix default VLAN TCI mask " Adrien Mazarguil 2018-04-25 15:28 ` [dpdk-dev] [PATCH v6 12/16] ethdev: add transfer attribute to " Adrien Mazarguil 2018-04-25 15:28 ` [dpdk-dev] [PATCH v6 13/16] ethdev: fix behavior of VF/PF in " Adrien Mazarguil 2018-04-25 15:28 ` [dpdk-dev] [PATCH v6 14/16] ethdev: rename physical port item " Adrien Mazarguil 2018-04-25 15:28 ` [dpdk-dev] [PATCH v6 15/16] ethdev: add physical port action to " Adrien Mazarguil 2018-04-25 15:28 ` [dpdk-dev] [PATCH v6 16/16] ethdev: add port ID item and " Adrien Mazarguil 2018-04-25 17:34 ` [dpdk-dev] [PATCH v6 00/16] Flow API overhaul for switch offloads Ferruh Yigit
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).