ethdev: datapath-focused flow rules management
cover ethdev: datapath-focused flow rules management
The current flow rules insertion mechanism assumes applications manage flow rules lifecycle in the control path. The flow rules creation/destruction is performed synchronously and under a lock. But for applications doing this job as part of the datapath, any blocking operations are not desirable as they cause delay in the packet processing.
These patches optimize a datapath-focused flow rules management approach based on four main concepts:
1. Pre-configuration hints.
In order to reduce the overhead of the flow rules management, the application may provide some hints at the initialization phase about flow rules characteristics to be used. The configuration funtion pre-allocates all the needed resources inside a PMD/HW beforehand and these resources are used at a later stage without costly allocations.
2. Flow grouping using templates.
Unlike current stage where each flow rule is treated as independent entity, new approach can leverage application knowledge about common patterns in most of flows. Similar flows are grouped toghether using templates to enable better resource management inside the PMD/HW.
3. Queue-based flow management.
Flow rules creation/destruction is done by using lockless flow queues. The application configures number of queues during the initialization stage. Then create/destroy operations are enqueued without any lock.
4. Asynchronous operations.
There is a way to spare the datapath from waiting for the flow rule creation/destruction. Adopting an asynchronous queue-based approach, the packet processing can continue with handling next packets while inserting/deleting a flow rule inside the hardware. The application is expected to poll for results later to see if the flow rule is successfully inserted/deleted or not.
Example on how to use this approach. Init stage consists from the resources preallocation, item and action templates definition and corresponding tables create. All these steps should be done before a device is started:
rte_eth_dev_configure();rte_flow_configure(port_id, number_of_flow_queues, max_num_of_counters); rte_flow_item_template_create(port_id, items("eth/ipv4/udp")); rte_flow_action_template_create(port_id, actions("counter/set_tp_src")); rte_flow_table_create(port_id, item_template, action_template); rte_eth_dev_start();
The packet processing can start once all the resources are preallocated. Flow rules creation/destruction jobs are enqueued as a part of the packet handling logic. These jobs are then flushed to the PMD/HW and their status is beign rquested via the dequeue API as a method to ensure flow rules are successfully created/destroyed.
rte_eth_rx_burst();
for (every received packet in the burts) {
if (flow rule needs to be created) {
rte_flow_q_flow_create(port_id, flow_queue_id, table_id,
item_template_id, items("eth/ipv4 is 1.1.1.1/udp"),
action_template_id, actions("counter/set_tp_src is 5555"));
} else {flow rule needs tp be destroyed) {
rte_flow_q_flow_destroy(port_id, flow_queue_id, flow_rule_id); }
rte_flow_q_flush(port_id, flow_queue_id); rte_flow_q_dequeue(port_id, flow_queue_id, &result);
}
Alexander Kozyrev (3):
ethdev: introduce flow pre-configuration hints
ethdev: add flow item/action templates
ethdev: add async queue-based flow rules operations
lib/ethdev/rte_flow.h | 626 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 626 insertions(+)
Signature · 1 line
2.18.2
PATCH 1/3 ethdev: introduce flow pre-configuration hints
The flow rules creation/destruction at a large scale incurs a performance penalty and may negatively impact the packet processing when used as part of the datapath logic. This is mainly because software/hardware resources are allocated and prepared during the flow rule creation.
In order to optimize the insertion rate, PMD may use some hints provided by the application at the initialization phase. The rte_flow_configure() function allows to pre-allocate all the needed resources beforehand. These resources can be used at a later stage without costly allocations. Every PMD may use only the subset of hints and ignore unused ones.
--- lib/ethdev/rte_flow.h | 70 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+)
lib/ethdev/rte_flow.h +70 -0
@@ -4288,6 +4288,76 @@ rte_flow_tunnel_item_release(uint16_t port_id,struct rte_flow_item *items, uint32_t num_of_items, struct rte_flow_error *error); + +/** +* Flow engine configuration. +*/ +__extension__ +struct rte_flow_port_attr { +/** +* Version of the struct layout, should be 0. +*/ +uint32_t version; +/** +* Memory size allocated for the flow rules management. +* If set to 0, memory is allocated dynamically. +*/ +uint32_t mem_size; +/** +* Number of counter actions pre-configured. +* If set to 0, PMD will allocate counters dynamically. +* @see RTE_FLOW_ACTION_TYPE_COUNT +*/ +uint32_t nb_counters; +/** +* Number of aging actions pre-configured. +* If set to 0, PMD will allocate aging dynamically. +* @see RTE_FLOW_ACTION_TYPE_AGE +*/ +uint32_t nb_aging; +/** +* Number of traffic metering actions pre-configured. +* If set to 0, PMD will allocate meters dynamically. +* @see RTE_FLOW_ACTION_TYPE_METER +*/ +uint32_t nb_meters; +/** +* Resources reallocation strategy. +* If set to 1, PMD is not allowed to allocate more resources on demand. +* An application can only allocate more resources by calling the +* configure API again with new values (may not be supported by PMD). +*/ +uint32_t fixed_resource_size:1 ; +}; + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Configure flow rules module. +* To pre-allocate resources as per the flow port attributes, +* this configuration function must be called before any flow rule is created. +* No other rte_flow function should be called while this function is invoked. +* This function can be called again to change the configuration. +* Some PMDs may not support re-configuration at all, +* or may only allow increasing the number of resources allocated. +* +* @param port_id +* Port identifier of Ethernet device. +* @param[in] port_attr +* Port configuration attributes. +* @param[out] error +* Perform verbose error reporting if not NULL. +* PMDs initialize this structure in case of error only. +* +* @return +* 0 on success, a negative errno value otherwise and rte_errno is set. +*/ +__rte_experimental +int +rte_flow_configure (uint16_t port_id, +const struct rte_flow_port_attr *port_attr, +struct rte_flow_error *error); #ifdef __cplusplus }#endif
Signature · 1 line
2.18.2
Re: [dpdk-dev] [PATCH 1/3] ethdev: introduce flow pre-configuration hints
Quoted 11 lines · Alexander Kozyrev
The flow rules creation/destruction at a large scale incurs a performance penalty and may negatively impact the packet processing when used as part of the datapath logic. This is mainly because software/hardware resources are allocated and prepared during the flow rule creation.
In order to optimize the insertion rate, PMD may use some hints provided by the application at the initialization phase. The
rte_flow_configure()function allows to pre-allocate all the needed resources beforehand. These resources can be used at a later stage without costly allocations. Every PMD may use only the subset of hints and ignore unused ones.
This could get tricky. An application can avoid attempts to create flows for items/actions if it can get a hint that PMD cannot satisfy some of the hints provided.
Also what if the application tries to configure a higher count than what the PMD/HW can support?
It will be good if the hints can be negotiated.
Something like this?
Application could start with a set of hints.
PMD can check what can be supported and return an updated set. Application stays within those values till it needs to resize.
Quoted 91 lines
Signed-off-by Alexander Kozyrev <[email protected]>Suggested-by Ori Kam <[email protected]>--- lib/ethdev/rte_flow.h | 70 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+)lib/ethdev/rte_flow.h +70
-1@@ -4288,6 +4288,76 @@ rte_flow_tunnel_item_release(uint16_t port_id,struct rte_flow_item *items, uint32_t num_of_items, struct rte_flow_error *error); + +/** +* Flow engine configuration. +*/ +__extension__ +struct rte_flow_port_attr { +/** +* Version of the struct layout, should be 0. +*/ +uint32_t version; +/** +* Memory size allocated for the flow rules management. +* If set to 0, memory is allocated dynamically. +*/ +uint32_t mem_size; +/** +* Number of counter actions pre-configured. +* If set to 0, PMD will allocate counters dynamically. +* @see RTE_FLOW_ACTION_TYPE_COUNT +*/ +uint32_t nb_counters; +/** +* Number of aging actions pre-configured. +* If set to 0, PMD will allocate aging dynamically. +* @see RTE_FLOW_ACTION_TYPE_AGE +*/ +uint32_t nb_aging; +/** +* Number of traffic metering actions pre-configured. +* If set to 0, PMD will allocate meters dynamically. +* @see RTE_FLOW_ACTION_TYPE_METER +*/ +uint32_t nb_meters; +/** +* Resources reallocation strategy. +* If set to 1, PMD is not allowed to allocate more resources on demand. +* An application can only allocate more resources by calling the +* configure API again with new values (may not be supported by PMD). +*/ +uint32_t fixed_resource_size:1 ; +}; + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Configure flow rules module. +* To pre-allocate resources as per the flow port attributes, +* this configuration function must be called before any flow rule is created. +* No other rte_flow function should be called while this function is invoked. +* This function can be called again to change the configuration. +* Some PMDs may not support re-configuration at all, +* or may only allow increasing the number of resources allocated. +* +* @param port_id +* Port identifier of Ethernet device. +* @param[in] port_attr +* Port configuration attributes. +* @param[out] error +* Perform verbose error reporting if not NULL. +* PMDs initialize this structure in case of error only. +* +* @return +* 0 on success, a negative errno value otherwise and rte_errno is set. +*/ +__rte_experimental +int +rte_flow_configure (uint16_t port_id, +const struct rte_flow_port_attr *port_attr, +struct rte_flow_error *error); #ifdef __cplusplus }#endif --2.18.2
Re: [dpdk-dev] [PATCH 1/3] ethdev: introduce flow pre-configuration hints
Hi Ajit,
Quoted 17 lines
-----Original Message-----
From: Ajit Khaparde <[email protected]>
Sent: Wednesday, October 13, 2021 7:11 AM
Subject: Re: [PATCH 1/3] ethdev: introduce flow pre-configuration hintsQuoted 11 lines · Alexander Kozyrev
The flow rules creation/destruction at a large scale incurs a performance penalty and may negatively impact the packet processing when used as part of the datapath logic. This is mainly because software/hardware resources are allocated and prepared during the flow rule creation.
In order to optimize the insertion rate, PMD may use some hints
provided by the application at the initialization phase. Therte_flow_configure()function allows to pre-allocate all the needed resources beforehand. These resources can be used at a later stage without costly allocations. Every PMD may use only the subset of hints and ignore unused ones.
Quoted 9 lines
This could get tricky. An application can avoid attempts to create flows for items/actions if it can get a hint that PMD cannot satisfy some of the hints provided.
Also what if the application tries to configure a higher count than what the PMD/HW can support? It will be good if the hints can be negotiated.
Something like this?
Application could start with a set of hints.
PMD can check what can be supported and return an updated set.
Application stays within those values till it needs to resize.
I don't like the negotaion approach since soon it will be impossible to maintain. I don't know how many possible option there will and what each PMD will implement. Also negotiation means that the PMD think he knows what is best and this is the opposite of this feature as giving the application as much control as possible.
Just like configure ethdev may fail and the application just get the error message. What application should do with the hits is PMD dependent.
For example application request 1M counter, this can even be system specific (to much memory) if PMD can't allocate such number of counter it should fail with error message that lets the application know if possible the max number of counters.
Best,
Ori
Quoted 91 lines
Quoted 91 lines
Signed-off-by Alexander Kozyrev <[email protected]>Suggested-by Ori Kam <[email protected]>--- lib/ethdev/rte_flow.h | 70 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+)lib/ethdev/rte_flow.h index renamed from lib/ethdev/rte_flow.h +0
-0
7b1ed7f110..c69d503b90100644lib/ethdev/rte_flow.h +69
-1@@ -4288,6 +4288,76 @@ rte_flow_tunnel_item_release(uint16_t port_id,struct rte_flow_item *items, uint32_t num_of_items, struct rte_flow_error *error); + +/** +* Flow engine configuration. +*/ +__extension__ +struct rte_flow_port_attr { +/** +* Version of the struct layout, should be 0. +*/ +uint32_t version; +/** +* Memory size allocated for the flow rules management. +* If set to 0, memory is allocated dynamically. +*/ +uint32_t mem_size; +/** +* Number of counter actions pre-configured. +* If set to 0, PMD will allocate counters dynamically. +* @see RTE_FLOW_ACTION_TYPE_COUNT +*/ +uint32_t nb_counters; +/** +* Number of aging actions pre-configured. +* If set to 0, PMD will allocate aging dynamically. +* @see RTE_FLOW_ACTION_TYPE_AGE +*/ +uint32_t nb_aging; +/** +* Number of traffic metering actions pre-configured. +* If set to 0, PMD will allocate meters dynamically. +* @see RTE_FLOW_ACTION_TYPE_METER +*/ +uint32_t nb_meters; +/** +* Resources reallocation strategy. +* If set to 1, PMD is not allowed to allocate more resources on demand. +* An application can only allocate more resources by calling the +* configure API again with new values (may not be supported by PMD). +*/ + uint32_t fixed_resource_size:1; }; + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Configure flow rules module. +* To pre-allocate resources as per the flow port attributes, +* this configuration function must be called before any flow rule is created. +* No other rte_flow function should be called while this function is invoked. +* This function can be called again to change the configuration. +* Some PMDs may not support re-configuration at all, +* or may only allow increasing the number of resources allocated. +* +* @param port_id +* Port identifier of Ethernet device. +* @param[in] port_attr +* Port configuration attributes. +* @param[out] error +* Perform verbose error reporting if not NULL. +* PMDs initialize this structure in case of error only. +* +* @return +* 0 on success, a negative errno value otherwise and rte_errno is set. +*/ +__rte_experimental +int +rte_flow_configure (uint16_t port_id, +const struct rte_flow_port_attr *port_attr, +struct rte_flow_error *error); #ifdef __cplusplus }#endif --2.18.2
Re: [dpdk-dev] [PATCH 1/3] ethdev: introduce flow pre-configuration hints
Quoted 35 lines · Ori Kam
Hi Ajit,
Quoted 17 lines
-----Original Message-----
From: Ajit Khaparde <[email protected]>
Sent: Wednesday, October 13, 2021 7:11 AM
Subject: Re: [PATCH 1/3] ethdev: introduce flow pre-configuration hintsQuoted 11 lines · Alexander Kozyrev
The flow rules creation/destruction at a large scale incurs a performance penalty and may negatively impact the packet processing when used as part of the datapath logic. This is mainly because software/hardware resources are allocated and prepared during the flow rule creation.
In order to optimize the insertion rate, PMD may use some hints
provided by the application at the initialization phase. Therte_flow_configure()function allows to pre-allocate all the needed resources beforehand. These resources can be used at a later stage without costly allocations. Every PMD may use only the subset of hints and ignore unused ones.Quoted 9 lines
This could get tricky. An application can avoid attempts to create flows for items/actions if it can get a hint that PMD cannot satisfy some of the hints provided.
Also what if the application tries to configure a higher count than what the PMD/HW can support? It will be good if the hints can be negotiated.
Something like this?
Application could start with a set of hints.
PMD can check what can be supported and return an updated set.
Application stays within those values till it needs to resize.I don't like the negotaion approach since soon it will be impossible to maintain. I don't know how many possible option there will and what each PMD will implement. Also negotiation means that the PMD think he knows what is best and this is the opposite of this feature as giving the application as much control as possible.
Quoted 6 lines
Just like configure ethdev may fail and the application just get the error message. What application should do with the hits is PMD dependent.
For example application request 1M counter, this can even be system specific (to much memory) if PMD can't allocate such number of counter it should fail with error message that lets the application know if possible the max number of counters.
How will the application know that the failure was because of counters and not because of meters or something else?
Quoted 95 lines
Best,
OriQuoted 91 lines
Quoted 91 lines
Signed-off-by Alexander Kozyrev <[email protected]>Suggested-by Ori Kam <[email protected]>--- lib/ethdev/rte_flow.h | 70 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+)lib/ethdev/rte_flow.h index renamed from lib/ethdev/rte_flow.h +0
-0
7b1ed7f110..c69d503b90100644lib/ethdev/rte_flow.h +69
-1@@ -4288,6 +4288,76 @@ rte_flow_tunnel_item_release(uint16_t port_id,struct rte_flow_item *items, uint32_t num_of_items, struct rte_flow_error *error); + +/** +* Flow engine configuration. +*/ +__extension__ +struct rte_flow_port_attr { +/** +* Version of the struct layout, should be 0. +*/ +uint32_t version; +/** +* Memory size allocated for the flow rules management. +* If set to 0, memory is allocated dynamically. +*/ +uint32_t mem_size; +/** +* Number of counter actions pre-configured. +* If set to 0, PMD will allocate counters dynamically. +* @see RTE_FLOW_ACTION_TYPE_COUNT +*/ +uint32_t nb_counters; +/** +* Number of aging actions pre-configured. +* If set to 0, PMD will allocate aging dynamically. +* @see RTE_FLOW_ACTION_TYPE_AGE +*/ +uint32_t nb_aging; +/** +* Number of traffic metering actions pre-configured. +* If set to 0, PMD will allocate meters dynamically. +* @see RTE_FLOW_ACTION_TYPE_METER +*/ +uint32_t nb_meters; +/** +* Resources reallocation strategy. +* If set to 1, PMD is not allowed to allocate more resources on demand. +* An application can only allocate more resources by calling the +* configure API again with new values (may not be supported by PMD). +*/ + uint32_t fixed_resource_size:1; }; + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Configure flow rules module. +* To pre-allocate resources as per the flow port attributes, +* this configuration function must be called before any flow rule is created. +* No other rte_flow function should be called while this function is invoked. +* This function can be called again to change the configuration. +* Some PMDs may not support re-configuration at all, +* or may only allow increasing the number of resources allocated. +* +* @param port_id +* Port identifier of Ethernet device. +* @param[in] port_attr +* Port configuration attributes. +* @param[out] error +* Perform verbose error reporting if not NULL. +* PMDs initialize this structure in case of error only. +* +* @return +* 0 on success, a negative errno value otherwise and rte_errno is set. +*/ +__rte_experimental +int +rte_flow_configure (uint16_t port_id, +const struct rte_flow_port_attr *port_attr, +struct rte_flow_error *error); #ifdef __cplusplus }#endif --2.18.2
Re: [dpdk-dev] [PATCH 1/3] ethdev: introduce flow pre-configuration hints
Hi Ajit,
Quoted 45 lines
-----Original Message-----
From: Ajit Khaparde <[email protected]>
Sent: Sunday, October 31, 2021 7:27 PM
Subject: Re: [PATCH 1/3] ethdev: introduce flow pre-configuration hintsQuoted 21 lines · Ori Kam
Hi Ajit,
Quoted 18 lines
-----Original Message-----
From: Ajit Khaparde <[email protected]>
Sent: Wednesday, October 13, 2021 7:11 AM
Subject: Re: [PATCH 1/3] ethdev: introduce flow pre-configuration hintsQuoted 11 lines · Alexander Kozyrev
The flow rules creation/destruction at a large scale incurs a performance penalty and may negatively impact the packet processing when used as part of the datapath logic. This is mainly because software/hardware resources are allocated and prepared during the flow rule creation.
In order to optimize the insertion rate, PMD may use some hints
provided by the application at the initialization phase. Therte_flow_configure()function allows to pre-allocate all the needed resources beforehand. These resources can be used at a later stage without costly allocations. Every PMD may use only the subset of hints and ignore unused ones.This could get tricky. An application can avoid attempts to create flows for items/actions if it can get
a
Quoted 17 lines
Quoted 8 lines
hint that PMD cannot satisfy some of the hints provided.
Also what if the application tries to configure a higher count than what the PMD/HW can support? It will be good if the hints can be negotiated.
Something like this?
Application could start with a set of hints.
PMD can check what can be supported and return an updated set.
Application stays within those values till it needs to resize.I don't like the negotaion approach since soon it will be impossible to maintain. I don't know how many possible option there will and what each PMD will implement. Also negotiation means that the PMD think he knows what is best and this is the opposite of this feature as giving the application as much control as possible.
Just like configure ethdev may fail and the application just get the error message. What application should do with the hits is PMD dependent.
Quoted 7 lines
Quoted 2 lines
For example application request 1M counter, this can even be system specific (to much memory) if PMD can't allocate such number of counter it should fail with error message that lets the
application
Quoted 1 line
know if possible the max number of counters.
How will the application know that the failure was because of counters and not because of meters or something else?
He can check the error description,
Even now when you insert rule you don't know why it failed. I assume that if only some of the parameters are not supported the error returned will be EINVAL.
Quoted 95 lines
Quoted 95 lines
Best,
OriQuoted 91 lines
Quoted 91 lines
Signed-off-by Alexander Kozyrev <[email protected]>Suggested-by Ori Kam <[email protected]>--- lib/ethdev/rte_flow.h | 70 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+)lib/ethdev/rte_flow.h index renamed from lib/ethdev/rte_flow.h +0
-0
7b1ed7f110..c69d503b90100644lib/ethdev/rte_flow.h +69
-1@@ -4288,6 +4288,76 @@ rte_flow_tunnel_item_release(uint16_t port_id,struct rte_flow_item *items, uint32_t num_of_items, struct rte_flow_error *error); + +/** +* Flow engine configuration. +*/ +__extension__ +struct rte_flow_port_attr { +/** +* Version of the struct layout, should be 0. +*/ +uint32_t version; +/** +* Memory size allocated for the flow rules management. +* If set to 0, memory is allocated dynamically. +*/ +uint32_t mem_size; +/** +* Number of counter actions pre-configured. +* If set to 0, PMD will allocate counters dynamically. +* @see RTE_FLOW_ACTION_TYPE_COUNT +*/ +uint32_t nb_counters; +/** +* Number of aging actions pre-configured. +* If set to 0, PMD will allocate aging dynamically. +* @see RTE_FLOW_ACTION_TYPE_AGE +*/ +uint32_t nb_aging; +/** +* Number of traffic metering actions pre-configured. +* If set to 0, PMD will allocate meters dynamically. +* @see RTE_FLOW_ACTION_TYPE_METER +*/ +uint32_t nb_meters; +/** +* Resources reallocation strategy. +* If set to 1, PMD is not allowed to allocate more resources on demand. +* An application can only allocate more resources by calling the +* configure API again with new values (may not be supported by PMD). +*/ + uint32_t fixed_resource_size:1; }; + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Configure flow rules module. +* To pre-allocate resources as per the flow port attributes, +* this configuration function must be called before any flow rule is created. +* No other rte_flow function should be called while this function is invoked. +* This function can be called again to change the configuration. +* Some PMDs may not support re-configuration at all, +* or may only allow increasing the number of resources allocated. +* +* @param port_id +* Port identifier of Ethernet device. +* @param[in] port_attr +* Port configuration attributes. +* @param[out] error +* Perform verbose error reporting if not NULL. +* PMDs initialize this structure in case of error only. +* +* @return +* 0 on success, a negative errno value otherwise and rte_errno is set. +*/ +__rte_experimental +int +rte_flow_configure (uint16_t port_id, +const struct rte_flow_port_attr *port_attr, +struct rte_flow_error *error); #ifdef __cplusplus }#endif --2.18.2
PATCH 2/3 ethdev: add flow item/action templates
In reply to Alexander KozyrevTreating every single flow rule as a completely independent and separate entity negatively impacts the flow rules insertion rate. Oftentimes in an application, many flow rules share a common structure (the same item mask and/or action list) so they can be grouped and classified together. This knowledge may be used as a source of optimization by a PMD/HW.
The item template defines common matching fields (the item mask) without values. The action template holds a list of action types that will be used together in the same rule. The specific values for items and actions will be given only during the rule creation.
A table combines item and action templates along with shared flow rule attributes (group ID, priority and traffic direction). This way a PMD/HW can prepare all the resources needed for efficient flow rules creation in the datapath. To avoid any hiccups due to memory reallocation, the maximum number of flow rules is defined at table creation time.
The flow rule creation is done by selecting a table, an item template and an action template (which are bound to the table), and setting unique values for the items and actions.
--- lib/ethdev/rte_flow.h | 268 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 268 insertions(+)
lib/ethdev/rte_flow.h +268 -0
@@ -4358,6 +4358,274 @@ int rte_flow_configure(uint16_t port_id, const struct rte_flow_port_attr *port_attr, struct rte_flow_error *error); + +/** +* Opaque type returned after successfull creation of item template. +* This handle can be used to manage the created item template. +*/ +struct rte_flow_item_template ; + +__extension__ +struct rte_flow_item_template_attr { +/** +* Version of the struct layout, should be 0. +*/ +uint32_t version; +/* No attributes so far. */ +}; + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Create item template. +* The item template defines common matching fields (item mask) without values. +* For example, matching on 5 tuple TCP flow, the template will be +* eth(null) + IPv4(source + dest) + TCP(s_port + d_port), +* while values for each rule will be set during the flow rule creation. +* The order of items in the template must be the same at rule insertion. +* +* @param port_id +* Port identifier of Ethernet device. +* @param[in] attr +* Item template attributes. +* @param[in] items +* Pattern specification (list terminated by the END pattern item). +* The spec member of an item is not used unless the end member is used. +* @param[out] error +* Perform verbose error reporting if not NULL. +* PMDs initialize this structure in case of error only. +* +* @return +* Handle on success, NULL otherwise and rte_errno is set. +*/ +__rte_experimental +struct rte_flow_item_template * +rte_flow_item_template_create (uint16_t port_id, +const struct rte_flow_item_template_attr *attr, +const struct rte_flow_item items[], +struct rte_flow_error *error); + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Destroy item template. +* This function may be called only when +* there are no more tables referencing this template. +* +* @param port_id +* Port identifier of Ethernet device. +* @param[in] template +* Handle to the template to be destroyed. +* @param[out] error +* Perform verbose error reporting if not NULL. +* PMDs initialize this structure in case of error only. +* +* @return +* 0 on success, a negative errno value otherwise and rte_errno is set. +*/ +__rte_experimental +int +rte_flow_item_template_destroy (uint16_t port_id, +struct rte_flow_item_template *template, +struct rte_flow_error *error); + +/** +* Opaque type returned after successfull creation of action template. +* This handle can be used to manage the created action template. +*/ +struct rte_flow_action_template ; + +__extension__ +struct rte_flow_action_template_attr { +/** +* Version of the struct layout, should be 0. +*/ +uint32_t version; +/* No attributes so far. */ +}; + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Create action template. +* The action template holds a list of action types without values. +* For example, the template to change TCP ports is TCP(s_port + d_port), +* while values for each rule will be set during the flow rule creation. +* +* The order of the action in the template must be kept when inserting rules. +* +* @param port_id +* Port identifier of Ethernet device. +* @param[in] attr +* Template attributes. +* @param[in] actions +* Associated actions (list terminated by the END action). +* The spec member is only used if the mask is 1. +* @param[in] masks +* List of actions that marks which of the action's member is constant. +* A mask has the same format as the corresponding action. +* If the action field in @p masks is not 0, +* the corresponding value in an action from @p actions will be the part +* of the template and used in all flow rules. +* The order of actions in @p masks is the same as in @p actions. +* In case of indirect actions present in @p actions, +* the actual action type should be present in @p mask. +* @param[out] error +* Perform verbose error reporting if not NULL. +* PMDs initialize this structure in case of error only. +* +* @return +* handle on success, NULL otherwise and rte_errno is set. +*/ +__rte_experimental +struct rte_flow_action_template * +rte_flow_action_template_create (uint16_t port_id, +const struct rte_flow_action_template_attr *attr, +const struct rte_flow_action actions[], +const struct rte_flow_action masks[], +struct rte_flow_error *error); + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Destroy action template. +* This function may be called only when +* there are no more tables referencing this template. +* +* @param port_id +* Port identifier of Ethernet device. +* @param[in] template +* Handle to the template to be destroyed. +* @param[out] error +* Perform verbose error reporting if not NULL. +* PMDs initialize this structure in case of error only. +* +* @return +* 0 on success, a negative errno value otherwise and rte_errno is set. +*/ +__rte_experimental +int +rte_flow_action_template_destroy (uint16_t port_id, +const struct rte_flow_action_template *template, +struct rte_flow_error *error); + + +/** +* Opaque type returned after successfull creation of table. +* This handle can be used to manage the created table. +*/ +struct rte_flow_table ; + +enum rte_flow_table_mode { +/** +* Fixed size, the number of flow rules will be limited. +* It is possible that some of the rules will not be inserted +* due to conflicts/lack of space. +* When rule insertion fails with try again error, +* the application may use one of the following ways +* to address this state: +* 1. Keep this rule processing in the software. +* 2. Try to offload this rule at a later time, +* after some rules have been removed from the hardware. +* 3. Create a new table and add this rule to the new table. +*/ +RTE_FLOW_TABLE_MODE_FIXED , +/** +* Resizable, the PMD/HW will insert all rules. +* No try again error will be received in this mode. +*/ +RTE_FLOW_TABLE_MODE_RESIZABLE , +}; + +/** +* Table attributes. +*/ +struct rte_flow_table_attr { +/** +* Version of the struct layout, should be 0. +*/ +uint32_t version; +/** +* Flow attributes that will be used in the table. +*/ +struct rte_flow_attr attr; +/** +* Maximum number of flow rules that this table holds. +* It can be hard or soft limit depending on the mode. +*/ +uint32_t max_rules; +/** +* Table mode. +*/ +enum rte_flow_table_mode mode; +}; + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Create table. +* Table is a group of flow rules with the same flow attributes +* (group ID, priority and traffic direction) defined for it. +* The table holds multiple item and action templates to build a flow rule. +* Each rule is free to use any combination of item and action templates +* and specify particular values for items and actions it would like to change. +* +* @param port_id +* Port identifier of Ethernet device. +* @param[in] attr +* Table attributes. +* @param[in] item_templates +* Array of item templates to be used in this table. +* @param[in] nb_item_templates +* The number of item templates in the item_templates array. +* @param[in] action_templates +* Array of action templates to be used in this table. +* @param[in] nb_action_templates +* The number of action templates in the action_templates array. +* @param[out] error +* Perform verbose error reporting if not NULL. +* PMDs initialize this structure in case of error only. +* +* @return +* Handle on success, NULL otherwise and rte_errno is set. +*/ +__rte_experimental +struct rte_flow_table * +rte_flow_table_create (uint16_t port_id,struct rte_flow_table_attr *attr, +const struct rte_flow_item_template *item_templates[], +uint8_t nb_item_templates, +const struct rte_flow_action_template *action_templates[], +uint8_t nb_action_templates, +struct rte_flow_error *error); + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Destroy table. +* This function may be called only when +* there are no more flow rules referencing this table. +* +* @param port_id +* Port identifier of Ethernet device. +* @param[in] table +* Handle to the table to be destroyed. +* @param[out] error +* Perform verbose error reporting if not NULL. +* PMDs initialize this structure in case of error only. +* +* @return +* 0 on success, a negative errno value otherwise and rte_errno is set. +*/ +__rte_experimental +int +rte_flow_table_destroy (uint16_t port_id,struct rte_flow_table *table, +struct rte_flow_error *error); #ifdef __cplusplus }#endif
Signature · 1 line
2.18.2
Re: [dpdk-dev] [PATCH 2/3] ethdev: add flow item/action templates
Hi,
Quoted 32 lines · Alexander Kozyrev
Treating every single flow rule as a completely independent and separate entity negatively impacts the flow rules insertion rate. Oftentimes in an application, many flow rules share a common structure (the same item mask and/or action list) so they can be grouped and classified together. This knowledge may be used as a source of optimization by a PMD/HW.
The item template defines common matching fields (the item mask) without values. The action template holds a list of action types that will be used together in the same rule. The specific values for items and actions will be given only during the rule creation.
A table combines item and action templates along with shared flow rule attributes (group ID, priority and traffic direction). This way a PMD/HW can prepare all the resources needed for efficient flow rules creation in the datapath. To avoid any hiccups due to memory reallocation, the maximum number of flow rules is defined at table creation time.
The flow rule creation is done by selecting a table, an item template and an action template (which are bound to the table), and setting unique values for the items and actions.
Signed-off-by Alexander Kozyrev <[email protected]>Suggested-by Ori Kam <[email protected]>--- lib/ethdev/rte_flow.h | 268 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 268 insertions(+)lib/ethdev/rte_flow.h +0
-0
lib/ethdev/rte_flow.h int · line 4363
Quoted 6 lines
lib/ethdev/rte_flow.h +3
-0@@ -4358,6 +4358,274 @@ int rte_flow_configure(uint16_t port_id, const struct rte_flow_port_attr *port_attr, struct rte_flow_error *error); + +/** +* Opaque type returned after successfull creation of item template.
Typo: "successfull" --> "successful".
Quoted 18 lines
lib/ethdev/rte_flow.h +18
-0+* This handle can be used to manage the created item template. +*/ +struct rte_flow_item_template ; + +__extension__ +struct rte_flow_item_template_attr { +/** +* Version of the struct layout, should be 0. +*/ +uint32_t version; +/* No attributes so far. */ +}; + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Create item template.
lib/ethdev/rte_flow.h int · line 4391
Quoted 10 lines
lib/ethdev/rte_flow.h +10
-0+* The item template defines common matching fields (item mask) without values. +* For example, matching on 5 tuple TCP flow, the template will be +* eth(null) + IPv4(source + dest) + TCP(s_port + d_port), +* while values for each rule will be set during the flow rule creation. +* The order of items in the template must be the same at rule insertion. +* +* @param port_id +* Port identifier of Ethernet device. +* @param[in] attr +* Item template attributes.
Please consider adding meaningful prefixes to "attr" here and below. This is needed to avoid confusion with "struct rte_flow_attr".
Example: "template_attr".
Quoted 19 lines
lib/ethdev/rte_flow.h +19
-0+* @param[in] items +* Pattern specification (list terminated by the END pattern item). +* The spec member of an item is not used unless the end member is used. +* @param[out] error +* Perform verbose error reporting if not NULL. +* PMDs initialize this structure in case of error only. +* +* @return +* Handle on success, NULL otherwise and rte_errno is set. +*/ +__rte_experimental +struct rte_flow_item_template * +rte_flow_item_template_create (uint16_t port_id, +const struct rte_flow_item_template_attr *attr, +const struct rte_flow_item items[], +struct rte_flow_error *error); + +/** +* @warning
lib/ethdev/rte_flow.h int · line 4420
Quoted 10 lines
lib/ethdev/rte_flow.h +10
-0+* @b EXPERIMENTAL: this API may change without prior notice. +* +* Destroy item template. +* This function may be called only when +* there are no more tables referencing this template. +* +* @param port_id +* Port identifier of Ethernet device. +* @param[in] template +* Handle to the template to be destroyed.
Perhaps "handle OF the template"?
Quoted 5 lines
lib/ethdev/rte_flow.h +5
-0+* @param[out] error +* Perform verbose error reporting if not NULL. +* PMDs initialize this structure in case of error only. +* +* @return
lib/ethdev/rte_flow.h int · line 4435
Quoted 10 lines
lib/ethdev/rte_flow.h +10
-0+* 0 on success, a negative errno value otherwise and rte_errno is set. +*/ +__rte_experimental +int +rte_flow_item_template_destroy (uint16_t port_id, +struct rte_flow_item_template *template, +struct rte_flow_error *error); + +/** +* Opaque type returned after successfull creation of action template.
Single "l" in "successful".
Quoted 18 lines
lib/ethdev/rte_flow.h +18
-0+* This handle can be used to manage the created action template. +*/ +struct rte_flow_action_template ; + +__extension__ +struct rte_flow_action_template_attr { +/** +* Version of the struct layout, should be 0. +*/ +uint32_t version; +/* No attributes so far. */ +}; + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Create action template.
lib/ethdev/rte_flow.h int · line 4463
Quoted 10 lines
lib/ethdev/rte_flow.h +10
-0+* The action template holds a list of action types without values. +* For example, the template to change TCP ports is TCP(s_port + d_port), +* while values for each rule will be set during the flow rule creation. +* +* The order of the action in the template must be kept when inserting rules. +* +* @param port_id +* Port identifier of Ethernet device. +* @param[in] attr +* Template attributes.
Perhaps add a meaningful prefix to "attr".
lib/ethdev/rte_flow.h int · line 4466
Quoted 3 lines
lib/ethdev/rte_flow.h +3
-0+* @param[in] actions +* Associated actions (list terminated by the END action). +* The spec member is only used if the mask is 1.
Maybe "its mask is all ones"?
lib/ethdev/rte_flow.h int · line 4468
Quoted 2 lines
lib/ethdev/rte_flow.h +2
-0+* @param[in] masks +* List of actions that marks which of the action's member is constant.
Consider the following action example:
struct rte_flow_action_vxlan_encap {
struct rte_flow_item *definition;
};So, if "definition" is not NULL, the whole header definition is supposed to be constant, right? Or am I missing something?
Quoted 40 lines
lib/ethdev/rte_flow.h +40
-0+* A mask has the same format as the corresponding action. +* If the action field in @p masks is not 0, +* the corresponding value in an action from @p actions will be the part +* of the template and used in all flow rules. +* The order of actions in @p masks is the same as in @p actions. +* In case of indirect actions present in @p actions, +* the actual action type should be present in @p mask. +* @param[out] error +* Perform verbose error reporting if not NULL. +* PMDs initialize this structure in case of error only. +* +* @return +* handle on success, NULL otherwise and rte_errno is set. +*/ +__rte_experimental +struct rte_flow_action_template * +rte_flow_action_template_create (uint16_t port_id, +const struct rte_flow_action_template_attr *attr, +const struct rte_flow_action actions[], +const struct rte_flow_action masks[], +struct rte_flow_error *error); + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Destroy action template. +* This function may be called only when +* there are no more tables referencing this template. +* +* @param port_id +* Port identifier of Ethernet device. +* @param[in] template +* Handle to the template to be destroyed. +* @param[out] error +* Perform verbose error reporting if not NULL. +* PMDs initialize this structure in case of error only. +* +* @return +* 0 on success, a negative errno value otherwise and rte_errno is set.
lib/ethdev/rte_flow.h int · line 4518
Quoted 10 lines
lib/ethdev/rte_flow.h +10
-0+*/ +__rte_experimental +int +rte_flow_action_template_destroy (uint16_t port_id, +const struct rte_flow_action_template *template, +struct rte_flow_error *error); + + +/** +* Opaque type returned after successfull creation of table.
Redundant "l" in "successful".
Quoted 27 lines
lib/ethdev/rte_flow.h +27
-0+* This handle can be used to manage the created table. +*/ +struct rte_flow_table ; + +enum rte_flow_table_mode { +/** +* Fixed size, the number of flow rules will be limited. +* It is possible that some of the rules will not be inserted +* due to conflicts/lack of space. +* When rule insertion fails with try again error, +* the application may use one of the following ways +* to address this state: +* 1. Keep this rule processing in the software. +* 2. Try to offload this rule at a later time, +* after some rules have been removed from the hardware. +* 3. Create a new table and add this rule to the new table. +*/ +RTE_FLOW_TABLE_MODE_FIXED , +/** +* Resizable, the PMD/HW will insert all rules. +* No try again error will be received in this mode. +*/ +RTE_FLOW_TABLE_MODE_RESIZABLE , +}; + +/** +* Table attributes.
lib/ethdev/rte_flow.h int · line 4555
Quoted 10 lines
lib/ethdev/rte_flow.h +10
-0+*/ +struct rte_flow_table_attr { +/** +* Version of the struct layout, should be 0. +*/ +uint32_t version; +/** +* Flow attributes that will be used in the table. +*/ +struct rte_flow_attr attr;
Perhaps, "flow_attr" then?
lib/ethdev/rte_flow.h int · line 4560
Quoted 5 lines
lib/ethdev/rte_flow.h +5
-0+/** +* Maximum number of flow rules that this table holds. +* It can be hard or soft limit depending on the mode. +*/ +uint32_t max_rules;
How about "nb_flows_max"?
Quoted 72 lines
lib/ethdev/rte_flow.h +68
-0+/** +* Table mode. +*/ +enum rte_flow_table_mode mode; +}; + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Create table. +* Table is a group of flow rules with the same flow attributes +* (group ID, priority and traffic direction) defined for it. +* The table holds multiple item and action templates to build a flow rule. +* Each rule is free to use any combination of item and action templates +* and specify particular values for items and actions it would like to change. +* +* @param port_id +* Port identifier of Ethernet device. +* @param[in] attr +* Table attributes. +* @param[in] item_templates +* Array of item templates to be used in this table. +* @param[in] nb_item_templates +* The number of item templates in the item_templates array. +* @param[in] action_templates +* Array of action templates to be used in this table. +* @param[in] nb_action_templates +* The number of action templates in the action_templates array. +* @param[out] error +* Perform verbose error reporting if not NULL. +* PMDs initialize this structure in case of error only. +* +* @return +* Handle on success, NULL otherwise and rte_errno is set. +*/ +__rte_experimental +struct rte_flow_table * +rte_flow_table_create (uint16_t port_id,struct rte_flow_table_attr *attr, +const struct rte_flow_item_template *item_templates[], +uint8_t nb_item_templates, +const struct rte_flow_action_template *action_templates[], +uint8_t nb_action_templates, +struct rte_flow_error *error); + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Destroy table. +* This function may be called only when +* there are no more flow rules referencing this table. +* +* @param port_id +* Port identifier of Ethernet device. +* @param[in] table +* Handle to the table to be destroyed. +* @param[out] error +* Perform verbose error reporting if not NULL. +* PMDs initialize this structure in case of error only. +* +* @return +* 0 on success, a negative errno value otherwise and rte_errno is set. +*/ +__rte_experimental +int +rte_flow_table_destroy (uint16_t port_id,struct rte_flow_table *table, +struct rte_flow_error *error); #ifdef __cplusplus }#endif
Signature · 1 line
Ivan M
Re: [dpdk-dev] [PATCH 2/3] ethdev: add flow item/action templates
Quoted 33 lines
From: Ivan Malov <[email protected]> On Wednesday, October 6, 2021 13:25
Quoted 3 lines · Alexander Kozyrev
Treating every single flow rule as a completely independent and separate entity negatively impacts the flow rules insertion rate. Oftentimes in an application, many flow rules share a common structure (the same item
mask
Quoted 4 lines
and/or action list) so they can be grouped and classified together. This knowledge may be used as a source of optimization by a PMD/HW.
The item template defines common matching fields (the item mask)
without
Quoted 8 lines
values. The action template holds a list of action types that will be used together in the same rule. The specific values for items and actions will be given only during the rule creation.
A table combines item and action templates along with shared flow rule attributes (group ID, priority and traffic direction). This way a PMD/HW can prepare all the resources needed for efficient flow rules creation in the datapath. To avoid any hiccups due to memory reallocation, the
maximum
Quoted 10 lines
number of flow rules is defined at table creation time.
The flow rule creation is done by selecting a table, an item template and an action template (which are bound to the table), and setting unique values for the items and actions.
Signed-off-by Alexander Kozyrev <[email protected]>Suggested-by Ori Kam <[email protected]>--- lib/ethdev/rte_flow.h | 268++++++++++++++++++++++++++++++++++++++++++
Quoted 2 lines
1 file changed, 268 insertions(+)
Quoted 13 lines
lib/ethdev/rte_flow.h int · line 4363
Quoted 11 lines
lib/ethdev/rte_flow.h +3
-0@@ -4358,6 +4358,274 @@ int rte_flow_configure(uint16_t port_id, const struct rte_flow_port_attr *port_attr, struct rte_flow_error *error); + +/** +* Opaque type returned after successfull creation of item template. Typo: "successfull" --> "successful".
Thanks for noticing, will correct.
Quoted 30 lines
Quoted 9 lines
lib/ethdev/rte_flow.h +9
-0+* This handle can be used to manage the created item template. +*/ +struct rte_flow_item_template ; + +__extension__ +struct rte_flow_item_template_attr { + /** + * Version of the struct layout, should be 0. + */lib/ethdev/rte_flow.h int
Quoted 10 lines
lib/ethdev/rte_flow.h +10
-0+uint32_t version; +/* No attributes so far. */ +}; + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Create item template. +* The item template defines common matching fields (item mask) without values.
lib/ethdev/rte_flow.h int · line 4391
Quoted 9 lines
lib/ethdev/rte_flow.h +9
-0+* For example, matching on 5 tuple TCP flow, the template will be +* eth(null) + IPv4(source + dest) + TCP(s_port + d_port), +* while values for each rule will be set during the flow rule creation. +* The order of items in the template must be the same at rule insertion. +* +* @param port_id +* Port identifier of Ethernet device. +* @param[in] attr +* Item template attributes.
Quoted 4 lines
Please consider adding meaningful prefixes to "attr" here and below. This is needed to avoid confusion with "struct
rte_flow_attr".Example: "
template_attr".
No problem.
Quoted 24 lines
lib/ethdev/rte_flow.h int
Quoted 3 lines
lib/ethdev/rte_flow.h +3
-0+* @param[in] items +* Pattern specification (list terminated by the END pattern item). +* The spec member of an item is not used unless the end member is used.
Quoted 20 lines
lib/ethdev/rte_flow.h +20
-0+* @param[out] error +* Perform verbose error reporting if not NULL. +* PMDs initialize this structure in case of error only. +* +* @return +* Handle on success, NULL otherwise and rte_errno is set. +*/ +__rte_experimental +struct rte_flow_item_template * +rte_flow_item_template_create (uint16_t port_id, +const struct rte_flow_item_template_attr *attr, +const struct rte_flow_item items[], +struct rte_flow_error *error); + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Destroy item template. +* This function may be called only when
Quoted 8 lines
lib/ethdev/rte_flow.h int · line 4420
Quoted 6 lines
lib/ethdev/rte_flow.h +6
-0+* there are no more tables referencing this template. +* +* @param port_id +* Port identifier of Ethernet device. +* @param[in] template +* Handle to the template to be destroyed. Perhaps "handle OF the template"?
You are right.
Quoted 9 lines
Quoted 9 lines
lib/ethdev/rte_flow.h +9
-0+* @param[out] error +* Perform verbose error reporting if not NULL. +* PMDs initialize this structure in case of error only. +* +* @return +* 0 on success, a negative errno value otherwise and rte_errno is set. +*/ +__rte_experimental +int
Quoted 8 lines
lib/ethdev/rte_flow.h int · line 4435
Quoted 6 lines
lib/ethdev/rte_flow.h +6
-0+rte_flow_item_template_destroy(uint16_t port_id, + struct rte_flow_item_template *template, + struct rte_flow_error *error); + +/** +* Opaque type returned after successfull creation of action template. Single "l" in "successful".
Ditto.
Quoted 24 lines
Quoted 13 lines
lib/ethdev/rte_flow.h +13
-0+* This handle can be used to manage the created action template. +*/ +struct rte_flow_action_template ; + +__extension__ +struct rte_flow_action_template_attr { +/** +* Version of the struct layout, should be 0. +*/ +uint32_t version; +/* No attributes so far. */ +}; +lib/ethdev/rte_flow.h int
Quoted 10 lines
lib/ethdev/rte_flow.h +10
-0+/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Create action template. +* The action template holds a list of action types without values. +* For example, the template to change TCP ports is TCP(s_port + d_port), +* while values for each rule will be set during the flow rule creation. +* +* The order of the action in the template must be kept when inserting rules.
Quoted 7 lines
lib/ethdev/rte_flow.h int · line 4463
Quoted 5 lines
lib/ethdev/rte_flow.h +5
-0+* +* @param port_id +* Port identifier of Ethernet device. +* @param[in] attr +* Template attributes. Perhaps add a meaningful prefix to "attr".
Sure thing, will rename all the "attr" to "thing_attr".
Quoted 5 lines
lib/ethdev/rte_flow.h int · line 4466
Quoted 3 lines
lib/ethdev/rte_flow.h +3
-0+* @param[in] actions +* Associated actions (list terminated by the END action). +* The spec member is only used if the mask is 1. Maybe "its mask is all ones"?
Not necessarily, just non-zero value would do. Will make it clearer.
Quoted 11 lines
lib/ethdev/rte_flow.h int · line 4468
Quoted 2 lines
lib/ethdev/rte_flow.h +2
-0+* @param[in] masks +* List of actions that marks which of the action's member is constant. Consider the following action example:
struct rte_flow_action_vxlan_encap { struct rte_flow_item *definition; };So, if "definition" is not NULL, the whole header definition is supposed to be constant, right? Or am I missing something?
If definition has non-zero value then the action spec will be used in every rule created with this template. In this particular example, yes, this definition is going to be a constant header for all the rules.
Quoted 44 lines
Quoted 44 lines
lib/ethdev/rte_flow.h +44
-0+* A mask has the same format as the corresponding action. +* If the action field in @p masks is not 0, +* the corresponding value in an action from @p actions will be the part +* of the template and used in all flow rules. +* The order of actions in @p masks is the same as in @p actions. +* In case of indirect actions present in @p actions, +* the actual action type should be present in @p mask. +* @param[out] error +* Perform verbose error reporting if not NULL. +* PMDs initialize this structure in case of error only. +* +* @return +* handle on success, NULL otherwise and rte_errno is set. +*/ +__rte_experimental +struct rte_flow_action_template * +rte_flow_action_template_create (uint16_t port_id, +const struct rte_flow_action_template_attr *attr, +const struct rte_flow_action actions[], +const struct rte_flow_action masks[], +struct rte_flow_error *error); + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Destroy action template. +* This function may be called only when +* there are no more tables referencing this template. +* +* @param port_id +* Port identifier of Ethernet device. +* @param[in] template +* Handle to the template to be destroyed. +* @param[out] error +* Perform verbose error reporting if not NULL. +* PMDs initialize this structure in case of error only. +* +* @return +* 0 on success, a negative errno value otherwise and rte_errno is set. +*/ +__rte_experimental +int +rte_flow_action_template_destroy(uint16_t port_id,
Quoted 8 lines
lib/ethdev/rte_flow.h int · line 4518
Quoted 6 lines
lib/ethdev/rte_flow.h +6
-0+const struct rte_flow_action_template *template, + struct rte_flow_error *error); + + +/** +* Opaque type returned after successfull creation of table. Redundant "l" in "successful".
Consider this fixed.
Quoted 31 lines
Quoted 31 lines
lib/ethdev/rte_flow.h +31
-0+* This handle can be used to manage the created table. +*/ +struct rte_flow_table ; + +enum rte_flow_table_mode { +/** +* Fixed size, the number of flow rules will be limited. +* It is possible that some of the rules will not be inserted +* due to conflicts/lack of space. +* When rule insertion fails with try again error, +* the application may use one of the following ways +* to address this state: +* 1. Keep this rule processing in the software. +* 2. Try to offload this rule at a later time, +* after some rules have been removed from the hardware. +* 3. Create a new table and add this rule to the new table. +*/ +RTE_FLOW_TABLE_MODE_FIXED , +/** +* Resizable, the PMD/HW will insert all rules. +* No try again error will be received in this mode. +*/ +RTE_FLOW_TABLE_MODE_RESIZABLE , +}; + +/** +* Table attributes. +*/ +struct rte_flow_table_attr { +/** +* Version of the struct layout, should be 0.
Quoted 8 lines
lib/ethdev/rte_flow.h int · line 4555
Quoted 6 lines
lib/ethdev/rte_flow.h +6
-0+*/ +uint32_t version; +/** +* Flow attributes that will be used in the table. +*/ +struct rte_flow_attr attr;Perhaps, "
flow_attr" then?
As we agreed.
Quoted 7 lines
lib/ethdev/rte_flow.h int · line 4560
Quoted 5 lines
lib/ethdev/rte_flow.h +5
-0+/** +* Maximum number of flow rules that this table holds. +* It can be hard or soft limit depending on the mode. +*/ +uint32_t max_rules;How about "
nb_flows_max"?
Just nb_flows maybe?
Re: [dpdk-dev] [PATCH 2/3] ethdev: add flow item/action templates
Quoted 20 lines · Alexander Kozyrev
Quoted 20 lines
From: Ivan Malov <[email protected]> On Wednesday, October 6, 2021 13:25
Quoted 3 lines · Alexander Kozyrev
Treating every single flow rule as a completely independent and separate entity negatively impacts the flow rules insertion rate. Oftentimes in an application, many flow rules share a common structure (the same item
mask
Quoted 4 lines
and/or action list) so they can be grouped and classified together. This knowledge may be used as a source of optimization by a PMD/HW.
The item template defines common matching fields (the item mask)
without
Quoted 8 lines
values. The action template holds a list of action types that will be used together in the same rule. The specific values for items and actions will be given only during the rule creation.
A table combines item and action templates along with shared flow rule attributes (group ID, priority and traffic direction). This way a PMD/HW can prepare all the resources needed for efficient flow rules creation in the datapath. To avoid any hiccups due to memory reallocation, the
Quoted 6 lines
Quoted 6 lines
maximum
Quoted 5 lines
number of flow rules is defined at table creation time.
The flow rule creation is done by selecting a table, an item template and an action template (which are bound to the table), and setting unique values for the items and actions.
For the life cycle of the template -
Is a template supposed to be destroyed immediately after its use? Can there be multiple templates active at a time?
In which case will the application maintain the templates?
And how to identify one template from another? Or that will not be needed?
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Signed-off-by Alexander Kozyrev <[email protected]>Suggested-by Ori Kam <[email protected]>---
Re: [dpdk-dev] [PATCH 2/3] ethdev: add flow item/action templates
Quoted 29 lines
From: Ajit Khaparde <[email protected]> On Tuesday, October 12, 2021 22:27
To: Alexander Kozyrev <[email protected]>Quoted 2 lines
Quoted 2 lines
From: Ivan Malov <[email protected]> On Wednesday, October 6,
2021 13:25
Quoted 2 lines
Quoted 2 lines · Alexander Kozyrev
Quoted 1 line
Treating every single flow rule as a completely independent and
separate
Quoted 16 lines
Quoted 16 lines
Quoted 2 lines
entity negatively impacts the flow rules insertion rate. Oftentimes in an application, many flow rules share a common structure (the same item
mask
Quoted 4 lines
and/or action list) so they can be grouped and classified together. This knowledge may be used as a source of optimization by a PMD/HW.
The item template defines common matching fields (the item mask)
without
Quoted 8 lines
values. The action template holds a list of action types that will be used together in the same rule. The specific values for items and actions will be given only during the rule creation.
A table combines item and action templates along with shared flow rule attributes (group ID, priority and traffic direction). This way a PMD/HW can prepare all the resources needed for efficient flow rules creation in the datapath. To avoid any hiccups due to memory reallocation, the
Quoted 5 lines
Quoted 5 lines
maximum
Quoted 4 lines
number of flow rules is defined at table creation time.
The flow rule creation is done by selecting a table, an item template and an action template (which are bound to the table), and setting
Quoted 8 lines
unique
Quoted 1 line
Quoted 1 line
Quoted 1 line
values for the items and actions.
For the life cycle of the template -
Is a template supposed to be destroyed immediately after its use? Can there be multiple templates active at a time?
In which case will the application maintain the templates?
And how to identify one template from another? Or that will not be needed?
A template must be active until there are no more tables referencing it. This, in turn, means that all the rules using it must be destroyed before that as well. The application gets a template handle and stores it in a table for future usage. There can be many templates stored in a single/multiple tables as needed.
Re: [dpdk-dev] [PATCH 2/3] ethdev: add flow item/action templates
In reply to Alexander KozyrevHi,
Quoted 287 lines · Alexander Kozyrev
Quoted 33 lines
From: Ivan Malov <[email protected]> On Wednesday, October 6, 2021 13:25
Quoted 3 lines · Alexander Kozyrev
Treating every single flow rule as a completely independent and separate entity negatively impacts the flow rules insertion rate. Oftentimes in an application, many flow rules share a common structure (the same item
mask
Quoted 4 lines
and/or action list) so they can be grouped and classified together. This knowledge may be used as a source of optimization by a PMD/HW.
The item template defines common matching fields (the item mask)
without
Quoted 8 lines
values. The action template holds a list of action types that will be used together in the same rule. The specific values for items and actions will be given only during the rule creation.
A table combines item and action templates along with shared flow rule attributes (group ID, priority and traffic direction). This way a PMD/HW can prepare all the resources needed for efficient flow rules creation in the datapath. To avoid any hiccups due to memory reallocation, the
maximum
Quoted 10 lines
number of flow rules is defined at table creation time.
The flow rule creation is done by selecting a table, an item template and an action template (which are bound to the table), and setting unique values for the items and actions.
Signed-off-by Alexander Kozyrev <[email protected]>Suggested-by Ori Kam <[email protected]>--- lib/ethdev/rte_flow.h | 268++++++++++++++++++++++++++++++++++++++++++
Quoted 2 lines
1 file changed, 268 insertions(+)Quoted 13 lines
lib/ethdev/rte_flow.h int · line 4363
Quoted 11 lines
lib/ethdev/rte_flow.h +3
-0@@ -4358,6 +4358,274 @@ int rte_flow_configure(uint16_t port_id, const struct rte_flow_port_attr *port_attr, struct rte_flow_error *error); + +/** +* Opaque type returned after successfull creation of item template. Typo: "successfull" --> "successful".
Thanks for noticing, will correct.
Quoted 30 lines
Quoted 9 lines
lib/ethdev/rte_flow.h +9
-0+* This handle can be used to manage the created item template. +*/ +struct rte_flow_item_template ; + +__extension__ +struct rte_flow_item_template_attr { + /** + * Version of the struct layout, should be 0. + */lib/ethdev/rte_flow.h int
Quoted 10 lines
lib/ethdev/rte_flow.h +10
-0+uint32_t version; +/* No attributes so far. */ +}; + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Create item template. +* The item template defines common matching fields (item mask) without values.
lib/ethdev/rte_flow.h int · line 4391
Quoted 9 lines
lib/ethdev/rte_flow.h +9
-0+* For example, matching on 5 tuple TCP flow, the template will be +* eth(null) + IPv4(source + dest) + TCP(s_port + d_port), +* while values for each rule will be set during the flow rule creation. +* The order of items in the template must be the same at rule insertion. +* +* @param port_id +* Port identifier of Ethernet device. +* @param[in] attr +* Item template attributes. Quoted 4 lines
Please consider adding meaningful prefixes to "attr" here and below. This is needed to avoid confusion with "struct
rte_flow_attr".Example: "
template_attr".No problem.
Quoted 24 lines
lib/ethdev/rte_flow.h int
Quoted 3 lines
lib/ethdev/rte_flow.h +3
-0+* @param[in] items +* Pattern specification (list terminated by the END pattern item). +* The spec member of an item is not used unless the end member is used.
Quoted 20 lines
lib/ethdev/rte_flow.h +20
-0+* @param[out] error +* Perform verbose error reporting if not NULL. +* PMDs initialize this structure in case of error only. +* +* @return +* Handle on success, NULL otherwise and rte_errno is set. +*/ +__rte_experimental +struct rte_flow_item_template * +rte_flow_item_template_create (uint16_t port_id, +const struct rte_flow_item_template_attr *attr, +const struct rte_flow_item items[], +struct rte_flow_error *error); + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Destroy item template. +* This function may be called only when Quoted 8 lines
lib/ethdev/rte_flow.h int · line 4420
Quoted 6 lines
lib/ethdev/rte_flow.h +6
-0+* there are no more tables referencing this template. +* +* @param port_id +* Port identifier of Ethernet device. +* @param[in] template +* Handle to the template to be destroyed. Perhaps "handle OF the template"?
You are right.
Quoted 9 lines
Quoted 9 lines
lib/ethdev/rte_flow.h +9
-0+* @param[out] error +* Perform verbose error reporting if not NULL. +* PMDs initialize this structure in case of error only. +* +* @return +* 0 on success, a negative errno value otherwise and rte_errno is set. +*/ +__rte_experimental +intQuoted 8 lines
lib/ethdev/rte_flow.h int · line 4435
Quoted 6 lines
lib/ethdev/rte_flow.h +6
-0+rte_flow_item_template_destroy(uint16_t port_id, + struct rte_flow_item_template *template, + struct rte_flow_error *error); + +/** +* Opaque type returned after successfull creation of action template. Single "l" in "successful".
Ditto.
Quoted 24 lines
Quoted 13 lines
lib/ethdev/rte_flow.h +13
-0+* This handle can be used to manage the created action template. +*/ +struct rte_flow_action_template ; + +__extension__ +struct rte_flow_action_template_attr { +/** +* Version of the struct layout, should be 0. +*/ +uint32_t version; +/* No attributes so far. */ +}; +lib/ethdev/rte_flow.h int
Quoted 10 lines
lib/ethdev/rte_flow.h +10
-0+/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Create action template. +* The action template holds a list of action types without values. +* For example, the template to change TCP ports is TCP(s_port + d_port), +* while values for each rule will be set during the flow rule creation. +* +* The order of the action in the template must be kept when inserting rules.
Quoted 7 lines
lib/ethdev/rte_flow.h int · line 4463
Quoted 5 lines
lib/ethdev/rte_flow.h +5
-0+* +* @param port_id +* Port identifier of Ethernet device. +* @param[in] attr +* Template attributes. Perhaps add a meaningful prefix to "attr".
Sure thing, will rename all the "attr" to "
thing_attr".Quoted 5 lines
lib/ethdev/rte_flow.h int · line 4466
Quoted 3 lines
lib/ethdev/rte_flow.h +3
-0+* @param[in] actions +* Associated actions (list terminated by the END action). +* The spec member is only used if the mask is 1. Maybe "its mask is all ones"?
Not necessarily, just non-zero value would do. Will make it clearer.
Quoted 11 lines
lib/ethdev/rte_flow.h int · line 4468
Quoted 2 lines
lib/ethdev/rte_flow.h +2
-0+* @param[in] masks +* List of actions that marks which of the action's member is constant. Consider the following action example:
struct rte_flow_action_vxlan_encap { struct rte_flow_item *definition; };So, if "definition" is not NULL, the whole header definition is supposed to be constant, right? Or am I missing something?
If definition has non-zero value then the action spec will be used in every rule created with this template. In this particular example, yes, this definition is going to be a constant header for all the rules.
Quoted 44 lines
Quoted 44 lines
lib/ethdev/rte_flow.h +44
-0+* A mask has the same format as the corresponding action. +* If the action field in @p masks is not 0, +* the corresponding value in an action from @p actions will be the part +* of the template and used in all flow rules. +* The order of actions in @p masks is the same as in @p actions. +* In case of indirect actions present in @p actions, +* the actual action type should be present in @p mask. +* @param[out] error +* Perform verbose error reporting if not NULL. +* PMDs initialize this structure in case of error only. +* +* @return +* handle on success, NULL otherwise and rte_errno is set. +*/ +__rte_experimental +struct rte_flow_action_template * +rte_flow_action_template_create (uint16_t port_id, +const struct rte_flow_action_template_attr *attr, +const struct rte_flow_action actions[], +const struct rte_flow_action masks[], +struct rte_flow_error *error); + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Destroy action template. +* This function may be called only when +* there are no more tables referencing this template. +* +* @param port_id +* Port identifier of Ethernet device. +* @param[in] template +* Handle to the template to be destroyed. +* @param[out] error +* Perform verbose error reporting if not NULL. +* PMDs initialize this structure in case of error only. +* +* @return +* 0 on success, a negative errno value otherwise and rte_errno is set. +*/ +__rte_experimental +int +rte_flow_action_template_destroy(uint16_t port_id,Quoted 8 lines
lib/ethdev/rte_flow.h int · line 4518
Quoted 6 lines
lib/ethdev/rte_flow.h +6
-0+const struct rte_flow_action_template *template, + struct rte_flow_error *error); + + +/** +* Opaque type returned after successfull creation of table. Redundant "l" in "successful".
Consider this fixed.
Quoted 31 lines
Quoted 31 lines
lib/ethdev/rte_flow.h +31
-0+* This handle can be used to manage the created table. +*/ +struct rte_flow_table ; + +enum rte_flow_table_mode { +/** +* Fixed size, the number of flow rules will be limited. +* It is possible that some of the rules will not be inserted +* due to conflicts/lack of space. +* When rule insertion fails with try again error, +* the application may use one of the following ways +* to address this state: +* 1. Keep this rule processing in the software. +* 2. Try to offload this rule at a later time, +* after some rules have been removed from the hardware. +* 3. Create a new table and add this rule to the new table. +*/ +RTE_FLOW_TABLE_MODE_FIXED , +/** +* Resizable, the PMD/HW will insert all rules. +* No try again error will be received in this mode. +*/ +RTE_FLOW_TABLE_MODE_RESIZABLE , +}; + +/** +* Table attributes. +*/ +struct rte_flow_table_attr { +/** +* Version of the struct layout, should be 0. Quoted 8 lines
lib/ethdev/rte_flow.h int · line 4555
Quoted 6 lines
lib/ethdev/rte_flow.h +6
-0+*/ +uint32_t version; +/** +* Flow attributes that will be used in the table. +*/ +struct rte_flow_attr attr;Perhaps, "
flow_attr" then?As we agreed.
Quoted 9 lines
Quoted 7 lines
lib/ethdev/rte_flow.h int · line 4560
Quoted 5 lines
lib/ethdev/rte_flow.h +5
-0+/** +* Maximum number of flow rules that this table holds. +* It can be hard or soft limit depending on the mode. +*/ +uint32_t max_rules;How about "
nb_flows_max"?Just
nb_flowsmaybe?
Probabably OK, too, but I don't have a strong opinion. One more option: "table_size".
Signature · 1 line
Ivan M
PATCH 3/3 ethdev: add async queue-based flow rules operations
In reply to Alexander KozyrevA new, faster, queue-based flow rules management mechanism is needed for applications offloading rules inside the datapath. This asynchronous and lockless mechanism frees the CPU for further packet processing and reduces the performance impact of the flow rules creation/destruction on the datapath. Note that queues are not thread-safe and queue-based operations can be safely invoked without any locks from a single thread.
The rte_flow_q_flow_create() function enqueues a flow creation to the requested queue. It benefits from already configured resources and sets unique values on top of item and action templates. A flow rule is enqueued on the specified flow queue and offloaded asynchronously to the hardware. The function returns immediately to spare CPU for further packet processing. The application must invoke the rte_flow_q_dequeue() function to complete the flow rule operation offloading, to clear the queue, and to receive the operation status. The rte_flow_q_flow_destroy() function enqueues a flow destruction to the requested queue.
--- lib/ethdev/rte_flow.h | 288 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 288 insertions(+)
lib/ethdev/rte_flow.h +288 -0
@@ -4298,6 +4298,13 @@ struct rte_flow_port_attr {* Version of the struct layout, should be 0. */ uint32_t version; +/** +* Number of flow queues to be configured. +* Flow queues are used for asyncronous flow rule creation/destruction. +* The order of operations is not guaranteed inside a queue. +* Flow queues are not thread-safe. +*/ +uint16_t nb_queues;/** * Memory size allocated for the flow rules management. * If set to 0, memory is allocated dynamically.
@@ -4330,6 +4337,21 @@ struct rte_flow_port_attr { uint32_t fixed_resource_size:1; }; +/** +* Flow engine queue configuration. +*/ +__extension__ +struct rte_flow_queue_attr { +/** +* Version of the struct layout, should be 0. +*/ +uint32_t version; +/** +* Number of flow rule operations a queue can hold. +*/ +uint32_t size; +}; +/** * @warning * @b EXPERIMENTAL: this API may change without prior notice.
@@ -4346,6 +4368,8 @@ struct rte_flow_port_attr {* Port identifier of Ethernet device. * @param[in] port_attr * Port configuration attributes. +* @param[in] queue_attr +* Array that holds attributes for each queue. * @param[out] error * Perform verbose error reporting if not NULL. * PMDs initialize this structure in case of error only.
@@ -4357,6 +4381,7 @@ __rte_experimentalint rte_flow_configure (uint16_t port_id,const struct rte_flow_port_attr *port_attr, +const struct rte_flow_queue_attr *queue_attr[],struct rte_flow_error *error);/**
@@ -4626,6 +4651,269 @@ __rte_experimentalint rte_flow_table_destroy (uint16_t port_id,struct rte_flow_table *table,struct rte_flow_error *error); + +/** +* Queue operation attributes +*/ +__extension__ +struct rte_flow_q_ops_attr { +/** +* Version of the struct layout, should be 0. +*/ +uint32_t version; +/** +* The user data that will be returned on the completion. +*/ +void *user_data; +/** +* When set, the requested action must be sent to the HW without +* any delay. Any prior requests must be also sent to the HW. +* If this bit is cleared, the application must call the +* rte_flow_queue_flush API to actually send the request to the HW. +*/ +uint32_t flush:1 ; +}; + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Enqueue rule creation operation. +* +* @param port_id +* Port identifier of Ethernet device. +* @param queue +* Flow queue used to insert the rule. +* @param[in] attr +* Rule creation operation attributes. +* @param[in] table +* Table to select templates from. +* @param[in] items +* List of pattern items to be used. +* The list order should match the order in the item template. +* The spec is the only relevant member of the item that is being used. +* @param[in] item_template_index +* Item template index in the table. +* @param[in] actions +* List of actions to be used. +* The list order should match the order in the action template. +* @param[in] action_template_index +* Action template index in the table. +* @param[out] error +* Perform verbose error reporting if not NULL. +* PMDs initialize this structure in case of error only. +* +* @return +* Handle on success, NULL otherwise and rte_errno is set. +* The rule handle doesn't mean that the rule was offloaded. +* Only completion result indicates that the rule was offloaded. +*/ +__rte_experimental +struct rte_flow * +rte_flow_q_flow_create (uint16_t port_id,uint32_t queue, +const struct rte_flow_q_ops_attr *attr, +const struct rte_flow_table *table, +const struct rte_flow_item items[], +uint8_t item_template_index, +const struct rte_flow_action actions[], +uint8_t action_template_index, +struct rte_flow_error *error); + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Enqueue rule destruction operation. +* +* This function enqueues a destruction operation on the queue. +* Application should assume that after calling this function +* the rule handle is not valid anymore. +* Completion indicates the full removal of the rule from the HW. +* +* @param port_id +* Port identifier of Ethernet device. +* @param queue +* Flow queue which is used to destroy the rule. +* This must match the queue on which the rule was created. +* @param[in] attr +* Rule destroy operation attributes. +* @param[in] flow +* Flow handle to be destroyed. +* @param[out] error +* Perform verbose error reporting if not NULL. +* PMDs initialize this structure in case of error only. +* +* @return +* 0 on success, a negative errno value otherwise and rte_errno is set. +*/ +__rte_experimental +int +rte_flow_q_flow_destroy (uint16_t port_id,uint32_t queue, +struct rte_flow_q_ops_attr *attr, +struct rte_flow *flow, +struct rte_flow_error *error); + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Enqueue indirect rule creation operation. +* @see rte_flow_action_handle_create +* +* @param[in] port_id +* Port identifier of Ethernet device. +* @param[in] queue +* Flow queue which is used to create the rule. +* @param[in] attr +* Queue operation attributes. +* @param[in] conf +* Action configuration for the indirect action object creation. +* @param[in] action +* Specific configuration of the indirect action object. +* @param[out] error +* Perform verbose error reporting if not NULL. +* PMDs initialize this structure in case of error only. +* +* @return +* - (0) if success. +* - (-ENODEV) if *port_id* invalid. +* - (-ENOSYS) if underlying device does not support this functionality. +* - (-EIO) if underlying device is removed. +* - (-ENOENT) if action pointed by *action* handle was not found. +* - (-EBUSY) if action pointed by *action* handle still used by some rules +* rte_errno is also set. +*/ +__rte_experimental +struct rte_flow_action_handle * +rte_flow_q_action_handle_create (uint16_t port_id,uint32_t queue, +const struct rte_flow_q_ops_attr *attr, +const struct rte_flow_indir_action_conf *conf, +const struct rte_flow_action *action, +struct rte_flow_error *error); + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Enqueue indirect rule destruction operation. +* The destroy queue must be the same +* as the queue on which the action was created. +* +* @param[in] port_id +* Port identifier of Ethernet device. +* @param[in] queue +* Flow queue which is used to destroy the rule. +* @param[in] attr +* Queue operation attributes. +* @param[in] handle +* Handle for the indirect action object to be destroyed. +* @param[out] error +* Perform verbose error reporting if not NULL. +* PMDs initialize this structure in case of error only. +* +* @return +* - (0) if success. +* - (-ENODEV) if *port_id* invalid. +* - (-ENOSYS) if underlying device does not support this functionality. +* - (-EIO) if underlying device is removed. +* - (-ENOENT) if action pointed by *action* handle was not found. +* - (-EBUSY) if action pointed by *action* handle still used by some rules +* rte_errno is also set. +*/ +__rte_experimental +int +rte_flow_q_action_handle_destroy (uint16_t port_id,uint32_t queue, +struct rte_flow_q_ops_attr *attr, +struct rte_flow_action_handle *handle, +struct rte_flow_error *error); + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Flush all internally stored rules to the HW. +* Non-flushed rules are rules that were inserted without the flush flag set. +* Can be used to notify the HW about batch of rules prepared by the SW to +* reduce the number of communications between the HW and SW. +* +* @param port_id +* Port identifier of Ethernet device. +* @param queue +* Flow queue to be flushed. +* @param[out] error +* Perform verbose error reporting if not NULL. +* PMDs initialize this structure in case of error only. +* +* @return +* 0 on success, a negative errno value otherwise and rte_errno is set. +*/ +__rte_experimental +int +rte_flow_q_flush (uint16_t port_id,uint32_t queue, +struct rte_flow_error *error); + +/** +* Dequeue operation status. +*/ +enum rte_flow_q_op_status { +/** +* The operation was completed successfully. +*/ +RTE_FLOW_Q_OP_SUCCESS , +/** +* The operation was not completed successfully. +*/ +RTE_FLOW_Q_OP_ERROR , +}; + +/** +* Dequeue operation result. +*/ +struct rte_flow_q_op_res { +/** +* Version of the struct layout, should be 0. +*/ +uint32_t version; +/** +* Returns the status of the operation that this completion signals. +*/ +enum rte_flow_q_op_status status; +/** +* User data that was supplied during operation submission. +*/ +void *user_data; +}; + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Dequeue a rte flow operation. +* The application must invoke this function in order to complete +* the flow rule offloading and to receive the flow rule operation status. +* +* @param port_id +* Port identifier of Ethernet device. +* @param queue +* Flow queue which is used to dequeue the operation. +* @param[out] res +* Array of results that will be set. +* @param[in] n_res +* Maximum number of results that can be returned. +* This value is equal to the size of the res array. +* @param[out] error +* Perform verbose error reporting if not NULL. +* PMDs initialize this structure in case of error only. +* +* @return +* Number of results that were dequeued, +* a negative errno value otherwise and rte_errno is set. +*/ +__rte_experimental +int +rte_flow_q_dequeue (uint16_t port_id,uint32_t queue, +struct rte_flow_q_op_res res[],uint16_t n_res, +struct rte_flow_error *error); #ifdef __cplusplus }#endif
Signature · 1 line
2.18.2
Re: [dpdk-dev] [PATCH 3/3] ethdev: add async queue-based flow rules operations
Hi,
Quoted 28 lines · Alexander Kozyrev
A new, faster, queue-based flow rules management mechanism is needed for applications offloading rules inside the datapath. This asynchronous and lockless mechanism frees the CPU for further packet processing and reduces the performance impact of the flow rules creation/destruction on the datapath. Note that queues are not thread-safe and queue-based operations can be safely invoked without any locks from a single thread.
The
rte_flow_q_flow_create()function enqueues a flow creation to the requested queue. It benefits from already configured resources and sets unique values on top of item and action templates. A flow rule is enqueued on the specified flow queue and offloaded asynchronously to the hardware. The function returns immediately to spare CPU for further packet processing. The application must invoke therte_flow_q_dequeue()function to complete the flow rule operation offloading, to clear the queue, and to receive the operation status. Therte_flow_q_flow_destroy()function enqueues a flow destruction to the requested queue.Signed-off-by Alexander Kozyrev <[email protected]>Suggested-by Ori Kam <[email protected]>--- lib/ethdev/rte_flow.h | 288 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 288 insertions(+)lib/ethdev/rte_flow.h +0
-0
lib/ethdev/rte_flow.h struct rte_flow_port_attr { · line 4303
Quoted 6 lines
lib/ethdev/rte_flow.h +3
-0@@ -4298,6 +4298,13 @@ struct rte_flow_port_attr {* Version of the struct layout, should be 0. */ uint32_t version; +/** +* Number of flow queues to be configured. +* Flow queues are used for asyncronous flow rule creation/destruction.
Typo: asyncronous --> asynchronous
Quoted 8 lines
lib/ethdev/rte_flow.h +4
-0+* The order of operations is not guaranteed inside a queue. +* Flow queues are not thread-safe. +*/ +uint16_t nb_queues;/** * Memory size allocated for the flow rules management. * If set to 0, memory is allocated dynamically.
lib/ethdev/rte_flow.h struct rte_flow_port_attr { · line 4344
Quoted 8 lines
lib/ethdev/rte_flow.h +5
-0@@ -4330,6 +4337,21 @@ struct rte_flow_port_attr { uint32_t fixed_resource_size:1; }; +/** +* Flow engine queue configuration. +*/ +__extension__ +struct rte_flow_queue_attr {
Perhaps "struct rte_flow_queue_mode" or "struct rte_flow_queue_conf". I don't insist.
Quoted 14 lines
lib/ethdev/rte_flow.h +10
-0+/** +* Version of the struct layout, should be 0. +*/ +uint32_t version; +/** +* Number of flow rule operations a queue can hold. +*/ +uint32_t size; +}; +/** * @warning * @b EXPERIMENTAL: this API may change without prior notice.
lib/ethdev/rte_flow.h struct rte_flow_port_attr { · line 4372
Quoted 5 lines
lib/ethdev/rte_flow.h +2
-0@@ -4346,6 +4368,8 @@ struct rte_flow_port_attr {* Port identifier of Ethernet device. * @param[in] port_attr * Port configuration attributes. +* @param[in] queue_attr +* Array that holds attributes for each queue.
This should probably say that the number of queues / array size is taken from port_attr->nb_queues.
Also, consider "... for each flow queue".
Quoted 17 lines
lib/ethdev/rte_flow.h +3
-0* @param[out] error * Perform verbose error reporting if not NULL. * PMDs initialize this structure in case of error only. @@ -4357,6 +4381,7 @@ __rte_experimentalint rte_flow_configure (uint16_t port_id,const struct rte_flow_port_attr *port_attr, +const struct rte_flow_queue_attr *queue_attr[],struct rte_flow_error *error);/** @@ -4626,6 +4651,269 @@ __rte_experimentalint rte_flow_table_destroy (uint16_t port_id,struct rte_flow_table *table,struct rte_flow_error *error); + +/**
lib/ethdev/rte_flow.h __rte_experimental · line 4665
Quoted 10 lines
lib/ethdev/rte_flow.h +10
-0+* Queue operation attributes +*/ +__extension__ +struct rte_flow_q_ops_attr { + /** + * Version of the struct layout, should be 0. + */ + uint32_t version; + /** + * The user data that will be returned on the completion.
Maybe "on completion events"?
lib/ethdev/rte_flow.h __rte_experimental · line 4672
Quoted 7 lines
lib/ethdev/rte_flow.h +7
-0+*/ +void *user_data; +/** +* When set, the requested action must be sent to the HW without +* any delay. Any prior requests must be also sent to the HW. +* If this bit is cleared, the application must call the +* rte_flow_queue_flush API to actually send the request to the HW.
Not sure that I understand the "Any prior requests ..." part. If this structure configures operation mode for the whole queue and not for each enqueue request, then no "prior requests" can exist in the first place because each submission is meant to be immediately sent to the HW.
But if this structure can vary across enqueue requests, then this documentation should be improved to say this clearly.
Quoted 6 lines
lib/ethdev/rte_flow.h +6
-0+*/ + uint32_t flush:1; +}; + +/** +* @warning
lib/ethdev/rte_flow.h __rte_experimental · line 4688
Quoted 10 lines
lib/ethdev/rte_flow.h +10
-0+* @b EXPERIMENTAL: this API may change without prior notice. +* +* Enqueue rule creation operation. +* +* @param port_id +* Port identifier of Ethernet device. +* @param queue +* Flow queue used to insert the rule. +* @param[in] attr +* Rule creation operation attributes.
At a bare minimum, please consider renaming this to "queue_attr". More variants (see above): "queue_mode", "queue_conf". I suggest doing so to avoid confusion with "struct rte_flow_attr" which sits in "struct rte_flow_table_attr" in fact.
If this structure must be exactly the same as the one used in rte_flow_configure(), please say so. If, however, this structure can be completely different on enqueue operations, then the argument name should indicate it somehow. Maybe, "override_queue_conf". Otherwise, it's unclear.
There are similar occurrences below.
lib/ethdev/rte_flow.h __rte_experimental · line 4690
Quoted 2 lines
lib/ethdev/rte_flow.h +2
-0+* @param[in] table +* Table to select templates from.
Perhaps "template_table"?
Quoted 61 lines
lib/ethdev/rte_flow.h +61
-0+* @param[in] items +* List of pattern items to be used. +* The list order should match the order in the item template. +* The spec is the only relevant member of the item that is being used. +* @param[in] item_template_index +* Item template index in the table. +* @param[in] actions +* List of actions to be used. +* The list order should match the order in the action template. +* @param[in] action_template_index +* Action template index in the table. +* @param[out] error +* Perform verbose error reporting if not NULL. +* PMDs initialize this structure in case of error only. +* +* @return +* Handle on success, NULL otherwise and rte_errno is set. +* The rule handle doesn't mean that the rule was offloaded. +* Only completion result indicates that the rule was offloaded. +*/ +__rte_experimental +struct rte_flow * +rte_flow_q_flow_create (uint16_t port_id,uint32_t queue, +const struct rte_flow_q_ops_attr *attr, +const struct rte_flow_table *table, +const struct rte_flow_item items[], +uint8_t item_template_index, +const struct rte_flow_action actions[], +uint8_t action_template_index, +struct rte_flow_error *error); + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Enqueue rule destruction operation. +* +* This function enqueues a destruction operation on the queue. +* Application should assume that after calling this function +* the rule handle is not valid anymore. +* Completion indicates the full removal of the rule from the HW. +* +* @param port_id +* Port identifier of Ethernet device. +* @param queue +* Flow queue which is used to destroy the rule. +* This must match the queue on which the rule was created. +* @param[in] attr +* Rule destroy operation attributes. +* @param[in] flow +* Flow handle to be destroyed. +* @param[out] error +* Perform verbose error reporting if not NULL. +* PMDs initialize this structure in case of error only. +* +* @return +* 0 on success, a negative errno value otherwise and rte_errno is set. +*/ +__rte_experimental +int +rte_flow_q_flow_destroy(uint16_t port_id, uint32_t queue,
lib/ethdev/rte_flow.h __rte_experimental · line 4761
Quoted 10 lines
lib/ethdev/rte_flow.h +10
-0+struct rte_flow_q_ops_attr *attr, + struct rte_flow *flow, + struct rte_flow_error *error); + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Enqueue indirect rule creation operation. +* @see rte_flow_action_handle_create
Why "indirect rule"? This API seems to enqueue an "indirect action"...
lib/ethdev/rte_flow.h __rte_experimental · line 4770
Quoted 9 lines
lib/ethdev/rte_flow.h +9
-0+* +* @param[in] port_id +* Port identifier of Ethernet device. +* @param[in] queue +* Flow queue which is used to create the rule. +* @param[in] attr +* Queue operation attributes. +* @param[in] conf +* Action configuration for the indirect action object creation.
Perhaps "indir_conf" or "indir_action_conf"?
Quoted 18 lines
lib/ethdev/rte_flow.h +18
-0+* @param[in] action +* Specific configuration of the indirect action object. +* @param[out] error +* Perform verbose error reporting if not NULL. +* PMDs initialize this structure in case of error only. +* +* @return +* - (0) if success. +* - (-ENODEV) if *port_id* invalid. +* - (-ENOSYS) if underlying device does not support this functionality. +* - (-EIO) if underlying device is removed. +* - (-ENOENT) if action pointed by *action* handle was not found. +* - (-EBUSY) if action pointed by *action* handle still used by some rules +* rte_errno is also set. +*/ +__rte_experimental +struct rte_flow_action_handle * +rte_flow_q_action_handle_create(uint16_t port_id, uint32_t queue,
lib/ethdev/rte_flow.h __rte_experimental · line 4798
Quoted 10 lines
lib/ethdev/rte_flow.h +10
-0+const struct rte_flow_q_ops_attr *attr, + const struct rte_flow_indir_action_conf *conf, + const struct rte_flow_action *action, + struct rte_flow_error *error); + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Enqueue indirect rule destruction operation.
Please see above. Did you mean "indirect action"?
Quoted 121 lines
lib/ethdev/rte_flow.h +117
-0+* The destroy queue must be the same +* as the queue on which the action was created. +* +* @param[in] port_id +* Port identifier of Ethernet device. +* @param[in] queue +* Flow queue which is used to destroy the rule. +* @param[in] attr +* Queue operation attributes. +* @param[in] handle +* Handle for the indirect action object to be destroyed. +* @param[out] error +* Perform verbose error reporting if not NULL. +* PMDs initialize this structure in case of error only. +* +* @return +* - (0) if success. +* - (-ENODEV) if *port_id* invalid. +* - (-ENOSYS) if underlying device does not support this functionality. +* - (-EIO) if underlying device is removed. +* - (-ENOENT) if action pointed by *action* handle was not found. +* - (-EBUSY) if action pointed by *action* handle still used by some rules +* rte_errno is also set. +*/ +__rte_experimental +int +rte_flow_q_action_handle_destroy (uint16_t port_id,uint32_t queue, +struct rte_flow_q_ops_attr *attr, +struct rte_flow_action_handle *handle, +struct rte_flow_error *error); + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Flush all internally stored rules to the HW. +* Non-flushed rules are rules that were inserted without the flush flag set. +* Can be used to notify the HW about batch of rules prepared by the SW to +* reduce the number of communications between the HW and SW. +* +* @param port_id +* Port identifier of Ethernet device. +* @param queue +* Flow queue to be flushed. +* @param[out] error +* Perform verbose error reporting if not NULL. +* PMDs initialize this structure in case of error only. +* +* @return +* 0 on success, a negative errno value otherwise and rte_errno is set. +*/ +__rte_experimental +int +rte_flow_q_flush (uint16_t port_id,uint32_t queue, +struct rte_flow_error *error); + +/** +* Dequeue operation status > + */ +enum rte_flow_q_op_status { +/** +* The operation was completed successfully. +*/ +RTE_FLOW_Q_OP_SUCCESS , +/** +* The operation was not completed successfully. +*/ +RTE_FLOW_Q_OP_ERROR , +}; + +/** +* Dequeue operation result. +*/ +struct rte_flow_q_op_res { +/** +* Version of the struct layout, should be 0. +*/ +uint32_t version; +/** +* Returns the status of the operation that this completion signals. +*/ +enum rte_flow_q_op_status status; +/** +* User data that was supplied during operation submission. +*/ +void *user_data; +}; + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Dequeue a rte flow operation. +* The application must invoke this function in order to complete +* the flow rule offloading and to receive the flow rule operation status. +* +* @param port_id +* Port identifier of Ethernet device. +* @param queue +* Flow queue which is used to dequeue the operation. +* @param[out] res +* Array of results that will be set. +* @param[in] n_res +* Maximum number of results that can be returned. +* This value is equal to the size of the res array. +* @param[out] error +* Perform verbose error reporting if not NULL. +* PMDs initialize this structure in case of error only. +* +* @return +* Number of results that were dequeued, +* a negative errno value otherwise and rte_errno is set. +*/ +__rte_experimental +int +rte_flow_q_dequeue (uint16_t port_id,uint32_t queue, +struct rte_flow_q_op_res res[],uint16_t n_res, +struct rte_flow_error *error); #ifdef __cplusplus }#endif
Signature · 1 line
Ivan M
Re: [dpdk-dev] [PATCH 3/3] ethdev: add async queue-based flow rules operations
Quoted 26 lines
From: Ivan Malov <[email protected]> on Wednesday, October 6, 2021 12:25
Quoted 17 lines · Alexander Kozyrev
A new, faster, queue-based flow rules management mechanism is needed for applications offloading rules inside the datapath. This asynchronous and lockless mechanism frees the CPU for further packet processing and reduces the performance impact of the flow rules creation/destruction on the datapath. Note that queues are not thread-safe and queue-based operations can be safely invoked without any locks from a single thread.
The
rte_flow_q_flow_create()function enqueues a flow creation to the requested queue. It benefits from already configured resources and sets unique values on top of item and action templates. A flow rule is enqueued on the specified flow queue and offloaded asynchronously to the hardware. The function returns immediately to spare CPU for further packet processing. The application must invoke therte_flow_q_dequeue()function to complete the flow rule operation offloading, to clear the queue, and to receive the operation status. Therte_flow_q_flow_destroy()function enqueues a flow destruction to the requested queue.Quoted 4 lines
Signed-off-by Alexander Kozyrev <[email protected]>Suggested-by Ori Kam <[email protected]>--- lib/ethdev/rte_flow.h | 288++++++++++++++++++++++++++++++++++++++++++
Quoted 2 lines
1 file changed, 288 insertions(+)
Quoted 13 lines
lib/ethdev/rte_flow.h struct rte_flow_port_attr { · line 4303
Quoted 11 lines
lib/ethdev/rte_flow.h +3
-0@@ -4298,6 +4298,13 @@ struct rte_flow_port_attr {* Version of the struct layout, should be 0. */ uint32_t version; +/** +* Number of flow queues to be configured. +* Flow queues are used for asyncronous flow rule creation/destruction. Typo: asyncronous --> asynchronous
Thanks for noticing, will correct all the typos.
Quoted 11 lines
Quoted 11 lines
lib/ethdev/rte_flow.h +4
-0+* The order of operations is not guaranteed inside a queue. +* Flow queues are not thread-safe. +*/ +uint16_t nb_queues;/** * Memory size allocated for the flow rules management. * If set to 0, memory is allocated dynamically. @@ -4330,6 +4337,21 @@ struct rte_flow_port_attr { uint32_t fixed_resource_size:1; };
Quoted 8 lines
lib/ethdev/rte_flow.h struct rte_flow_port_attr { · line 4344
Quoted 5 lines
lib/ethdev/rte_flow.h +5
-0+/** +* Flow engine queue configuration. +*/ +__extension__ +struct rte_flow_queue_attr {Perhaps "struct
rte_flow_queue_mode" or "structrte_flow_queue_conf". I don't insist.
I would prefer sticking to attributes for consistency. We have them elsewhere.
Quoted 14 lines
Quoted 14 lines
lib/ethdev/rte_flow.h +10
-0+/** +* Version of the struct layout, should be 0. +*/ +uint32_t version; +/** +* Number of flow rule operations a queue can hold. +*/ +uint32_t size; +}; +/** * @warning * @b EXPERIMENTAL: this API may change without prior notice. @@ -4346,6 +4368,8 @@ struct rte_flow_port_attr {
Quoted 8 lines
lib/ethdev/rte_flow.h struct rte_flow_port_attr { · line 4372
Quoted 5 lines
lib/ethdev/rte_flow.h +2
-0* Port identifier of Ethernet device. * @param[in] port_attr * Port configuration attributes. +* @param[in] queue_attr +* Array that holds attributes for each queue. This should probably say that the number of queues / array size is taken from
port_attr->nb_queues.
Good idea, will mention this.
Quoted 1 line
Also, consider "... for each flow queue".
Sounds good.
Quoted 21 lines
Quoted 21 lines
lib/ethdev/rte_flow.h +7
-0* @param[out] error * Perform verbose error reporting if not NULL. * PMDs initialize this structure in case of error only. @@ -4357,6 +4381,7 @@ __rte_experimentalint rte_flow_configure (uint16_t port_id,const struct rte_flow_port_attr *port_attr, +const struct rte_flow_queue_attr *queue_attr[],struct rte_flow_error *error);/** @@ -4626,6 +4651,269 @@ __rte_experimentalint rte_flow_table_destroy (uint16_t port_id,struct rte_flow_table *table,struct rte_flow_error *error); + +/** +* Queue operation attributes +*/ +__extension__ +struct rte_flow_q_ops_attr {
Quoted 8 lines
lib/ethdev/rte_flow.h __rte_experimental · line 4665
Quoted 6 lines
lib/ethdev/rte_flow.h +6
-0+/** +* Version of the struct layout, should be 0. +*/ +uint32_t version; +/** +* The user data that will be returned on the completion. Maybe "on completion events"?
Agree.
Quoted 4 lines
Quoted 4 lines
lib/ethdev/rte_flow.h +4
-0+*/ +void *user_data; +/** +* When set, the requested action must be sent to the HW without
Quoted 8 lines
lib/ethdev/rte_flow.h __rte_experimental · line 4672
Quoted 3 lines
lib/ethdev/rte_flow.h +3
-0+* any delay. Any prior requests must be also sent to the HW. +* If this bit is cleared, the application must call the +* rte_flow_queue_flush API to actually send the request to the HW. Not sure that I understand the "Any prior requests ..." part. If this structure configures operation mode for the whole queue and not for each enqueue request, then no "prior requests" can exist in the first place because each submission is meant to be immediately sent to the HW.
This structure configures attributes per single operation.
User can send multiple operations without "flush" attribute set to keep them in a queue. Then it is possible to issue one operation with "flush" attribute set to purge the whole queue.
Quoted 2 lines
But if this structure can vary across enqueue requests, then this documentation should be improved to say this clearly.
I'll try to make it clear that it is per-operation attributes indeed.
Quoted 18 lines
Quoted 6 lines
lib/ethdev/rte_flow.h +6
-0+*/ + uint32_t flush:1; +}; + +/** +* @warning lib/ethdev/rte_flow.h __rte_experimental · line 4688
Quoted 10 lines
lib/ethdev/rte_flow.h +10
-0+* @b EXPERIMENTAL: this API may change without prior notice. +* +* Enqueue rule creation operation. +* +* @param port_id +* Port identifier of Ethernet device. +* @param queue +* Flow queue used to insert the rule. +* @param[in] attr +* Rule creation operation attributes. At a bare minimum, please consider renaming this to "
queue_attr". More
Quoted 8 lines
variants (see above): "
queue_mode", "queue_conf". I suggest doing so to avoid confusion with "structrte_flow_attr" which sits in "structrte_flow_table_attr" in fact.
If this structure must be exactly the same as the one used inrte_flow_configure(), please say so. If, however, this structure can be completely different on enqueue operations, then the argument name should indicate it somehow. Maybe, "override_queue_conf". Otherwise, it's unclear.
Sounds reasonable, will do. Although it is operation attributes, not the queue's ones.
Quoted 5 lines
There are similar occurrences below.
lib/ethdev/rte_flow.h __rte_experimental · line 4690
Quoted 2 lines
lib/ethdev/rte_flow.h +2
-0+* @param[in] table +* Table to select templates from. Perhaps "
template_table"?
Noted.
Quoted 65 lines
Quoted 65 lines
lib/ethdev/rte_flow.h +65
-0+* @param[in] items +* List of pattern items to be used. +* The list order should match the order in the item template. +* The spec is the only relevant member of the item that is being used. +* @param[in] item_template_index +* Item template index in the table. +* @param[in] actions +* List of actions to be used. +* The list order should match the order in the action template. +* @param[in] action_template_index +* Action template index in the table. +* @param[out] error +* Perform verbose error reporting if not NULL. +* PMDs initialize this structure in case of error only. +* +* @return +* Handle on success, NULL otherwise and rte_errno is set. +* The rule handle doesn't mean that the rule was offloaded. +* Only completion result indicates that the rule was offloaded. +*/ +__rte_experimental +struct rte_flow * +rte_flow_q_flow_create (uint16_t port_id,uint32_t queue, +const struct rte_flow_q_ops_attr *attr, +const struct rte_flow_table *table, +const struct rte_flow_item items[], +uint8_t item_template_index, +const struct rte_flow_action actions[], +uint8_t action_template_index, +struct rte_flow_error *error); + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Enqueue rule destruction operation. +* +* This function enqueues a destruction operation on the queue. +* Application should assume that after calling this function +* the rule handle is not valid anymore. +* Completion indicates the full removal of the rule from the HW. +* +* @param port_id +* Port identifier of Ethernet device. +* @param queue +* Flow queue which is used to destroy the rule. +* This must match the queue on which the rule was created. +* @param[in] attr +* Rule destroy operation attributes. +* @param[in] flow +* Flow handle to be destroyed. +* @param[out] error +* Perform verbose error reporting if not NULL. +* PMDs initialize this structure in case of error only. +* +* @return +* 0 on success, a negative errno value otherwise and rte_errno is set. +*/ +__rte_experimental +int +rte_flow_q_flow_destroy (uint16_t port_id,uint32_t queue, +struct rte_flow_q_ops_attr *attr, +struct rte_flow *flow, +struct rte_flow_error *error); +
Quoted 8 lines
lib/ethdev/rte_flow.h __rte_experimental · line 4761
Quoted 6 lines
lib/ethdev/rte_flow.h +6
-0+/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Enqueue indirect rule creation operation. +* @see rte_flow_action_handle_create Why "indirect rule"? This API seems to enqueue an "indirect action"...
Thanks, will change to action.
Quoted 11 lines
lib/ethdev/rte_flow.h __rte_experimental · line 4770
Quoted 9 lines
lib/ethdev/rte_flow.h +9
-0+* +* @param[in] port_id +* Port identifier of Ethernet device. +* @param[in] queue +* Flow queue which is used to create the rule. +* @param[in] attr +* Queue operation attributes. +* @param[in] conf +* Action configuration for the indirect action object creation. Perhaps "
indir_conf" or "indir_action_conf"?
Ok.
Quoted 22 lines
Quoted 22 lines
lib/ethdev/rte_flow.h +22
-0+* @param[in] action +* Specific configuration of the indirect action object. +* @param[out] error +* Perform verbose error reporting if not NULL. +* PMDs initialize this structure in case of error only. +* +* @return +* - (0) if success. +* - (-ENODEV) if *port_id* invalid. +* - (-ENOSYS) if underlying device does not support this functionality. +* - (-EIO) if underlying device is removed. +* - (-ENOENT) if action pointed by *action* handle was not found. +* - (-EBUSY) if action pointed by *action* handle still used by some rules +* rte_errno is also set. +*/ +__rte_experimental +struct rte_flow_action_handle * +rte_flow_q_action_handle_create (uint16_t port_id,uint32_t queue, +const struct rte_flow_q_ops_attr *attr, +const struct rte_flow_indir_action_conf *conf, +const struct rte_flow_action *action, +struct rte_flow_error *error);
Quoted 8 lines
lib/ethdev/rte_flow.h __rte_experimental · line 4798
Quoted 6 lines
lib/ethdev/rte_flow.h +6
-0+ +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Enqueue indirect rule destruction operation. Please see above. Did you mean "indirect action"?
Again, you are right, action is a better word here.
Re: [dpdk-dev] [PATCH 3/3] ethdev: add async queue-based flow rules operations
In reply to Alexander KozyrevQuoted 29 lines · Alexander Kozyrev
A new, faster, queue-based flow rules management mechanism is needed for applications offloading rules inside the datapath. This asynchronous and lockless mechanism frees the CPU for further packet processing and reduces the performance impact of the flow rules creation/destruction on the datapath. Note that queues are not thread-safe and queue-based operations can be safely invoked without any locks from a single thread.
The
rte_flow_q_flow_create()function enqueues a flow creation to the requested queue. It benefits from already configured resources and sets unique values on top of item and action templates. A flow rule is enqueued on the specified flow queue and offloaded asynchronously to the hardware. The function returns immediately to spare CPU for further packet processing. The application must invoke therte_flow_q_dequeue()function to complete the flow rule operation offloading, to clear the queue, and to receive the operation status. Therte_flow_q_flow_destroy()function enqueues a flow destruction to the requested queue.Signed-off-by Alexander Kozyrev <[email protected]>Suggested-by Ori Kam <[email protected]>--- lib/ethdev/rte_flow.h | 288 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 288 insertions(+)lib/ethdev/rte_flow.h +0
-0
lib/ethdev/rte_flow.h struct rte_flow_port_attr { · line 4307
Quoted 10 lines
lib/ethdev/rte_flow.h +7
-0@@ -4298,6 +4298,13 @@ struct rte_flow_port_attr {* Version of the struct layout, should be 0. */ uint32_t version; +/** +* Number of flow queues to be configured. +* Flow queues are used for asyncronous flow rule creation/destruction. +* The order of operations is not guaranteed inside a queue. +* Flow queues are not thread-safe. +*/ +uint16_t nb_queues;
Will it matter if PMD can create a smaller set of queues? Or may be just one? Should the application set this based on get_infos_get() or some other mechanism?
::::
Re: [dpdk-dev] [PATCH 3/3] ethdev: add async queue-based flow rules operations
Hi Ajit,
Quoted 41 lines
-----Original Message-----
From: Ajit Khaparde <[email protected]>
Sent: Wednesday, October 13, 2021 7:58 AM
Subject: Re: [PATCH 3/3] ethdev: add async queue-based flow rules operationsQuoted 7 lines · Alexander Kozyrev
A new, faster, queue-based flow rules management mechanism is needed
for applications offloading rules inside the datapath. This
asynchronous and lockless mechanism frees the CPU for further packet processing and reduces the performance impact of the flow rules creation/destruction on the datapath. Note that queues are not
thread-safe and queue-based operations can be safely invoked without any locks from a singlethread.
Quoted 27 lines
The
rte_flow_q_flow_create()function enqueues a flow creation to the requested queue. It benefits from already configured resources and
sets unique values on top of item and action templates. A flow rule is enqueued on the specified flow queue and offloaded asynchronously to the hardware. The function returns immediately to spare CPU for further packet processing. The application must invoke therte_flow_q_dequeue()function to complete the flow rule operation offloading, to clear the queue, and to receive the operation status. Therte_flow_q_flow_destroy()function enqueues a flow destruction to the requested queue.Signed-off-by Alexander Kozyrev <[email protected]>Suggested-by Ori Kam <[email protected]>--- lib/ethdev/rte_flow.h | 288 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 288 insertions(+)lib/ethdev/rte_flow.h index renamed from lib/ethdev/rte_flow.h +0
-0
ba3204b17e..8cdffd8d2e100644lib/ethdev/rte_flow.h +1
-0@@ -4298,6 +4298,13 @@ struct rte_flow_port_attr {* Version of the struct layout, should be 0. */ uint32_t version; +/**
Quoted 9 lines
lib/ethdev/rte_flow.h struct rte_flow_port_attr { · line 4307
Quoted 6 lines
lib/ethdev/rte_flow.h +6
-0+* Number of flow queues to be configured. +* Flow queues are used for asyncronous flow rule creation/destruction. +* The order of operations is not guaranteed inside a queue. +* Flow queues are not thread-safe. +*/ +uint16_t nb_queues;Will it matter if PMD can create a smaller set of queues? Or may be just one? Should the application set this based on
get_infos_get()or some other mechanism?
This is the number of queues from application point of view. PMD can implement just one queue using locks.
Best,
Ori
Quoted 1 line
::::
v2 cover ethdev: datapath-focused flow rules management
In reply to Alexander KozyrevThree major changes to a generic RTE Flow API were implemented in order to speed up flow rule insertion/destruction and adapt the API to the needs of a datapath-focused flow rules management applications:
1. Pre-configuration hints.
Application may give us some hints on what type of resources are needed. Introduce the configuration routine to prepare all the needed resources inside a PMD/HW before any flow rules are created at the init stage.
2. Flow grouping using templates.
Use the knowledge about which flow rules are to be used in an application and prepare item and action templates for them in advance. Group flow rules with common patterns and actions together for better resource management.
3. Queue-based flow management.
Perform flow rule insertion/destruction asynchronously to spare the datapath from blocking on RTE Flow API and allow it to continue with packet processing. Enqueue flow rules operations and poll for the results later.
testpmd examples are part of the patch series. PMD changes will follow.
RFC: https://patchwork.dpdk.org/project/dpdk/cover/[email protected]/
---
v2: fixed patch series thread
Alexander Kozyrev (10):
ethdev: introduce flow pre-configuration hints
ethdev: add flow item/action templates
ethdev: bring in async queue-based flow rules operations app/testpmd: implement rte flow configure app/testpmd: implement rte flow item/action template app/testpmd: implement rte flow table app/testpmd: implement rte flow queue create flow app/testpmd: implement rte flow queue drain app/testpmd: implement rte flow queue dequeue app/testpmd: implement rte flow queue indirect action
app/test-pmd/cmdline_flow.c | 1484 ++++++++++++++++- app/test-pmd/config.c | 731 ++++++++ app/test-pmd/testpmd.h | 61 + doc/guides/prog_guide/img/rte_flow_q_init.svg | 71 + .../prog_guide/img/rte_flow_q_usage.svg | 60 + doc/guides/prog_guide/rte_flow.rst | 319 ++++ doc/guides/rel_notes/release_22_03.rst | 19 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 350 +++- lib/ethdev/rte_flow.c | 332 ++++ lib/ethdev/rte_flow.h | 680 ++++++++ lib/ethdev/rte_flow_driver.h | 103 ++ lib/ethdev/version.map | 16 + 12 files changed, 4203 insertions(+), 23 deletions(-) create mode 100644 doc/guides/prog_guide/img/rte_flow_q_init.svg create mode 100644 doc/guides/prog_guide/img/rte_flow_q_usage.svg
Signature · 1 line
2.18.2
PATCH v2 1/10 ethdev: introduce flow pre-configuration hints
The flow rules creation/destruction at a large scale incurs a performance penalty and may negatively impact the packet processing when used as part of the datapath logic. This is mainly because software/hardware resources are allocated and prepared during the flow rule creation.
In order to optimize the insertion rate, PMD may use some hints provided by the application at the initialization phase. The rte_flow_configure() function allows to pre-allocate all the needed resources beforehand. These resources can be used at a later stage without costly allocations. Every PMD may use only the subset of hints and ignore unused ones or fail in case the requested configuration is not supported.
--- doc/guides/prog_guide/rte_flow.rst | 37 +++++++++++++++ doc/guides/rel_notes/release_22_03.rst | 2 + lib/ethdev/rte_flow.c | 20 ++++++++ lib/ethdev/rte_flow.h | 63 ++++++++++++++++++++++++++ lib/ethdev/rte_flow_driver.h | 5 ++ lib/ethdev/version.map | 3 ++ 6 files changed, 130 insertions(+)
doc/guides/prog_guide/rte_flow.rst +37 -0
@@ -3589,6 +3589,43 @@ Return values: - 0 on success, a negative errno value otherwise and ``rte_errno`` is set. +Rules management configuration +------------------------------ + +Configure flow rules management. + +An application may provide some hints at the initialization phase about +rules management configuration and/or expected flow rules characteristics. +These hints may be used by PMD to pre-allocate resources and configure NIC. + +Configuration +~~~~~~~~~~~~~ + +This function performs the flow rules management configuration and +pre-allocates needed resources beforehand to avoid costly allocations later. +Hints about the expected number of counters or meters in an application, +for example, allow PMD to prepare and optimize NIC memory layout in advance. +``rte_flow_configure()`` must be called before any flow rule is created, +but after an Ethernet device is configured. + +.. code-block:: c + + int + rte_flow_configure(uint16_t port_id, + const struct rte_flow_port_attr *port_attr, + struct rte_flow_error *error); + +Arguments: + +- ``port_id``: port identifier of Ethernet device. +- ``port_attr``: port attributes for flow management library. +- ``error``: perform verbose error reporting if not NULL. PMDs initialize + this structure in case of error only. + +Return values: + +- 0 on success, a negative errno value otherwise and ``rte_errno`` is set. + .. _flow_isolated_mode: Flow isolated mode
doc/guides/rel_notes/release_22_03.rst +2 -0
@@ -55,6 +55,8 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* ethdev: Added ``rte_flow_configure`` API to configure Flow Management + library, allowing to pre-allocate some resources for better performance. Removed Items -------------
lib/ethdev/rte_flow.c +20 -0
@@ -1391,3 +1391,23 @@ rte_flow_flex_item_release(uint16_t port_id, ret = ops->flex_item_release (dev, handle, error);return flow_err (port_id, ret, error); } + +int +rte_flow_configure (uint16_t port_id, +const struct rte_flow_port_attr *port_attr, +struct rte_flow_error *error) +{ +struct rte_eth_dev *dev = &rte_eth_devices[port_id]; +const struct rte_flow_ops *ops =rte_flow_ops_get (port_id, error); + +if (unlikely (!ops)) +return -rte_errno; +if (likely (!!ops->configure)) { +return flow_err (port_id, + ops->configure (dev, port_attr, error), + error); + } +return rte_flow_error_set (error,ENOTSUP , +RTE_FLOW_ERROR_TYPE_UNSPECIFIED , +NULL ,rte_strerror (ENOTSUP )); +}
lib/ethdev/rte_flow.h +63 -0
69 lines not on this page · raw message
lib/ethdev/rte_flow_driver.h +5 -0
@@ -152,6 +152,11 @@ struct rte_flow_ops { (struct rte_eth_dev *dev, const struct rte_flow_item_flex_handle *handle, struct rte_flow_error *error); +/** See rte_flow_configure() */ +int (*configure) + (struct rte_eth_dev *dev, +const struct rte_flow_port_attr *port_attr, +struct rte_flow_error *err); };/**
lib/ethdev/version.map +3 -0
@@ -256,6 +256,9 @@ EXPERIMENTAL { rte_flow_flex_item_create; rte_flow_flex_item_release; rte_flow_pick_transfer_proxy; + + # added in 22.03 + rte_flow_configure; }; INTERNAL {
Signature · 1 line
2.18.2
Re: [PATCH v2 01/10] ethdev: introduce flow pre-configuration hints
Quoted 17 lines · Alexander Kozyrev
The flow rules creation/destruction at a large scale incurs a performance penalty and may negatively impact the packet processing when used as part of the datapath logic. This is mainly because software/hardware resources are allocated and prepared during the flow rule creation.
In order to optimize the insertion rate, PMD may use some hints provided by the application at the initialization phase. The
rte_flow_configure()function allows to pre-allocate all the needed resources beforehand. These resources can be used at a later stage without costly allocations. Every PMD may use only the subset of hints and ignore unused ones or fail in case the requested configuration is not supported.Signed-off-by Alexander Kozyrev <[email protected]>---
lib/ethdev/rte_flow.h rte_flow_flex_item_release(uint16_t port_id, · line 4862
Quoted 7 lines
lib/ethdev/rte_flow.h +7
-0+/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Flow engine port configuration attributes. +*/ +__extension__
Is this __extension__ required ?
lib/ethdev/rte_flow.h rte_flow_flex_item_release(uint16_t port_id, · line 4867
Quoted 5 lines
lib/ethdev/rte_flow.h +5
-0+struct rte_flow_port_attr { +/** +* Version of the struct layout, should be 0. +*/ +uint32_t version;
Why version number? Across DPDK, we are using dynamic function versioning, I think, that would
be sufficient for ABI versioning
Quoted 23 lines
lib/ethdev/rte_flow.h +23
-0+/** +* Number of counter actions pre-configured. +* If set to 0, PMD will allocate counters dynamically. +* @see RTE_FLOW_ACTION_TYPE_COUNT +*/ +uint32_t nb_counters; +/** +* Number of aging actions pre-configured. +* If set to 0, PMD will allocate aging dynamically. +* @see RTE_FLOW_ACTION_TYPE_AGE +*/ +uint32_t nb_aging; +/** +* Number of traffic metering actions pre-configured. +* If set to 0, PMD will allocate meters dynamically. +* @see RTE_FLOW_ACTION_TYPE_METER +*/ +uint32_t nb_meters; +}; + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice.
lib/ethdev/rte_flow.h rte_flow_flex_item_release(uint16_t port_id, · line 4900
Quoted 10 lines
lib/ethdev/rte_flow.h +10
-0+* +* Configure flow rules module. +* To pre-allocate resources as per the flow port attributes +* this configuration function must be called before any flow rule is created. +* Must be called only after Ethernet device is configured, but may be called +* before or after the device is started as long as there are no flow rules. +* No other rte_flow function should be called while this function is invoked. +* This function can be called again to change the configuration. +* Some PMDs may not support re-configuration at all, +* or may only allow increasing the number of resources allocated.
Following comment from Ivan looks good to me
* Pre-configure the port's flow API engine.
*
* This API can only be invoked before the application
* starts using the rest of the flow library functions. *
* The API can be invoked multiple times to change the
* settings. The port, however, may reject the changes.
Quoted 12 lines
+ *
+ * @paramport_id
+ * Port identifier of Ethernet device.
+ * @param[in]port_attr
+ * Port configuration attributes.
+ * @param[out] error
+ * Perform verbose error reporting if not NULL.
+ * PMDs initialize this structure in case of error only.
+ *
+ * @return
+ * 0 on success, a negative errno value otherwise andrte_errnois set.
+ */
lib/ethdev/rte_flow.h rte_flow_flex_item_release(uint16_t port_id, · line 4915
Quoted 3 lines
lib/ethdev/rte_flow.h +3
-0+__rte_experimental +int +rte_flow_configure(uint16_t port_id,
Should we couple, setting resource limit hint to configure function as if we add future items in
configuration, we may pain to manage all state. Instead how about, rte_flow_resource_reserve_hint_set()?
Review
Quoted 2 lines
(quoted diff) +2
-0+ const struct rte_flow_port_attr *port_attr, + struct rte_flow_error *error);
I think, we should have _get function to get those limit numbers otherwise, we can not write portable applications as the return value is kind of boolean now if
don't define exact values for rte_errno for reasons.
Quoted 37 lines
lib/ethdev/rte_flow.h +1
-0+ #ifdef __cplusplus }#endif lib/ethdev/rte_flow_driver.h +5
-0@@ -152,6 +152,11 @@ struct rte_flow_ops { (struct rte_eth_dev *dev, const struct rte_flow_item_flex_handle *handle, struct rte_flow_error *error); +/** See rte_flow_configure() */ +int (*configure) + (struct rte_eth_dev *dev, +const struct rte_flow_port_attr *port_attr, +struct rte_flow_error *err); };/** lib/ethdev/version.map +3
-1@@ -256,6 +256,9 @@ EXPERIMENTAL { rte_flow_flex_item_create; rte_flow_flex_item_release; rte_flow_pick_transfer_proxy; + + # added in 22.03 + rte_flow_configure; }; INTERNAL { --2.18.2
Re: [PATCH v2 01/10] ethdev: introduce flow pre-configuration hints
24/01/2022 15:36, Jerin Jacob:
Quoted 9 lines · Alexander Kozyrev
lib/ethdev/rte_flow.h rte_flow_flex_item_release(uint16_t port_id, · line 4867
Quoted 5 lines
lib/ethdev/rte_flow.h +5
-0+struct rte_flow_port_attr { +/** +* Version of the struct layout, should be 0. +*/ +uint32_t version;Why version number? Across DPDK, we are using dynamic function versioning, I think, that would be sufficient for ABI versioning
Function versioning is not ideal when the structure is accessed in many places like many drivers and library functions.
The idea of this version field (which can be a bitfield)
is to update it when some new features are added,
so the users of the struct can check if a feature is there before trying to use it.
It means a bit more code in the functions, but avoid duplicating functions as in function versioning.
Another approach was suggested by Bruce, and applied to dmadev. It is assuming we only add new fields at the end (no removal), and focus on the size of the struct.
By passing sizeof as an extra parameter, the function knows
which fields are OK to use.
Example: http://code.dpdk.org/dpdk/v21.11/source/lib/dmadev/rte_dmadev.c#L476
Re: [PATCH v2 01/10] ethdev: introduce flow pre-configuration hints
Quoted 22 lines · Thomas Monjalon
24/01/2022 15:36, Jerin Jacob:
Quoted 9 lines · Alexander Kozyrev
lib/ethdev/rte_flow.h rte_flow_flex_item_release(uint16_t port_id, · line 4867
Quoted 5 lines
lib/ethdev/rte_flow.h +5
-0+struct rte_flow_port_attr { +/** +* Version of the struct layout, should be 0. +*/ +uint32_t version;Why version number? Across DPDK, we are using dynamic function versioning, I think, that would be sufficient for ABI versioning
Function versioning is not ideal when the structure is accessed in many places like many drivers and library functions.
The idea of this version field (which can be a bitfield)
is to update it when some new features are added,
so the users of the struct can check if a feature is there before trying to use it.
It means a bit more code in the functions, but avoid duplicating functions as in function versioning.
Quoted 6 lines
Another approach was suggested by Bruce, and applied to dmadev. It is assuming we only add new fields at the end (no removal), and focus on the size of the struct.
By passing sizeof as an extra parameter, the function knows
which fields are OK to use.
Example: http://code.dpdk.org/dpdk/v21.11/source/lib/dmadev/rte_dmadev.c#L476
+ @Richardson, Bruce
Either approach is fine, No strong opinion. We can have one approach and use it across DPDK for consistency.
Quoted 2 lines
Re: [PATCH v2 01/10] ethdev: introduce flow pre-configuration hints
Quoted 30 lines · Jerin Jacob
Quoted 22 lines · Thomas Monjalon
24/01/2022 15:36, Jerin Jacob:
Quoted 9 lines · Alexander Kozyrev
lib/ethdev/rte_flow.h rte_flow_flex_item_release(uint16_t port_id, · line 4867
Quoted 5 lines
lib/ethdev/rte_flow.h +5
-0+struct rte_flow_port_attr { +/** +* Version of the struct layout, should be 0. +*/ +uint32_t version;Why version number? Across DPDK, we are using dynamic function versioning, I think, that would be sufficient for ABI versioning
Function versioning is not ideal when the structure is accessed in many places like many drivers and library functions.
The idea of this version field (which can be a bitfield)
is to update it when some new features are added,
so the users of the struct can check if a feature is there before trying to use it.
It means a bit more code in the functions, but avoid duplicating functions as in function versioning.Quoted 6 lines
Another approach was suggested by Bruce, and applied to dmadev. It is assuming we only add new fields at the end (no removal), and focus on the size of the struct.
By passing sizeof as an extra parameter, the function knows
which fields are OK to use.
Example: http://code.dpdk.org/dpdk/v21.11/source/lib/dmadev/rte_dmadev.c#L476
Quoted 4 lines
+ @Richardson, Bruce
Either approach is fine, No strong opinion. We can have one approach and use it across DPDK for consistency.
In general I prefer the size-based approach, mainly because of its simplicity. However, some other reasons why we may want to choose it:
* It's completely hidden from the end user, and there is no need for an extra struct field that needs to be filled in
* Related to that, for the version-field approach, if the field is present in a user-allocated struct, then you probably need to start preventing user error via:
- having the external struct not have the field and use a separate internal struct to add in the version info after the fact in the versioned function. Alternatively,
- provide a separate init function for each structure to fill in the version field appropriately
* In general, using the size-based approach like in the linked example is more resilient since it's compiler-inserted, so there is reduced chance of error.
* A sizeof field allows simple-enough handling in the drivers - especially since it does not allow removed fields. Each driver only needs to check that the size passed in is greater than that expected, thereby allowing us to have both updated and non-updated drivers co-existing simultaneously. [For a version field, the same scheme could also work if we keep the no-delete rule, but for a bitmask field, I believe things may get more complex in terms of checking]
In terms of the limitations of using sizeof - requiring new fields to always go on the end, and preventing shrinking the struct - I think that the simplicity gains far outweigh the impact of these strictions.
* Adding fields to struct is far more common than wanting to remove one
* So long as the added field is at the end, even if the struct size doesn't change the scheme can still work as the versioned function for the old struct can ensure that the extra field is appropriately zeroed (rather than random) on entry into any driver function
* If we do want to remove a field, the space simply needs to be marked as reserved in the struct, until the next ABI break release, when it can be compacted. Again, function versioning can take care of appropriately zeroing this field on return, if necessary.
My 2c from considering this for the implementation in dmadev. :-)
/Bruce
RE: [PATCH v2 01/10] ethdev: introduce flow pre-configuration hints
Quoted 78 lines · On Monday, January 24, 2022 13:09 Bruce Richardson…
Quoted 1 line · Jerin Jacob
On Mon, Jan 24, 2022 at 11:05 PM Thomas Monjalon
Quoted 3 lines · <[email protected]> wrote:
Quoted 3 lines
24/01/2022 15:36, Jerin Jacob:
Quoted 1 line
On Tue, Jan 18, 2022 at 9:01 PM Alexander Kozyrev
Quoted 19 lines · <[email protected]> wrote:
Quoted 19 lines
Quoted 8 lines
lib/ethdev/rte_flow.h rte_flow_flex_item_release(uint16_t port_id, · line 4867
Quoted 5 lines
lib/ethdev/rte_flow.h +5
-0+struct rte_flow_port_attr { +/** +* Version of the struct layout, should be 0. +*/ +uint32_t version;Why version number? Across DPDK, we are using dynamic function versioning, I think, that would be sufficient for ABI versioning
Function versioning is not ideal when the structure is accessed in many places like many drivers and library functions.
The idea of this version field (which can be a bitfield)
is to update it when some new features are added,
so the users of the struct can check if a feature is there before trying to use it.
It means a bit more code in the functions, but avoid duplicating functions as in function versioning.Quoted 6 lines
Quoted 6 lines
Another approach was suggested by Bruce, and applied to dmadev. It is assuming we only add new fields at the end (no removal), and focus on the size of the struct.
By passing sizeof as an extra parameter, the function knows which fields are OK to use.
Example:http://code.dpdk.org/dpdk/v21.11/source/lib/dmadev/rte_dmadev.c#L476
Quoted 5 lines
+ @Richardson, Bruce
Either approach is fine, No strong opinion. We can have one approach and use it across DPDK for consistency.In general I prefer the size-based approach, mainly because of its simplicity. However, some other reasons why we may want to choose it:
* It's completely hidden from the end user, and there is no need for an extra struct field that needs to be filled in
* Related to that, for the version-field approach, if the field is present in a user-allocated struct, then you probably need to start preventing user error via:
- having the external struct not have the field and use a separate internal struct to add in the version info after the fact in the versioned function. Alternatively,
- provide a separate init function for each structure to fill in the version field appropriately* In general, using the size-based approach like in the linked example is more resilient since it's compiler-inserted, so there is reduced chance of error.
* A sizeof field allows simple-enough handling in the drivers - especially since it does not allow removed fields. Each driver only needs to check that the size passed in is greater than that expected, thereby allowing us to have both updated and non-updated drivers co-existing
simultaneously.
[For a version field, the same scheme could also work if we keep the no-delete rule, but for a bitmask field, I believe things may get more complex in terms of checking]In terms of the limitations of using sizeof - requiring new fields to always go on the end, and preventing shrinking the struct - I think that the simplicity gains far outweigh the impact of these strictions.
* Adding fields to struct is far more common than wanting to remove one
* So long as the added field is at the end, even if the struct size doesn't change the scheme can still work as the versioned function for the old struct can ensure that the extra field is appropriately zeroed (rather than random) on entry into any driver function
Quoted 8 lines
* If we do want to remove a field, the space simply needs to be marked as reserved in the struct, until the next ABI break release, when it can be compacted. Again, function versioning can take care of appropriately zeroing this field on return, if necessary.
My 2c from considering this for the implementation in dmadev. :-)
/Bruce
Thank you for the suggestions. I have no objections in adopting a size-based approach. I can keep versions or switch to sizeof as long as we can agree on some uniform way.
RE: [PATCH v2 01/10] ethdev: introduce flow pre-configuration hints
In reply to Bruce RichardsonHi Bruce,
Quoted 72 lines
-----Original Message-----
From: Bruce Richardson <[email protected]>
Sent: Monday, January 24, 2022 8:09 PM
Subject: Re: [PATCH v2 01/10] ethdev: introduce flow pre-configuration hintsQuoted 30 lines · Jerin Jacob
Quoted 22 lines · Thomas Monjalon
24/01/2022 15:36, Jerin Jacob:
Quoted 9 lines · Alexander Kozyrev
lib/ethdev/rte_flow.h rte_flow_flex_item_release(uint16_t port_id, · line 4867
Quoted 5 lines
lib/ethdev/rte_flow.h +5
-0+struct rte_flow_port_attr { +/** +* Version of the struct layout, should be 0. +*/ +uint32_t version;Why version number? Across DPDK, we are using dynamic function versioning, I think, that would be sufficient for ABI versioning
Function versioning is not ideal when the structure is accessed in many places like many drivers and library functions.
The idea of this version field (which can be a bitfield)
is to update it when some new features are added,
so the users of the struct can check if a feature is there before trying to use it.
It means a bit more code in the functions, but avoid duplicating functions as in function versioning.Quoted 6 lines
Another approach was suggested by Bruce, and applied to dmadev. It is assuming we only add new fields at the end (no removal), and focus on the size of the struct.
By passing sizeof as an extra parameter, the function knows
which fields are OK to use.
Example: http://code.dpdk.org/dpdk/v21.11/source/lib/dmadev/rte_dmadev.c#L476Quoted 4 lines
+ @Richardson, Bruce
Either approach is fine, No strong opinion. We can have one approach and use it across DPDK for consistency.In general I prefer the size-based approach, mainly because of its simplicity. However, some other reasons why we may want to choose it:
* It's completely hidden from the end user, and there is no need for an extra struct field that needs to be filled in
* Related to that, for the version-field approach, if the field is present in a user-allocated struct, then you probably need to start preventing user error via:
- having the external struct not have the field and use a separate internal struct to add in the version info after the fact in the versioned function. Alternatively,
- provide a separate init function for each structure to fill in the version field appropriately* In general, using the size-based approach like in the linked example is more resilient since it's compiler-inserted, so there is reduced chance of error.
* A sizeof field allows simple-enough handling in the drivers - especially since it does not allow removed fields. Each driver only needs to check that the size passed in is greater than that expected, thereby allowing us to have both updated and non-updated drivers co-existing simultaneously. [For a version field, the same scheme could also work if we keep the no-delete rule, but for a bitmask field, I believe things may get more complex in terms of checking]
In terms of the limitations of using sizeof - requiring new fields to always go on the end, and preventing shrinking the struct - I think that the simplicity gains far outweigh the impact of these strictions.
Quoted 7 lines
* Adding fields to struct is far more common than wanting to remove one
* So long as the added field is at the end, even if the struct size doesn't change the scheme can still work as the versioned function for the old struct can ensure that the extra field is appropriately zeroed (rather than random) on entry into any driver function
Zero can be a valid value so this is may result in an issue.
Quoted 5 lines
* If we do want to remove a field, the space simply needs to be marked as reserved in the struct, until the next ABI break release, when it can be compacted. Again, function versioning can take care of appropriately zeroing this field on return, if necessary.
This means that PMD will have to change just for removal of a field I would say removal is not allowed.
Quoted 1 line
My 2c from considering this for the implementation in dmadev. :-)
Some concerns I have about your suggestion:
1. The size of the struct is dependent on the system, for example
Assume this struct
{Uint16_t a;Uint32_t b;Uint8_t c;Uint32_t d;
}
Incase of 32 bit machine the size will be 128 bytes, while in 64 machine it will be 96
2. ABI breakage, as far as I know changing size of a struct is ABI breakage, since if the application got the size from previous version and for example created array or allocated memory then using the new structure will result in memory override.
I know that flags/version is not easy since it means creating new
Structure for each change. I prefer to declare that size can change between
DPDK releases is allowd but as long as we say ABI breakage is forbidden then I don't think your solution is valid.
And we must go with the version/flags and create new structure for each change.
Best,
Ori
Quoted 2 lines
/Bruce
Re: [PATCH v2 01/10] ethdev: introduce flow pre-configuration hints
Quoted 76 lines · Ori Kam
Hi Bruce,
Quoted 74 lines
-----Original Message-----
From: Bruce Richardson <[email protected]>
Sent: Monday, January 24, 2022 8:09 PM
Subject: Re: [PATCH v2 01/10] ethdev: introduce flow pre-configuration hintsQuoted 30 lines · Jerin Jacob
Quoted 22 lines · Thomas Monjalon
24/01/2022 15:36, Jerin Jacob:
Quoted 9 lines · Alexander Kozyrev
lib/ethdev/rte_flow.h rte_flow_flex_item_release(uint16_t port_id, · line 4867
Quoted 5 lines
lib/ethdev/rte_flow.h +5
-0+struct rte_flow_port_attr { +/** +* Version of the struct layout, should be 0. +*/ +uint32_t version;Why version number? Across DPDK, we are using dynamic function versioning, I think, that would be sufficient for ABI versioning
Function versioning is not ideal when the structure is accessed in many places like many drivers and library functions.
The idea of this version field (which can be a bitfield)
is to update it when some new features are added,
so the users of the struct can check if a feature is there before trying to use it.
It means a bit more code in the functions, but avoid duplicating functions as in function versioning.Quoted 6 lines
Another approach was suggested by Bruce, and applied to dmadev. It is assuming we only add new fields at the end (no removal), and focus on the size of the struct.
By passing sizeof as an extra parameter, the function knows
which fields are OK to use.
Example: http://code.dpdk.org/dpdk/v21.11/source/lib/dmadev/rte_dmadev.c#L476Quoted 4 lines
+ @Richardson, Bruce
Either approach is fine, No strong opinion. We can have one approach and use it across DPDK for consistency.In general I prefer the size-based approach, mainly because of its simplicity. However, some other reasons why we may want to choose it:
* It's completely hidden from the end user, and there is no need for an extra struct field that needs to be filled in
* Related to that, for the version-field approach, if the field is present in a user-allocated struct, then you probably need to start preventing user error via:
- having the external struct not have the field and use a separate internal struct to add in the version info after the fact in the versioned function. Alternatively,
- provide a separate init function for each structure to fill in the version field appropriately* In general, using the size-based approach like in the linked example is more resilient since it's compiler-inserted, so there is reduced chance of error.
* A sizeof field allows simple-enough handling in the drivers - especially since it does not allow removed fields. Each driver only needs to check that the size passed in is greater than that expected, thereby allowing us to have both updated and non-updated drivers co-existing simultaneously. [For a version field, the same scheme could also work if we keep the no-delete rule, but for a bitmask field, I believe things may get more complex in terms of checking]
In terms of the limitations of using sizeof - requiring new fields to always go on the end, and preventing shrinking the struct - I think that the simplicity gains far outweigh the impact of these strictions.
* Adding fields to struct is far more common than wanting to remove one
Quoted 8 lines
Quoted 5 lines
* So long as the added field is at the end, even if the struct size doesn't change the scheme can still work as the versioned function for the old struct can ensure that the extra field is appropriately zeroed (rather than random) on entry into any driver function
Zero can be a valid value so this is may result in an issue.
In this instance, I was using zero as a neutral, default-option value. If having zero as the default causes problems, we can always make the structure size change to force a new size value.
Quoted 11 lines
Quoted 5 lines
* If we do want to remove a field, the space simply needs to be marked as reserved in the struct, until the next ABI break release, when it can be compacted. Again, function versioning can take care of appropriately zeroing this field on return, if necessary.
This means that PMD will have to change just for removal of a field I would say removal is not allowed.
Quoted 1 line
My 2c from considering this for the implementation in dmadev. :-)
Quoted 10 lines
Some concerns I have about your suggestion:
1. The size of the struct is dependent on the system, for example
Assume this struct
{Uint16_ta;Uint32_tb;Uint8_tc;Uint32_td;
}
Incase of 32 bit machine the size will be 128 bytes, while in 64 machine it will be 96
Actually, I believe that in just about every system we support it will be 4x4B i.e. 16 bytes in size. How do you compute 96 or 128 byte sizes? In any case, the actual size value doesn't matter in practice, since all sizes should be computed by the compiler using sizeof, rather than hard-coded.
Quoted 11 lines
2. ABI breakage, as far as I know changing size of a struct is ABI breakage, since if the application got the size from previous version and for example created array or allocated memory then using the new structure will result in memory override.
I know that flags/version is not easy since it means creating new
Structure for each change. I prefer to declare that size can change between
DPDK releases is allowd but as long as we say ABI breakage is forbidden then I don't think your solution is valid.
And we must go with the version/flags and create new structure for each change.
whatever approach is taken for this, I believe we will always need to create a new structure for the changes. This is because only functions can be versioned, not structures. The only question therefore becomes how to pass ABI version information, and therefore by extension structure version information across a library to driver boundary. This has to be an extra field somewhere, either in a structure or as a function parameter. I'd prefer not in the structure as it exposes it to the user. In terms of the field value, it can either be explicit version info as version number or version flags, or implicit versioning via "size". Based off the "YAGNI" principle, I really would prefer just using sizes, as it's far easier to manage and work with for all concerned, and requires no additional documentation for the programmer or driver developer to understand.
Regards,
/Bruce
Re: [PATCH v2 01/10] ethdev: introduce flow pre-configuration hints
Quoted 125 lines · Bruce Richardson
Quoted 76 lines · Ori Kam
Hi Bruce,
Quoted 74 lines
-----Original Message----- From: Bruce Richardson <[email protected]> Sent: Monday, January 24, 2022 8:09 PM
Subject: Re: [PATCH v2 01/10] ethdev: introduce flow pre-configuration hintsQuoted 30 lines · Jerin Jacob
Quoted 21 lines · Thomas Monjalon
24/01/2022 15:36, Jerin Jacob:
Quoted 9 lines
Quoted 3 lines · Alexander Kozyrev
+struct
rte_flow_port_attr{ + /** + * Version
of the struct layout, should be 0. + */ +uint32_tversion;Why version number? Across DPDK, we are using dynamic function versioning, I think, that would be sufficient for ABI versioning
Function versioning is not ideal when the structure is accessed in many places like many drivers and library functions.
The idea of this version field (which can be a bitfield) is to update it when some new features are added, so the users of the struct can check if a feature is there before trying to use it. It means a bit more code in the functions, but avoid duplicating functions as in function versioning.
Quoted 6 lines
Another approach was suggested by Bruce, and applied to dmadev. It is assuming we only add new fields at the end (no removal), and focus on the size of the struct. By passing sizeof as an extra parameter, the function knows which fields are OK to use. Example:
http://code.dpdk.org/dpdk/v21.11/source/lib/dmadev/rte_dmadev.c#L476Quoted 3 lines
+ @Richardson, Bruce Either approach is fine, No strong opinion. We can have one approach and use it across DPDK for consistency.
In general I prefer the size-based approach, mainly because of its simplicity. However, some other reasons why we may want to choose it:
* It's completely hidden from the end user, and there is no need for an extra struct field that needs to be filled in
* Related to that, for the version-field approach, if the field is present in a user-allocated struct, then you probably need to start preventing user error via: - having the external struct not have the field and use a separate internal struct to add in the version info after the fact in the versioned function. Alternatively, - provide a separate init function for each structure to fill in the version field appropriately
* In general, using the size-based approach like in the linked example is more resilient since it's compiler-inserted, so there is reduced chance of error.
* A sizeof field allows simple-enough handling in the drivers - especially since it does not allow removed fields. Each driver only needs to check that the size passed in is greater than that expected, thereby allowing us to have both updated and non-updated drivers co-existing simultaneously. [For a version field, the same scheme could also work if we keep the no-delete rule, but for a bitmask field, I believe things may get more complex in terms of checking]
In terms of the limitations of using sizeof - requiring new fields to always go on the end, and preventing shrinking the struct - I think that the simplicity gains far outweigh the impact of these strictions.
* Adding fields to struct is far more common than wanting to remove one
Quoted 8 lines
Quoted 5 lines
* So long as the added field is at the end, even if the struct size doesn't change the scheme can still work as the versioned function for the old struct can ensure that the extra field is appropriately zeroed (rather than random) on entry into any driver function
Zero can be a valid value so this is may result in an issue.
In this instance, I was using zero as a neutral, default-option value. If having zero as the default causes problems, we can always make the structure size change to force a new size value.
Quoted 9 lines
Quoted 5 lines
* If we do want to remove a field, the space simply needs to be marked as reserved in the struct, until the next ABI break release, when it can be compacted. Again, function versioning can take care of appropriately zeroing this field on return, if necessary.
This means that PMD will have to change just for removal of a field I would say removal is not allowed.
Quoted 6 lines
Quoted 1 line
My 2c from considering this for the implementation in dmadev. :-)
Some concerns I have about your suggestion: 1. The size of the struct is dependent on the system, for example Assume this struct {
Uint16_ta;Uint32_tb;Uint8_tc;Uint32_td; } Incase of 32 bit machine the size will be 128 bytes, while in 64 machine it will be 96Actually, I believe that in just about every system we support it will be 4x4B i.e. 16 bytes in size. How do you compute 96 or 128 byte sizes? In any case, the actual size value doesn't matter in practice, since all sizes should be computed by the compiler using sizeof, rather than hard-coded.
Quoted 6 lines
2. ABI breakage, as far as I know changing size of a struct is ABI breakage, since if the application got the size from previous version and for example created array or allocated memory then using the new structure will result in memory override.
Quoted 6 lines
I know that flags/version is not easy since it means creating new Structure for each change. I prefer to declare that size can change between DPDK releases is allowd but as long as we say ABI breakage is forbidden then I don't think your solution is valid. And we must go with the version/flags and create new structure for each change.
Quoted 14 lines
whatever approach is taken for this, I believe we will always need to create a new structure for the changes. This is because only functions can be versioned, not structures. The only question therefore becomes how to pass ABI version information, and therefore by extension structure version information across a library to driver boundary. This has to be an extra field somewhere, either in a structure or as a function parameter. I'd prefer not in the structure as it exposes it to the user. In terms of the field value, it can either be explicit version info as version number or version flags, or implicit versioning via "size". Based off the "YAGNI" principle, I really would prefer just using sizes, as it's far easier to manage and work with for all concerned, and requires no additional documentation for the programmer or driver developer to understand.
As a third alternative that I would find acceptable, we could also just take the approach of passing the ABI version explicitly across the function call i.e. 22 for DPDK_21.11. I'd find this ok too on the basis that it's largely self explanatory, and can be inserted automatically by the compiler
- again reducing chances of errors. [However, I also believe that using sizes is still simpler again, which is why it's still my first choice! :-)]
/Bruce
RE: [PATCH v2 01/10] ethdev: introduce flow pre-configuration hints
Quoted 121 lines
-----Original Message-----
From: Bruce Richardson <[email protected]>
Sent: Tuesday, January 25, 2022 8:14 PM
To: Ori Kam <[email protected]>
Subject: Re: [PATCH v2 01/10] ethdev: introduce flow pre-configuration hintsQuoted 112 lines · Bruce Richardson
Quoted 76 lines · Ori Kam
Hi Bruce,
Quoted 74 lines
-----Original Message----- From: Bruce Richardson <[email protected]> Sent: Monday, January 24, 2022 8:09 PM
Subject: Re: [PATCH v2 01/10] ethdev: introduce flow pre-configuration hintsQuoted 30 lines · Jerin Jacob
Quoted 21 lines · Thomas Monjalon
24/01/2022 15:36, Jerin Jacob:
Quoted 9 lines
Quoted 3 lines · Alexander Kozyrev
+struct
rte_flow_port_attr{ + /** + * Version
of the struct layout, should be 0. + */ +uint32_tversion;Why version number? Across DPDK, we are using dynamic function versioning, I think, that would be sufficient for ABI versioning
Function versioning is not ideal when the structure is accessed in many places like many drivers and library functions.
The idea of this version field (which can be a bitfield) is to update it when some new features are added, so the users of the struct can check if a feature is there before trying to use it. It means a bit more code in the functions, but avoid duplicating functions as in function versioning.
Quoted 6 lines
Another approach was suggested by Bruce, and applied to dmadev. It is assuming we only add new fields at the end (no removal), and focus on the size of the struct. By passing sizeof as an extra parameter, the function knows which fields are OK to use. Example:
http://code.dpdk.org/dpdk/v21.11/source/lib/dmadev/rte_dmadev.c#L476Quoted 3 lines
+ @Richardson, Bruce Either approach is fine, No strong opinion. We can have one approach and use it across DPDK for consistency.
In general I prefer the size-based approach, mainly because of its simplicity. However, some other reasons why we may want to choose it:
* It's completely hidden from the end user, and there is no need for an extra struct field that needs to be filled in
* Related to that, for the version-field approach, if the field is present in a user-allocated struct, then you probably need to start preventing user error via: - having the external struct not have the field and use a separate internal struct to add in the version info after the fact in the versioned function. Alternatively, - provide a separate init function for each structure to fill in the version field appropriately
* In general, using the size-based approach like in the linked example is more resilient since it's compiler-inserted, so there is reduced chance of error.
* A sizeof field allows simple-enough handling in the drivers - especially since it does not allow removed fields. Each driver only needs to check that the size passed in is greater than that expected, thereby allowing us to have both updated and non-updated drivers co-existing simultaneously. [For a version field, the same scheme could also work if we keep the no-delete rule, but for a bitmask field, I believe things may get more complex in terms of checking]
In terms of the limitations of using sizeof - requiring new fields to always go on the end, and preventing shrinking the struct - I think that the simplicity gains far outweigh the impact of these strictions.
* Adding fields to struct is far more common than wanting to remove one
Quoted 8 lines
Quoted 5 lines
* So long as the added field is at the end, even if the struct size doesn't change the scheme can still work as the versioned function for the old struct can ensure that the extra field is appropriately zeroed (rather than random) on entry into any driver function
Zero can be a valid value so this is may result in an issue.
In this instance, I was using zero as a neutral, default-option value. If having zero as the default causes problems, we can always make the structure size change to force a new size value.
Quoted 9 lines
Quoted 5 lines
* If we do want to remove a field, the space simply needs to be marked as reserved in the struct, until the next ABI break release, when it can be compacted. Again, function versioning can take care of appropriately zeroing this field on return, if necessary.
This means that PMD will have to change just for removal of a field I would say removal is not allowed.
Quoted 6 lines
Quoted 1 line
My 2c from considering this for the implementation in dmadev. :-)
Some concerns I have about your suggestion: 1. The size of the struct is dependent on the system, for example Assume this struct {
Uint16_ta;Uint32_tb;Uint8_tc;Uint32_td; } Incase of 32 bit machine the size will be 128 bytes, while in 64 machine it will be 96Actually, I believe that in just about every system we support it will be 4x4B i.e. 16 bytes in size. How do you compute 96 or 128 byte sizes? In any case, the actual size value doesn't matter in practice, since all sizes should be computed by the compiler using sizeof, rather than hard-coded.
You are correct my mistake with the numbers.
I still think there might be some issue but I can't think of anything. So dropping it.
Quoted 27 lines
Quoted 13 lines
Quoted 6 lines
2. ABI breakage, as far as I know changing size of a struct is ABI breakage, since if the application got the size from previous version and for example created array or allocated memory then using the new structure will result in memory override.
Quoted 6 lines
I know that flags/version is not easy since it means creating new Structure for each change. I prefer to declare that size can change between DPDK releases is allowd but as long as we say ABI breakage is forbidden then I don't think your solution is valid. And we must go with the version/flags and create new structure for each change.
Quoted 14 lines
whatever approach is taken for this, I believe we will always need to create a new structure for the changes. This is because only functions can be versioned, not structures. The only question therefore becomes how to pass ABI version information, and therefore by extension structure version information across a library to driver boundary. This has to be an extra field somewhere, either in a structure or as a function parameter. I'd prefer not in the structure as it exposes it to the user. In terms of the field value, it can either be explicit version info as version number or version flags, or implicit versioning via "size". Based off the "YAGNI" principle, I really would prefer just using sizes, as it's far easier to manage and work with for all concerned, and requires no additional documentation for the programmer or driver developer to understand.
Quoted 7 lines
As a third alternative that I would find acceptable, we could also just take the approach of passing the ABI version explicitly across the function call i.e. 22 for DPDK_21.11. I'd find this ok too on the basis that it's largely self explanatory, and can be inserted automatically by the compiler
- again reducing chances of errors. [However, I also believe that using sizes is still simpler again, which is why it's still my first choice! :-)]
Just to make sure I fully understand your suggestion. We will create new struct for each change. The function will stay the same
For example I had the following:
Struct base {
Uint32_t x;
}
Function (struct base *input)
{
Inner_func (input, sizeof(struct base))
}
Now I'm adding new member so it will look like this:
Struct new {
Uint32_t x;Uint32_t y;
}
When I want to call the function I need to castFunction((struct base*) new)
Right?
This means that in both cases the sizeof wil return the same value, What am I missing?
Quoted 1 line
/Bruce
Re: [PATCH v2 01/10] ethdev: introduce flow pre-configuration hints
Quoted 180 lines · Ori Kam
Quoted 121 lines
-----Original Message-----
From: Bruce Richardson <[email protected]>
Sent: Tuesday, January 25, 2022 8:14 PM
To: Ori Kam <[email protected]>
Subject: Re: [PATCH v2 01/10] ethdev: introduce flow pre-configuration hintsQuoted 112 lines · Bruce Richardson
Quoted 76 lines · Ori Kam
Hi Bruce,
Quoted 74 lines
-----Original Message----- From: Bruce Richardson <[email protected]> Sent: Monday, January 24, 2022 8:09 PM
Subject: Re: [PATCH v2 01/10] ethdev: introduce flow pre-configuration hintsQuoted 30 lines · Jerin Jacob
Quoted 21 lines · Thomas Monjalon
24/01/2022 15:36, Jerin Jacob:
Quoted 9 lines
Quoted 3 lines · Alexander Kozyrev
+struct
rte_flow_port_attr{ + /** + * Version
of the struct layout, should be 0. + */ +uint32_tversion;Why version number? Across DPDK, we are using dynamic function versioning, I think, that would be sufficient for ABI versioning
Function versioning is not ideal when the structure is accessed in many places like many drivers and library functions.
The idea of this version field (which can be a bitfield) is to update it when some new features are added, so the users of the struct can check if a feature is there before trying to use it. It means a bit more code in the functions, but avoid duplicating functions as in function versioning.
Quoted 6 lines
Another approach was suggested by Bruce, and applied to dmadev. It is assuming we only add new fields at the end (no removal), and focus on the size of the struct. By passing sizeof as an extra parameter, the function knows which fields are OK to use. Example:
http://code.dpdk.org/dpdk/v21.11/source/lib/dmadev/rte_dmadev.c#L476Quoted 3 lines
+ @Richardson, Bruce Either approach is fine, No strong opinion. We can have one approach and use it across DPDK for consistency.
In general I prefer the size-based approach, mainly because of its simplicity. However, some other reasons why we may want to choose it:
* It's completely hidden from the end user, and there is no need for an extra struct field that needs to be filled in
* Related to that, for the version-field approach, if the field is present in a user-allocated struct, then you probably need to start preventing user error via: - having the external struct not have the field and use a separate internal struct to add in the version info after the fact in the versioned function. Alternatively, - provide a separate init function for each structure to fill in the version field appropriately
* In general, using the size-based approach like in the linked example is more resilient since it's compiler-inserted, so there is reduced chance of error.
* A sizeof field allows simple-enough handling in the drivers - especially since it does not allow removed fields. Each driver only needs to check that the size passed in is greater than that expected, thereby allowing us to have both updated and non-updated drivers co-existing simultaneously. [For a version field, the same scheme could also work if we keep the no-delete rule, but for a bitmask field, I believe things may get more complex in terms of checking]
In terms of the limitations of using sizeof - requiring new fields to always go on the end, and preventing shrinking the struct - I think that the simplicity gains far outweigh the impact of these strictions.
* Adding fields to struct is far more common than wanting to remove one
Quoted 8 lines
Quoted 5 lines
* So long as the added field is at the end, even if the struct size doesn't change the scheme can still work as the versioned function for the old struct can ensure that the extra field is appropriately zeroed (rather than random) on entry into any driver function
Zero can be a valid value so this is may result in an issue.
In this instance, I was using zero as a neutral, default-option value. If having zero as the default causes problems, we can always make the structure size change to force a new size value.
Quoted 9 lines
Quoted 5 lines
* If we do want to remove a field, the space simply needs to be marked as reserved in the struct, until the next ABI break release, when it can be compacted. Again, function versioning can take care of appropriately zeroing this field on return, if necessary.
This means that PMD will have to change just for removal of a field I would say removal is not allowed.
Quoted 6 lines
Quoted 1 line
My 2c from considering this for the implementation in dmadev. :-)
Some concerns I have about your suggestion: 1. The size of the struct is dependent on the system, for example Assume this struct {
Uint16_ta;Uint32_tb;Uint8_tc;Uint32_td; } Incase of 32 bit machine the size will be 128 bytes, while in 64 machine it will be 96Actually, I believe that in just about every system we support it will be 4x4B i.e. 16 bytes in size. How do you compute 96 or 128 byte sizes? In any case, the actual size value doesn't matter in practice, since all sizes should be computed by the compiler using sizeof, rather than hard-coded.
You are correct my mistake with the numbers.
I still think there might be some issue but I can't think of anything. So dropping it.Quoted 27 lines
Quoted 13 lines
Quoted 6 lines
2. ABI breakage, as far as I know changing size of a struct is ABI breakage, since if the application got the size from previous version and for example created array or allocated memory then using the new structure will result in memory override.
Quoted 6 lines
I know that flags/version is not easy since it means creating new Structure for each change. I prefer to declare that size can change between DPDK releases is allowd but as long as we say ABI breakage is forbidden then I don't think your solution is valid. And we must go with the version/flags and create new structure for each change.
Quoted 14 lines
whatever approach is taken for this, I believe we will always need to create a new structure for the changes. This is because only functions can be versioned, not structures. The only question therefore becomes how to pass ABI version information, and therefore by extension structure version information across a library to driver boundary. This has to be an extra field somewhere, either in a structure or as a function parameter. I'd prefer not in the structure as it exposes it to the user. In terms of the field value, it can either be explicit version info as version number or version flags, or implicit versioning via "size". Based off the "YAGNI" principle, I really would prefer just using sizes, as it's far easier to manage and work with for all concerned, and requires no additional documentation for the programmer or driver developer to understand.
Quoted 7 lines
As a third alternative that I would find acceptable, we could also just take the approach of passing the ABI version explicitly across the function call i.e. 22 for DPDK_21.11. I'd find this ok too on the basis that it's largely self explanatory, and can be inserted automatically by the compiler
- again reducing chances of errors. [However, I also believe that using sizes is still simpler again, which is why it's still my first choice! :-)]Just to make sure I fully understand your suggestion. We will create new struct for each change. The function will stay the same
For example I had the following:Struct base {
Uint32_tx;
}Function (struct base *input)
{
Inner_func(input, sizeof(struct base))
}Now I'm adding new member so it will look like this:
Struct new {
Uint32_tx;Uint32_ty;
}
Quoted 8 lines
When I want to call the function I need to cast
Function((struct base*) new)Right?
This means that in both cases the sizeof wil return the same value, What am I missing?
The scenario is as follows. Suppose we have the initial state as below:
struct x_dev_cfg {
int x;
};
intx_dev_cfg(int dev_id, struct x_dev_cfg *cfg)
{
struct x_dev *dev = x_devs[id];
// some setup/config may go here
return dev->configure(cfg, sizeof(cfg)); // sizeof(cfg) == 4
}
Now, supposing we need to add in a new field into the config structure, a very common occurance. This will indeed break the ABI, so we need to use ABI versioning, to ensure that apps passing in the old structure, only call a function which expects the old structure. Therefore, we need a copy of the old structure, and a function to work on it. This gives this result:
struct x_dev_cfg {
int x;
bool flag; // new field;
};struct x_dev_cfg_v22 { // needed for ABI-versioned function
int x; };
/* this function will only be called by *newly-linked* code, which uses
* the new structure */
intx_dev_cfg(int dev_id, struct x_dev_cfg *cfg)
{
struct x_dev *dev = x_devs[id];
// some setup/config may go here
return dev->configure(cfg, sizeof(cfg)); // sizeof(cfg) is now 8
}
/* this function is called by apps linked against old version */ intx_dev_cfg_v22(int dev_id, struct x_dev_cfg_v22 *cfg)
{
struct x_dev *dev = x_devs[id];
// some setup/config may go here
return dev->configure((void *)cfg, sizeof(cfg)); // sizeof(cfg) is still 4
}
With the above library code, we have different functions using the different structures, so ABI compatibility is preserved - apps passing in a 4-byte struct call a function using the 4-byte struct, while newer apps can use the 8-byte version.
The final part of the puzzle is then how drivers react to this change. Originally, all drivers only use "x" in the config structure because that is all that there is. That will still continue to work fine in the above case, as both 4-byte and 8-byte structs have the same x value at the same offset. i.e. no driver updates for x_dev is needed.
On the other hand, if there are drivers that do want/need the new field, they can also get to use it, but they do need to check for its presence before they do so, i.e they would work as below:
if (size_param > struct(x_dev_cfg_v22)) { // or "== struct(x_dev_cfg)"
// use flags field
}Hope this is clear now.
/Bruce
Re: [PATCH v2 01/10] ethdev: introduce flow pre-configuration hints
26/01/2022 11:52, Bruce Richardson:
Quoted 63 lines
The scenario is as follows. Suppose we have the initial state as below:
struct x_dev_cfg { int x; };int
x_dev_cfg(int dev_id, struct x_dev_cfg *cfg){ struct x_dev *dev = x_devs[id]; // some setup/config may go here return dev->configure(cfg, sizeof(cfg)); // sizeof(cfg) == 4 }Now, supposing we need to add in a new field into the config structure, a very common occurance. This will indeed break the ABI, so we need to use ABI versioning, to ensure that apps passing in the old structure, only call a function which expects the old structure. Therefore, we need a copy of the old structure, and a function to work on it. This gives this result:
struct x_dev_cfg { int x; bool flag; // new field; };struct
x_dev_cfg_v22{ // needed for ABI-versioned functionint x; };/* this function will only be called by *newly-linked* code, which uses
* the new structure */
intx_dev_cfg(int dev_id, struct x_dev_cfg *cfg){ struct x_dev *dev = x_devs[id]; // some setup/config may go here return dev->configure(cfg, sizeof(cfg)); // sizeof(cfg) is now 8 }/* this function is called by apps linked against old version */ int
x_dev_cfg_v22(int dev_id, struct x_dev_cfg_v22 *cfg){ struct x_dev *dev = x_devs[id]; // some setup/config may go here return dev->configure((void *)cfg, sizeof(cfg)); // sizeof(cfg) is still 4 }With the above library code, we have different functions using the different structures, so ABI compatibility is preserved - apps passing in a 4-byte struct call a function using the 4-byte struct, while newer apps can use the 8-byte version.
The final part of the puzzle is then how drivers react to this change. Originally, all drivers only use "x" in the config structure because that is all that there is. That will still continue to work fine in the above case, as both 4-byte and 8-byte structs have the same x value at the same offset. i.e. no driver updates for
x_devis needed.On the other hand, if there are drivers that do want/need the new field, they can also get to use it, but they do need to check for its presence before they do so, i.e they would work as below:
Quoted 5 lines
if (size_param > struct(x_dev_cfg_v22)) { // or "== struct(x_dev_cfg)" // use flags field }Hope this is clear now.
Yes, this is the kind of explanation we need in our guideline doc. Alternatives can be documented as well.
If we can list pros/cons in the doc, it will be easier to choose the best approach and to explain the choice during code review.
RE: [PATCH v2 01/10] ethdev: introduce flow pre-configuration hints
Quoted 75 lines
-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Wednesday, January 26, 2022 1:22 PM
Subject: Re: [PATCH v2 01/10] ethdev: introduce flow pre-configuration hints26/01/2022 11:52, Bruce Richardson:
Quoted 67 lines
The scenario is as follows. Suppose we have the initial state as below:
struct x_dev_cfg { int x; };int
x_dev_cfg(int dev_id, struct x_dev_cfg *cfg){ struct x_dev *dev = x_devs[id]; // some setup/config may go here return dev->configure(cfg, sizeof(cfg)); // sizeof(cfg) == 4 }Now, supposing we need to add in a new field into the config structure, a very common occurance. This will indeed break the ABI, so we need to use ABI versioning, to ensure that apps passing in the old structure, only call a function which expects the old structure. Therefore, we need a copy of the old structure, and a function to work on it. This gives this result:
struct x_dev_cfg { int x; bool flag; // new field; };struct
x_dev_cfg_v22{ // needed for ABI-versioned functionint x; };/* this function will only be called by *newly-linked* code, which uses
* the new structure */
intx_dev_cfg(int dev_id, struct x_dev_cfg *cfg){ struct x_dev *dev = x_devs[id]; // some setup/config may go here return dev->configure(cfg, sizeof(cfg)); // sizeof(cfg) is now 8 }/* this function is called by apps linked against old version */ int
x_dev_cfg_v22(int dev_id, struct x_dev_cfg_v22 *cfg){ struct x_dev *dev = x_devs[id]; // some setup/config may go here return dev->configure((void *)cfg, sizeof(cfg)); // sizeof(cfg) is still 4 }With the above library code, we have different functions using the different structures, so ABI compatibility is preserved - apps passing in a 4-byte struct call a function using the 4-byte struct, while newer apps can use the 8-byte version.
The final part of the puzzle is then how drivers react to this change. Originally, all drivers only use "x" in the config structure because that is all that there is. That will still continue to work fine in the above case, as both 4-byte and 8-byte structs have the same x value at the same offset. i.e. no driver updates for
x_devis needed.On the other hand, if there are drivers that do want/need the new field, they can also get to use it, but they do need to check for its presence before they do so, i.e they would work as below:
if (size_param > struct(x_dev_cfg_v22)) { // or "== struct(x_dev_cfg)" // use flags field }
Quoted 8 lines
Quoted 1 line
Hope this is clear now.
Yes, this is the kind of explanation we need in our guideline doc. Alternatives can be documented as well.
If we can list pros/cons in the doc, it will be easier to choose the best approach and to explain the choice during code review.
Thanks you very much for the clear explanation.
The draw back is that we need also to duplicate the functions. Using the flags/version we only need to create new structures and from application point of view it knows what exta fields it gets. (I agree that application knowledge has downsides but also advantages)
In the case of flags/version your example will look like this (this is for the record and may other developers are intrested):
struct x_dev_cfg { //original struct
int ver; int x; };
struct x_dev_cfg_v2 { // new struct
int ver; int x; bool flag; // new field;
};
The function is always the same function:
x_dev_cfg(int dev_id, struct x_dev_cfg *cfg)
{
struct x_dev *dev = x_devs[id];
// some setup/config may go here
return dev->configure(cfg); }
When calling this function with old struct:X_dev_cfg(id, (struct x_dev_cfg *)cfg)
When calling this function with new struct:X_dev_cfg(id, (struct x_dev_cfg *)cfg_v2)
In PMD:
If (cfg->ver >= 2)
// version 2 logic Else If (cfg->v >=0) // base version logic
When using flags it gives even more control since pmd can tell exactly what features are required.
All options have prons/cons
I vote for the version one.
We can have a poll 😊
Or like Thomas said list pros and cons and each subsystem can have it own selection.
Re: [PATCH v2 01/10] ethdev: introduce flow pre-configuration hints
Quoted 129 lines · Ori Kam
Quoted 75 lines
-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Wednesday, January 26, 2022 1:22 PM
Subject: Re: [PATCH v2 01/10] ethdev: introduce flow pre-configuration hints26/01/2022 11:52, Bruce Richardson:
Quoted 67 lines
The scenario is as follows. Suppose we have the initial state as below:
struct x_dev_cfg { int x; };int
x_dev_cfg(int dev_id, struct x_dev_cfg *cfg){ struct x_dev *dev = x_devs[id]; // some setup/config may go here return dev->configure(cfg, sizeof(cfg)); // sizeof(cfg) == 4 }Now, supposing we need to add in a new field into the config structure, a very common occurance. This will indeed break the ABI, so we need to use ABI versioning, to ensure that apps passing in the old structure, only call a function which expects the old structure. Therefore, we need a copy of the old structure, and a function to work on it. This gives this result:
struct x_dev_cfg { int x; bool flag; // new field; };struct
x_dev_cfg_v22{ // needed for ABI-versioned functionint x; };/* this function will only be called by *newly-linked* code, which uses
* the new structure */
intx_dev_cfg(int dev_id, struct x_dev_cfg *cfg){ struct x_dev *dev = x_devs[id]; // some setup/config may go here return dev->configure(cfg, sizeof(cfg)); // sizeof(cfg) is now 8 }/* this function is called by apps linked against old version */ int
x_dev_cfg_v22(int dev_id, struct x_dev_cfg_v22 *cfg){ struct x_dev *dev = x_devs[id]; // some setup/config may go here return dev->configure((void *)cfg, sizeof(cfg)); // sizeof(cfg) is still 4 }With the above library code, we have different functions using the different structures, so ABI compatibility is preserved - apps passing in a 4-byte struct call a function using the 4-byte struct, while newer apps can use the 8-byte version.
The final part of the puzzle is then how drivers react to this change. Originally, all drivers only use "x" in the config structure because that is all that there is. That will still continue to work fine in the above case, as both 4-byte and 8-byte structs have the same x value at the same offset. i.e. no driver updates for
x_devis needed.On the other hand, if there are drivers that do want/need the new field, they can also get to use it, but they do need to check for its presence before they do so, i.e they would work as below:
if (size_param > struct(x_dev_cfg_v22)) { // or "== struct(x_dev_cfg)" // use flags field }Quoted 8 lines
Quoted 1 line
Hope this is clear now.
Yes, this is the kind of explanation we need in our guideline doc. Alternatives can be documented as well.
If we can list pros/cons in the doc, it will be easier to choose the best approach and to explain the choice during code review.Thanks you very much for the clear explanation.
The draw back is that we need also to duplicate the functions. Using the flags/version we only need to create new structures and from application point of view it knows what exta fields it gets. (I agree that application knowledge has downsides but also advantages)
In the case of flags/version your example will look like this (this is for the record and may other developers are intrested):
struct
x_dev_cfg{ //original structint ver; int x; };struct
x_dev_cfg_v2{ // new structint ver; int x; bool flag; // new field;};
The function is always the same function:
x_dev_cfg(int dev_id, struct x_dev_cfg *cfg){ struct x_dev *dev = x_devs[id]; // some setup/config may go here return dev->configure(cfg);}
When calling this function with old struct:
X_dev_cfg(id, (struct x_dev_cfg *)cfg)When calling this function with new struct:
X_dev_cfg(id, (struct x_dev_cfg *)cfg_v2)In PMD:
If (cfg->ver>= 2)// version 2 logic Else If (cfg->v >=0) // base version logicWhen using flags it gives even more control since pmd can tell exactly what features are required.
Quoted 6 lines
All options have prons/cons
I vote for the version one.We can have a poll 😊
Or like Thomas said list pros and cons and each subsystem can have it own selection.
The biggest issue I have with this version approach is how is the user meant to know what version number to put into the structure? When the user upgrades from one version of DPDK to the next, are they manually to update their version numbers in all their structures? If they don't, they then may be mistified if they use the newer fields and find that they "don't work" because they forgot that they need to update the version field to the newer version at the same time. The reason I prefer the size field is that it is impossible for the end user to mess things up, and the entirity of the mechanism is internal, and hidden from the user.
Regards,
/Bruce
RE: [PATCH v2 01/10] ethdev: introduce flow pre-configuration hints
Quoted 145 lines
-----Original Message-----
From: Bruce Richardson <[email protected]>
Sent: Wednesday, January 26, 2022 3:41 PM
To: Ori Kam <[email protected]>
Subject: Re: [PATCH v2 01/10] ethdev: introduce flow pre-configuration hintsQuoted 129 lines · Ori Kam
Quoted 75 lines
-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Wednesday, January 26, 2022 1:22 PM
Subject: Re: [PATCH v2 01/10] ethdev: introduce flow pre-configuration hints26/01/2022 11:52, Bruce Richardson:
Quoted 67 lines
The scenario is as follows. Suppose we have the initial state as below:
struct x_dev_cfg { int x; };int
x_dev_cfg(int dev_id, struct x_dev_cfg *cfg){ struct x_dev *dev = x_devs[id]; // some setup/config may go here return dev->configure(cfg, sizeof(cfg)); // sizeof(cfg) == 4 }Now, supposing we need to add in a new field into the config structure, a very common occurance. This will indeed break the ABI, so we need to use ABI versioning, to ensure that apps passing in the old structure, only call a function which expects the old structure. Therefore, we need a copy of the old structure, and a function to work on it. This gives this result:
struct x_dev_cfg { int x; bool flag; // new field; };struct
x_dev_cfg_v22{ // needed for ABI-versioned functionint x; };/* this function will only be called by *newly-linked* code, which uses
* the new structure */
intx_dev_cfg(int dev_id, struct x_dev_cfg *cfg){ struct x_dev *dev = x_devs[id]; // some setup/config may go here return dev->configure(cfg, sizeof(cfg)); // sizeof(cfg) is now 8 }/* this function is called by apps linked against old version */ int
x_dev_cfg_v22(int dev_id, struct x_dev_cfg_v22 *cfg){ struct x_dev *dev = x_devs[id]; // some setup/config may go here return dev->configure((void *)cfg, sizeof(cfg)); // sizeof(cfg) is still 4 }With the above library code, we have different functions using the different structures, so ABI compatibility is preserved - apps passing in a 4-byte struct call a function using the 4-byte struct, while newer apps can use the 8-byte version.
The final part of the puzzle is then how drivers react to this change. Originally, all drivers only use "x" in the config structure because that is all that there is. That will still continue to work fine in the above case, as both 4-byte and 8-byte structs have the same x value at the same offset. i.e. no driver updates for
x_devis needed.On the other hand, if there are drivers that do want/need the new field, they can also get to use it, but they do need to check for its presence before they do so, i.e they would work as below:
if (size_param > struct(x_dev_cfg_v22)) { // or "== struct(x_dev_cfg)" // use flags field }Quoted 8 lines
Quoted 1 line
Hope this is clear now.
Yes, this is the kind of explanation we need in our guideline doc. Alternatives can be documented as well.
If we can list pros/cons in the doc, it will be easier to choose the best approach and to explain the choice during code review.Thanks you very much for the clear explanation.
The draw back is that we need also to duplicate the functions. Using the flags/version we only need to create new structures and from application point of view it knows what exta fields it gets. (I agree that application knowledge has downsides but also advantages)
In the case of flags/version your example will look like this (this is for the record and may other developers are intrested):
struct
x_dev_cfg{ //original structint ver; int x; };struct
x_dev_cfg_v2{ // new structint ver; int x; bool flag; // new field;};
The function is always the same function:
x_dev_cfg(int dev_id, struct x_dev_cfg *cfg){ struct x_dev *dev = x_devs[id]; // some setup/config may go here return dev->configure(cfg);}
When calling this function with old struct:
X_dev_cfg(id, (struct x_dev_cfg *)cfg)When calling this function with new struct:
X_dev_cfg(id, (struct x_dev_cfg *)cfg_v2)In PMD:
If (cfg->ver>= 2)// version 2 logic Else If (cfg->v >=0) // base version logicWhen using flags it gives even more control since pmd can tell exactly what features are required.
Quoted 6 lines
All options have prons/cons
I vote for the version one.We can have a poll 😊
Or like Thomas said list pros and cons and each subsystem can have it own selection.
Quoted 10 lines
The biggest issue I have with this version approach is how is the user meant to know what version number to put into the structure? When the user upgrades from one version of DPDK to the next, are they manually to update their version numbers in all their structures? If they don't, they then may be mistified if they use the newer fields and find that they "don't work" because they forgot that they need to update the version field to the newer version at the same time. The reason I prefer the size field is that it is impossible for the end user to mess things up, and the entirity of the mechanism is internal, and hidden from the user.
The solution is simple when you define new struct in the struct you write what should be the version number.
You can also define that 0 is the latest one, so application that are are writing code which is size agnostic will just set 0 all the time.
Quoted 2 lines
Regards,
/Bruce
Re: [PATCH v2 01/10] ethdev: introduce flow pre-configuration hints
In reply to Jerin JacobQuoted 96 lines · Jerin Jacob
Quoted 17 lines · Alexander Kozyrev
The flow rules creation/destruction at a large scale incurs a performance penalty and may negatively impact the packet processing when used as part of the datapath logic. This is mainly because software/hardware resources are allocated and prepared during the flow rule creation.
In order to optimize the insertion rate, PMD may use some hints provided by the application at the initialization phase. The
rte_flow_configure()function allows to pre-allocate all the needed resources beforehand. These resources can be used at a later stage without costly allocations. Every PMD may use only the subset of hints and ignore unused ones or fail in case the requested configuration is not supported.Signed-off-by Alexander Kozyrev <[email protected]>---
lib/ethdev/rte_flow.h rte_flow_flex_item_release(uint16_t port_id, · line 4862
Quoted 7 lines
lib/ethdev/rte_flow.h +7
-0+/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Flow engine port configuration attributes. +*/ +__extension__Is this
__extension__required ?lib/ethdev/rte_flow.h rte_flow_flex_item_release(uint16_t port_id, · line 4867
Quoted 5 lines
lib/ethdev/rte_flow.h +5
-0+struct rte_flow_port_attr { +/** +* Version of the struct layout, should be 0. +*/ +uint32_t version;Why version number? Across DPDK, we are using dynamic function versioning, I think, that would
be sufficient for ABI versioningQuoted 23 lines
lib/ethdev/rte_flow.h +23
-0+/** +* Number of counter actions pre-configured. +* If set to 0, PMD will allocate counters dynamically. +* @see RTE_FLOW_ACTION_TYPE_COUNT +*/ +uint32_t nb_counters; +/** +* Number of aging actions pre-configured. +* If set to 0, PMD will allocate aging dynamically. +* @see RTE_FLOW_ACTION_TYPE_AGE +*/ +uint32_t nb_aging; +/** +* Number of traffic metering actions pre-configured. +* If set to 0, PMD will allocate meters dynamically. +* @see RTE_FLOW_ACTION_TYPE_METER +*/ +uint32_t nb_meters; +}; + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. lib/ethdev/rte_flow.h rte_flow_flex_item_release(uint16_t port_id, · line 4900
Quoted 10 lines
lib/ethdev/rte_flow.h +10
-0+* +* Configure flow rules module. +* To pre-allocate resources as per the flow port attributes +* this configuration function must be called before any flow rule is created. +* Must be called only after Ethernet device is configured, but may be called +* before or after the device is started as long as there are no flow rules. +* No other rte_flow function should be called while this function is invoked. +* This function can be called again to change the configuration. +* Some PMDs may not support re-configuration at all, +* or may only allow increasing the number of resources allocated. Following comment from Ivan looks good to me
* Pre-configure the port's flow API engine.
*
* This API can only be invoked before the application
* starts using the rest of the flow library functions. *
* The API can be invoked multiple times to change the
* settings. The port, however, may reject the changes.Quoted 12 lines
+ *
+ * @paramport_id
+ * Port identifier of Ethernet device.
+ * @param[in]port_attr
+ * Port configuration attributes.
+ * @param[out] error
+ * Perform verbose error reporting if not NULL.
+ * PMDs initialize this structure in case of error only.
+ *
+ * @return
+ * 0 on success, a negative errno value otherwise andrte_errnois set.
+ */
Quoted 8 lines
lib/ethdev/rte_flow.h rte_flow_flex_item_release(uint16_t port_id, · line 4915
Quoted 3 lines
lib/ethdev/rte_flow.h +3
-0+__rte_experimental +int +rte_flow_configure(uint16_t port_id,Should we couple, setting resource limit hint to configure function as if we add future items in
configuration, we may pain to manage all state. Instead how about,rte_flow_resource_reserve_hint_set()?
+1
Quoted 9 lines
Review
Quoted 4 lines
(quoted diff) +2
-0+ const struct rte_flow_port_attr *port_attr, + struct rte_flow_error *error);I think, we should have
_getfunction to get those limit numbers otherwise, we can not write portable applications as the return value is kind of boolean now if
don't define exact values forrte_errnofor reasons.
+1
RE: [PATCH v2 01/10] ethdev: introduce flow pre-configuration hints
Quoted 6 lines · On Monday, January 24, 2022 12:41 Ajit Khaparde <[email protected]>…
Quoted 2 lines · Jerin Jacob
On Tue, Jan 18, 2022 at 9:01 PM Alexander Kozyrev
Quoted 1 line · <[email protected]> wrote:
Quoted 1 line
Quoted 26 lines
Quoted 6 lines
Quoted 6 lines
The flow rules creation/destruction at a large scale incurs a performance penalty and may negatively impact the packet processing when used as part of the datapath logic. This is mainly because software/hardware resources are allocated and prepared during the flow rule creation.
In order to optimize the insertion rate, PMD may use some hints
provided
Quoted 19 lines
Quoted 10 lines
by the application at the initialization phase. The
rte_flow_configure()function allows to pre-allocate all the needed resources beforehand. These resources can be used at a later stage without costly allocations. Every PMD may use only the subset of hints and ignore unused ones or fail in case the requested configuration is not supported.Signed-off-by Alexander Kozyrev <[email protected]>---
lib/ethdev/rte_flow.h rte_flow_flex_item_release(uint16_t port_id, · line 4862
Quoted 7 lines
lib/ethdev/rte_flow.h +7
-0+/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Flow engine port configuration attributes. +*/ +__extension__Is this
__extension__required ?
No, it is not longer required as I removed bitfield from this structure. Thanks for catching.
Quoted 39 lines
Quoted 30 lines
lib/ethdev/rte_flow.h rte_flow_flex_item_release(uint16_t port_id, · line 4867
Quoted 6 lines
lib/ethdev/rte_flow.h +5
-0+struct rte_flow_port_attr { +/** +* Version of the struct layout, should be 0. +*/ +uint32_t version;Why version number? Across DPDK, we are using dynamic function versioning, I think, that would
be sufficient for ABI versioningQuoted 19 lines
lib/ethdev/rte_flow.h +19
-0+/** +* Number of counter actions pre-configured. +* If set to 0, PMD will allocate counters dynamically. +* @see RTE_FLOW_ACTION_TYPE_COUNT +*/ +uint32_t nb_counters; +/** +* Number of aging actions pre-configured. +* If set to 0, PMD will allocate aging dynamically. +* @see RTE_FLOW_ACTION_TYPE_AGE +*/ +uint32_t nb_aging; +/** +* Number of traffic metering actions pre-configured. +* If set to 0, PMD will allocate meters dynamically. +* @see RTE_FLOW_ACTION_TYPE_METER +*/ +uint32_t nb_meters; +};Quoted 8 lines
lib/ethdev/rte_flow.h rte_flow_flex_item_release(uint16_t port_id,
Quoted 8 lines
lib/ethdev/rte_flow.h +8
-0+ +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Configure flow rules module. +* To pre-allocate resources as per the flow port attributes +* this configuration function must be called before any flow rule is created.
Quoted 18 lines
Quoted 1 line
Quoted 1 line
+ * Must be called only after Ethernet device is configured, but may be
called
Quoted 2 lines
Quoted 2 lines
+ * before or after the device is started as long as there are no flow rules.
+ * No otherrte_flowfunction should be called while this function isinvoked.
Quoted 13 lines
Quoted 3 lines
+ * This function can be called again to change the configuration.
+ * Some PMDs may not support re-configuration at all,
+ * or may only allow increasing the number of resources allocated.Following comment from Ivan looks good to me
* Pre-configure the port's flow API engine.
*
* This API can only be invoked before the application
* starts using the rest of the flow library functions. *
* The API can be invoked multiple times to change the
* settings. The port, however, may reject the changes.
Ok, I'll adopt this wording in the v3.
Quoted 20 lines
Quoted 12 lines
Quoted 12 lines
+ *
+ * @paramport_id
+ * Port identifier of Ethernet device.
+ * @param[in]port_attr
+ * Port configuration attributes.
+ * @param[out] error
+ * Perform verbose error reporting if not NULL.
+ * PMDs initialize this structure in case of error only.
+ *
+ * @return
+ * 0 on success, a negative errno value otherwise andrte_errnois set.
+ */Quoted 8 lines
lib/ethdev/rte_flow.h rte_flow_flex_item_release(uint16_t port_id, · line 4915
Quoted 3 lines
lib/ethdev/rte_flow.h +3
-0+__rte_experimental +int +rte_flow_configure(uint16_t port_id,Should we couple, setting resource limit hint to configure function as if we add future items in
configuration, we may pain to manage all state. Instead how about,rte_flow_resource_reserve_hint_set()?
Quoted 1 line
+1
Port attributes are the hints, PMD can safely ignore anything that is not supported/deemed unreasonable. Having several functions to call instead of one configuration function seems like a burden to me.
Quoted 11 lines
Quoted 10 lines
Review
Quoted 5 lines
(quoted diff) +2
-0+ const struct rte_flow_port_attr *port_attr, + struct rte_flow_error *error);I think, we should have
_getfunction to get those limit numbers otherwise, we can not write portable applications as the return value is kind of boolean now if
don't define exact values forrte_errnofor reasons.+1
We had this discussion in RFC. The limits will vary from NIC to NIC and from system to system, depending on hardware capabilities and amount of free memory for example. It is easier to reject a configuration with a clear error description as we do for flow creation.
Re: [PATCH v2 01/10] ethdev: introduce flow pre-configuration hints
Quoted 28 lines · Alexander Kozyrev
Quoted 3 lines · On Monday, January 24, 2022 12:41 Ajit Khaparde <[email protected]>…
Quoted 1 line · Jerin Jacob
Ok, I'll adopt this wording in the v3.
Quoted 20 lines
Quoted 20 lines
Quoted 12 lines
+ *
+ * @paramport_id
+ * Port identifier of Ethernet device.
+ * @param[in]port_attr
+ * Port configuration attributes.
+ * @param[out] error
+ * Perform verbose error reporting if not NULL.
+ * PMDs initialize this structure in case of error only.
+ *
+ * @return
+ * 0 on success, a negative errno value otherwise andrte_errnois set.
+ */lib/ethdev/rte_flow.h rte_flow_flex_item_release(uint16_t port_id, · line 4915
Quoted 3 lines
lib/ethdev/rte_flow.h +3
-0+__rte_experimental +int +rte_flow_configure(uint16_t port_id,Should we couple, setting resource limit hint to configure function as if we add future items in
configuration, we may pain to manage all state. Instead how about,rte_flow_resource_reserve_hint_set()?
Quoted 3 lines
Quoted 1 line
+1
Port attributes are the hints, PMD can safely ignore anything that is not supported/deemed unreasonable. Having several functions to call instead of one configuration function seems like a burden to me.
If we add a lot of features which has different state it will be difficult to manage.
Since it is the slow path and OPTIONAL API. IMO, it should be fine to have a separate API for a specific purpose
to have a clean interface.
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
(quoted diff) +2
-0+ const struct rte_flow_port_attr *port_attr, + struct rte_flow_error *error);
Quoted 8 lines
Quoted 5 lines
Quoted 4 lines
I think, we should have
_getfunction to get those limit numbers otherwise, we can not write portable applications as the return value is kind of boolean now if
don't define exact values forrte_errnofor reasons.+1
We had this discussion in RFC. The limits will vary from NIC to NIC and from system to system, depending on hardware capabilities and amount of free memory for example. It is easier to reject a configuration with a clear error description as we do for flow creation.
In that case, we can return a "defined" return value or "defined" errno to capture this case so that
the application can make forward progress to differentiate between API failed vs dont having enough resources
and move on.
RE: [PATCH v2 01/10] ethdev: introduce flow pre-configuration hints
Quoted 35 lines · On Tuesday, January 25, 2022 13:44 Jerin Jacob <[email protected]> wrote:
Quoted 2 lines · Alexander Kozyrev
On Monday, January 24, 2022 12:41 Ajit Khaparde
Quoted 4 lines · <[email protected]> wrote:
Quoted 3 lines
Quoted 1 line · Jerin Jacob
Quoted 13 lines
Ok, I'll adopt this wording in the v3.
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
+ *
+ * @paramport_id
+ * Port identifier of Ethernet device.
+ * @param[in]port_attr
+ * Port configuration attributes.
+ * @param[out] error
+ * Perform verbose error reporting if not NULL.
+ * PMDs initialize this structure in case of error only.
+ *
+ * @return
+ * 0 on success, a negative errno value otherwise andrte_errnoisset.
Quoted 11 lines
Quoted 10 lines
Quoted 9 lines
lib/ethdev/rte_flow.h rte_flow_flex_item_release(uint16_t port_id, · line 4915
Quoted 4 lines
+ */
lib/ethdev/rte_flow.h +3
-0+__rte_experimental +int +rte_flow_configure(uint16_t port_id,Should we couple, setting resource limit hint to configure function as if we add future items in
configuration, we may pain to manage all state. Instead how about,rte_flow_resource_reserve_hint_set()?+1
Port attributes are the hints, PMD can safely ignore anything that is not
supported/deemed unreasonable.
Quoted 8 lines
Quoted 1 line
Having several functions to call instead of one configuration function seems
like a burden to me.
If we add a lot of features which has different state it will be difficult to manage.
Since it is the slow path and OPTIONAL API. IMO, it should be fine to have a separate API for a specific purpose
to have a clean interface.
This approach contradicts to the DPDK way of configuring devices. It you look at the rte_eth_dev_configure or rte_eth_rx_queue_setup API you will see that the configuration is propagated via config structures. I would like to conform to this approach with my new API as well.
Another question is how to deal with interdependencies with separate hints? There could be some resources that requires other resources to be present. Or one resource shares the hardware registers with another one and needs to be accounted for. That is not easy to do with separate function calls.
Quoted 17 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Review
Quoted 6 lines
(quoted diff) +2
-0+ const struct rte_flow_port_attr *port_attr, + struct rte_flow_error *error);I think, we should have
_getfunction to get those limit numbersotherwise,
Quoted 5 lines
Quoted 4 lines
Quoted 3 lines
we can not write portable applications as the return value is kind of boolean now if
don't define exact values forrte_errnofor reasons.+1
We had this discussion in RFC. The limits will vary from NIC to NIC and from
system to
Quoted 1 line
system, depending on hardware capabilities and amount of free memory
for example.
Quoted 8 lines
Quoted 1 line
It is easier to reject a configuration with a clear error description as we do
for flow creation.
In that case, we can return a "defined" return value or "defined" errno to capture this case so that
the application can make forward progress to differentiate between API failed vs dont having enough resources
and move on.
I think you are right and it will be useful to provide some hardware capabilities. I'll add something like rte_flow_info_get() to obtain available flow rule resources.
Re: [PATCH v2 01/10] ethdev: introduce flow pre-configuration hints
Quoted 46 lines · Alexander Kozyrev
Quoted 35 lines · On Tuesday, January 25, 2022 13:44 Jerin Jacob <[email protected]> wrote:
Quoted 2 lines · Alexander Kozyrev
On Monday, January 24, 2022 12:41 Ajit Khaparde
Quoted 4 lines · <[email protected]> wrote:
Quoted 3 lines
Quoted 1 line · Jerin Jacob
Quoted 13 lines
Ok, I'll adopt this wording in the v3.
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
+ *
+ * @paramport_id
+ * Port identifier of Ethernet device.
+ * @param[in]port_attr
+ * Port configuration attributes.
+ * @param[out] error
+ * Perform verbose error reporting if not NULL.
+ * PMDs initialize this structure in case of error only.
+ *
+ * @return
+ * 0 on success, a negative errno value otherwise andrte_errnoisset.
Quoted 11 lines
Quoted 10 lines
Quoted 9 lines
lib/ethdev/rte_flow.h rte_flow_flex_item_release(uint16_t port_id, · line 4915
Quoted 4 lines
+ */
lib/ethdev/rte_flow.h +3
-0+__rte_experimental +int +rte_flow_configure(uint16_t port_id,Should we couple, setting resource limit hint to configure function as if we add future items in
configuration, we may pain to manage all state. Instead how about,rte_flow_resource_reserve_hint_set()?+1
Port attributes are the hints, PMD can safely ignore anything that is not
supported/deemed unreasonable.
Quoted 8 lines
Quoted 1 line
Having several functions to call instead of one configuration function seems
like a burden to me.
If we add a lot of features which has different state it will be difficult to manage.
Since it is the slow path and OPTIONAL API. IMO, it should be fine to have a separate API for a specific purpose
to have a clean interface.
Quoted 4 lines
This approach contradicts to the DPDK way of configuring devices. It you look at the
rte_eth_dev_configureorrte_eth_rx_queue_setupAPI you will see that the configuration is propagated via config structures. I would like to conform to this approach with my new API as well.
There is a subtle difference, those are mandatory APIs. i,e application must call those API to use the subsequent APIs.
I am OK with introducing rte_flow_configure() for such use cases. Probably, we can add these parameters in rte_flow_configure() for the new features.
And make it mandatory API for the next ABI to avoid application breakage.
Also, please change git commit to the description for adding the configure state
for rte_flow API.
BTW: Your Queue patch[3/3] probably needs to add the nb_queue parameter to configure.
So the driver knows, the number queue needed upfront like the ethdev API scheme.
Quoted 5 lines
Another question is how to deal with interdependencies with separate hints? There could be some resources that requires other resources to be present. Or one resource shares the hardware registers with another one and needs to be accounted for. That is not easy to do with separate function calls.
I got the use case now.
Quoted 21 lines
Quoted 21 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Review
Quoted 7 lines
(quoted diff) +2
-0+ const struct rte_flow_port_attr *port_attr, + struct rte_flow_error *error);I think, we should have
_getfunction to get those limit numbersotherwise,
Quoted 5 lines
Quoted 4 lines
Quoted 3 lines
we can not write portable applications as the return value is kind of boolean now if
don't define exact values forrte_errnofor reasons.+1
We had this discussion in RFC. The limits will vary from NIC to NIC and from
system to
Quoted 1 line
system, depending on hardware capabilities and amount of free memory
for example.
Quoted 1 line
It is easier to reject a configuration with a clear error description as we do
for flow creation.
Quoted 8 lines
Quoted 5 lines
In that case, we can return a "defined" return value or "defined" errno to capture this case so that
the application can make forward progress to differentiate between API failed vs dont having enough resources
and move on.I think you are right and it will be useful to provide some hardware capabilities. I'll add something like
rte_flow_info_get()to obtain available flow rule resources.
Ack.
PATCH v2 2/10 ethdev: add flow item/action templates
In reply to Alexander KozyrevTreating every single flow rule as a completely independent and separate entity negatively impacts the flow rules insertion rate. Oftentimes in an application, many flow rules share a common structure (the same item mask and/or action list) so they can be grouped and classified together. This knowledge may be used as a source of optimization by a PMD/HW.
The item template defines common matching fields (the item mask) without values. The action template holds a list of action types that will be used together in the same rule. The specific values for items and actions will be given only during the rule creation.
A table combines item and action templates along with shared flow rule attributes (group ID, priority and traffic direction). This way a PMD/HW can prepare all the resources needed for efficient flow rules creation in the datapath. To avoid any hiccups due to memory reallocation, the maximum number of flow rules is defined at table creation time.
The flow rule creation is done by selecting a table, an item template and an action template (which are bound to the table), and setting unique values for the items and actions.
--- doc/guides/prog_guide/rte_flow.rst | 124 ++++++++++++ doc/guides/rel_notes/release_22_03.rst | 8 + lib/ethdev/rte_flow.c | 141 +++++++++++++ lib/ethdev/rte_flow.h | 269 +++++++++++++++++++++++++ lib/ethdev/rte_flow_driver.h | 37 ++++ lib/ethdev/version.map | 6 + 6 files changed, 585 insertions(+)
doc/guides/prog_guide/rte_flow.rst +124 -0
@@ -3626,6 +3626,130 @@ Return values: - 0 on success, a negative errno value otherwise and ``rte_errno`` is set. +Flow templates +~~~~~~~~~~~~~~ + +Oftentimes in an application, many flow rules share a common structure +(the same pattern and/or action list) so they can be grouped and classified +together. This knowledge may be used as a source of optimization by a PMD/HW. +The flow rule creation is done by selecting a table, an item template +and an action template (which are bound to the table), and setting unique +values for the items and actions. This API is not thread-safe. + +Item templates +^^^^^^^^^^^^^^ + +The item template defines a common pattern (the item mask) without values. +The mask value is used to select a field to match on, spec/last are ignored. +The item template may be used by multiple tables and must not be destroyed +until all these tables are destroyed first. + +.. code-block:: c + + struct rte_flow_item_template * + rte_flow_item_template_create(uint16_t port_id, + const struct rte_flow_item_template_attr *it_attr, + const struct rte_flow_item items[], + struct rte_flow_error *error); + +For example, to create an item template to match on the destination MAC: + +.. code-block:: c + + struct rte_flow_item root_items[2] = {{0}}; + struct rte_flow_item_eth eth_m = {0}; + items[0].type = RTE_FLOW_ITEM_TYPE_ETH; + eth_m.dst.addr_bytes = "\xff\xff\xff\xff\xff\xff"; + items[0].mask = ð_m; + items[1].type = RTE_FLOW_ITEM_TYPE_END; + + struct rte_flow_item_template *it = + rte_flow_item_template_create(port, &itr, &items, &error); + +The concrete value to match on will be provided at the rule creation. + +Action templates +^^^^^^^^^^^^^^^^ + +The action template holds a list of action types to be used in flow rules. +The mask parameter allows specifying a shared constant value for every rule. +The action template may be used by multiple tables and must not be destroyed +until all these tables are destroyed first. + +.. code-block:: c + + struct rte_flow_action_template * + rte_flow_action_template_create(uint16_t port_id, + const struct rte_flow_action_template_attr *at_attr, + const struct rte_flow_action actions[], + const struct rte_flow_action masks[], + struct rte_flow_error *error); + +For example, to create an action template with the same Mark ID +but different Queue Index for every rule: + +.. code-block:: c + + struct rte_flow_action actions[] = { + /* Mark ID is constant (4) for every rule, Queue Index is unique */ + [0] = {.type = RTE_FLOW_ACTION_TYPE_MARK, + .conf = &(struct rte_flow_action_mark){.id = 4}}, + [1] = {.type = RTE_FLOW_ACTION_TYPE_QUEUE}, + [2] = {.type = RTE_FLOW_ACTION_TYPE_END,}, + }; + struct rte_flow_action masks[] = { + /* Assign to MARK mask any non-zero value to make it constant */ + [0] = {.type = RTE_FLOW_ACTION_TYPE_MARK, + .conf = &(struct rte_flow_action_mark){.id = 1}}, + [1] = {.type = RTE_FLOW_ACTION_TYPE_QUEUE}, + [2] = {.type = RTE_FLOW_ACTION_TYPE_END,}, + }; + + struct rte_flow_action_template *at = + rte_flow_action_template_create(port, &atr, &actions, &masks, &error); + +The concrete value for Queue Index will be provided at the rule creation. + +Flow table +^^^^^^^^^^ + +A table combines a number of item and action templates along with shared flow +rule attributes (group ID, priority and traffic direction). This way a PMD/HW +can prepare all the resources needed for efficient flow rules creation in +the datapath. To avoid any hiccups due to memory reallocation, the maximum +number of flow rules is defined at table creation time. Any flow rule +creation beyond the maximum table size is rejected. Application may create +another table to accommodate more rules in this case. + +.. code-block:: c + + struct rte_flow_table * + rte_flow_table_create(uint16_t port_id, + const struct rte_flow_table_attr *table_attr, + struct rte_flow_item_template *item_templates[], + uint8_t nb_item_templates, + struct rte_flow_action_template *action_templates[], + uint8_t nb_action_templates, + struct rte_flow_error *error); + +A table can be created only after the Flow Rules management is configured +and item and action templates are created. + +.. code-block:: c + + rte_flow_configure(port, *port_attr, *error); + + struct rte_flow_item_template *it[0] = + rte_flow_item_template_create(port, &itr, &items, &error); + struct rte_flow_action_template *at[0] = + rte_flow_action_template_create(port, &atr, &actions, &masks, &error); + + struct rte_flow_table *table = + rte_flow_table_create(port, *table_attr, + *it, nb_item_templates, + *at, nb_action_templates, + *error); + .. _flow_isolated_mode: Flow isolated mode
doc/guides/rel_notes/release_22_03.rst +8 -0
@@ -58,6 +58,14 @@ New Features * ethdev: Added ``rte_flow_configure`` API to configure Flow Management library, allowing to pre-allocate some resources for better performance. +* ethdev: Added ``rte_flow_table_create`` API to group flow rules with + the same flow attributes and common matching patterns and actions + defined by ``rte_flow_item_template_create`` and + ``rte_flow_action_template_create`` respectively. + Corresponding functions to destroy these entities are: + ``rte_flow_table_destroy``, ``rte_flow_item_template_destroy`` + and ``rte_flow_action_template_destroy`` respectively. + Removed Items -------------
lib/ethdev/rte_flow.c +141 -0
144 lines not on this page · raw message
lib/ethdev/rte_flow.h +269 -0
275 lines not on this page · raw message
lib/ethdev/rte_flow_driver.h +37 -0
@@ -157,6 +157,43 @@ struct rte_flow_ops { (struct rte_eth_dev *dev, const struct rte_flow_port_attr *port_attr, struct rte_flow_error *err); +/** See rte_flow_item_template_create() */ +struct rte_flow_item_template *(*item_template_create) + (struct rte_eth_dev *dev, +const struct rte_flow_item_template_attr *it_attr, +const struct rte_flow_item items[], +struct rte_flow_error *err); +/** See rte_flow_item_template_destroy() */ +int (*item_template_destroy) + (struct rte_eth_dev *dev, +struct rte_flow_item_template *it, +struct rte_flow_error *err); +/** See rte_flow_action_template_create() */ +struct rte_flow_action_template *(*action_template_create) + (struct rte_eth_dev *dev, +const struct rte_flow_action_template_attr *at_attr, +const struct rte_flow_action actions[], +const struct rte_flow_action masks[], +struct rte_flow_error *err); +/** See rte_flow_action_template_destroy() */ +int (*action_template_destroy) + (struct rte_eth_dev *dev, +struct rte_flow_action_template *at, +struct rte_flow_error *err); +/** See rte_flow_table_create() */ +struct rte_flow_table *(*table_create) + (struct rte_eth_dev *dev, +const struct rte_flow_table_attr *table_attr, +struct rte_flow_item_template *item_templates[], +uint8_t nb_item_templates, +struct rte_flow_action_template *action_templates[], +uint8_t nb_action_templates, +struct rte_flow_error *err); +/** See rte_flow_table_destroy() */ +int (*table_destroy) + (struct rte_eth_dev *dev, +struct rte_flow_table *table, +struct rte_flow_error *err); };/**
lib/ethdev/version.map +6 -0
@@ -259,6 +259,12 @@ EXPERIMENTAL { # added in 22.03 rte_flow_configure; + rte_flow_item_template_create; + rte_flow_item_template_destroy; + rte_flow_action_template_create; + rte_flow_action_template_destroy; + rte_flow_table_create; + rte_flow_table_destroy; }; INTERNAL {
Signature · 1 line
2.18.2
PATCH v2 3/10 ethdev: bring in async queue-based flow rules operations
In reply to Alexander KozyrevA new, faster, queue-based flow rules management mechanism is needed for applications offloading rules inside the datapath. This asynchronous and lockless mechanism frees the CPU for further packet processing and reduces the performance impact of the flow rules creation/destruction on the datapath. Note that queues are not thread-safe and the queue should be accessed from the same thread for all queue operations. It is the responsibility of the app to sync the queue functions in case of multi-threaded access to the same queue.
The rte_flow_q_flow_create() function enqueues a flow creation to the requested queue. It benefits from already configured resources and sets unique values on top of item and action templates. A flow rule is enqueued on the specified flow queue and offloaded asynchronously to the hardware. The function returns immediately to spare CPU for further packet processing. The application must invoke the rte_flow_q_dequeue() function to complete the flow rule operation offloading, to clear the queue, and to receive the operation status. The rte_flow_q_flow_destroy() function enqueues a flow destruction to the requested queue.
--- doc/guides/prog_guide/img/rte_flow_q_init.svg | 71 ++++ .../prog_guide/img/rte_flow_q_usage.svg | 60 +++ doc/guides/prog_guide/rte_flow.rst | 158 ++++++++ doc/guides/rel_notes/release_22_03.rst | 9 + lib/ethdev/rte_flow.c | 173 ++++++++- lib/ethdev/rte_flow.h | 348 ++++++++++++++++++ lib/ethdev/rte_flow_driver.h | 61 +++ lib/ethdev/version.map | 7 + 8 files changed, 886 insertions(+), 1 deletion(-) create mode 100644 doc/guides/prog_guide/img/rte_flow_q_init.svg create mode 100644 doc/guides/prog_guide/img/rte_flow_q_usage.svg
doc/guides/prog_guide/img/rte_flow_q_init.svg new file +71 -0
@@ -0,0 +1,71 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- SPDX-License-Identifier: BSD-3-Clause --> +<!-- Copyright(c) 2022 NVIDIA Corporation & Affiliates --> + +<svg + width="485" height="535" + xmlns="http://www.w3.org/2000/svg" + xmlns:xlink="http://www.w3.org/1999/xlink" + overflow="hidden"> + <defs> + <clipPath id="clip0"> + <rect x="0" y="0" width="485" height="535"/> + </clipPath> + </defs> + <g clip-path="url(#clip0)"> + <rect x="0" y="0" width="485" height="535" fill="#FFFFFF"/> + <rect x="0.500053" y="79.5001" width="482" height="59" + stroke="#000000" stroke-width="1.33333" stroke-miterlimit="8" + fill="#A6A6A6"/> + <text font-family="Calibri,Calibri_MSFontService,sans-serif" + font-weight="400" font-size="24" transform="translate(121.6 116)"> + rte_eth_dev_configure + <tspan font-size="24" x="224.007" y="0">()</tspan> + </text> + <rect x="0.500053" y="158.5" width="482" height="59" stroke="#000000" + stroke-width="1.33333" stroke-miterlimit="8" fill="#FFFFFF"/> + <text font-family="Calibri,Calibri_MSFontService,sans-serif" + font-weight="400" font-size="24" transform="translate(140.273 195)"> + rte_flow_configure() + </text> + <rect x="0.500053" y="236.5" width="482" height="60" stroke="#000000" + stroke-width="1.33333" stroke-miterlimit="8" fill="#FFFFFF"/> + <text font-family="Calibri,Calibri_MSFontService,sans-serif" + font-weight="400" font-size="24" transform="translate(77.4259 274)"> + rte_flow_item_template_create() + </text> + <rect x="0.500053" y="316.5" width="482" height="59" stroke="#000000" + stroke-width="1.33333" stroke-miterlimit="8" fill="#FFFFFF"/> + <text font-family="Calibri,Calibri_MSFontService,sans-serif" + font-weight="400" font-size="24" transform="translate(69.3792 353)"> + rte_flow_action_template_create + <tspan font-size="24" x="328.447" y="0">(</tspan>) + </text> + <rect x="0.500053" y="0.500053" width="482" height="60" stroke="#000000" + stroke-width="1.33333" stroke-miterlimit="8" fill="#A6A6A6"/> + <text font-family="Calibri,Calibri_MSFontService,sans-serif" + font-weight="400" font-size="24" transform="translate(177.233 37)"> + rte_eal_init + <tspan font-size="24" x="112.74" y="0">()</tspan> + </text> + <path d="M2-1.09108e-05 2.00005 9.2445-1.99995 9.24452-2 1.09108e-05ZM6.00004 7.24448 0.000104987 19.2445-5.99996 7.24455Z" transform="matrix(-1 0 0 1 241 60)"/> + <path d="M2-1.08133e-05 2.00005 9.41805-1.99995 9.41807-2 1.08133e-05ZM6.00004 7.41802 0.000104987 19.4181-5.99996 7.41809Z" transform="matrix(-1 0 0 1 241 138)"/> + <path d="M2-1.09108e-05 2.00005 9.2445-1.99995 9.24452-2 1.09108e-05ZM6.00004 7.24448 0.000104987 19.2445-5.99996 7.24455Z" transform="matrix(-1 0 0 1 241 217)"/> + <rect x="0.500053" y="395.5" width="482" height="59" stroke="#000000" + stroke-width="1.33333" stroke-miterlimit="8" fill="#FFFFFF"/> + <text font-family="Calibri,Calibri_MSFontService,sans-serif" + font-weight="400" font-size="24" transform="translate(124.989 432)"> + rte_flow_table_create + <tspan font-size="24" x="217.227" y="0">(</tspan> + <tspan font-size="24" x="224.56" y="0">)</tspan> + </text> + <path d="M2-1.05859e-05 2.00005 9.83526-1.99995 9.83529-2 1.05859e-05ZM6.00004 7.83524 0.000104987 19.8353-5.99996 7.83531Z" transform="matrix(-1 0 0 1 241 296)"/> + <path d="M243 375 243 384.191 239 384.191 239 375ZM247 382.191 241 394.191 235 382.191Z"/> + <rect x="0.500053" y="473.5" width="482" height="60" stroke="#000000" + stroke-width="1.33333" stroke-miterlimit="8" fill="#A6A6A6"/> + <text font-family="Calibri,Calibri_MSFontService,sans-serif" + font-weight="400" font-size="24" transform="translate(145.303 511)"> + rte_eth_dev_start()</text> + <path d="M245 454 245 463.191 241 463.191 241 454ZM249 461.191 243 473.191 237 461.191Z"/> + </g> +</svg>
doc/guides/prog_guide/img/rte_flow_q_usage.svg new file +60 -0
61 lines not on this page · raw message
doc/guides/prog_guide/rte_flow.rst +158 -0
182 lines not on this page · raw message
doc/guides/rel_notes/release_22_03.rst +9 -0
@@ -66,6 +66,15 @@ New Features ``rte_flow_table_destroy``, ``rte_flow_item_template_destroy`` and ``rte_flow_action_template_destroy`` respectively. +* ethdev: Added ``rte_flow_q_flow_create`` and ``rte_flow_q_flow_destroy`` API + to enqueue flow creaion/destruction operations asynchronously as well as + ``rte_flow_q_dequeue`` to poll results of these operations and + ``rte_flow_q_drain`` to drain the flow queue and pass all operations to NIC. + Introduced asynchronous API for indirect actions management as well: + ``rte_flow_q_action_handle_create``, ``rte_flow_q_action_handle_destroy`` and + ``rte_flow_q_action_handle_update``. + + Removed Items -------------
lib/ethdev/rte_flow.c +172 -1
188 lines not on this page · raw message
lib/ethdev/rte_flow.h +348 -0
378 lines not on this page · raw message
lib/ethdev/rte_flow_driver.h +61 -0
73 lines not on this page · raw message
lib/ethdev/version.map +7 -0
@@ -265,6 +265,13 @@ EXPERIMENTAL { rte_flow_action_template_destroy; rte_flow_table_create; rte_flow_table_destroy; + rte_flow_q_flow_create; + rte_flow_q_flow_destroy; + rte_flow_q_action_handle_create; + rte_flow_q_action_handle_destroy; + rte_flow_q_action_handle_update; + rte_flow_q_drain; + rte_flow_q_dequeue; }; INTERNAL {
Signature · 1 line
2.18.2
PATCH v2 4/10 app/testpmd: implement rte flow configure
In reply to Alexander KozyrevAdd testpmd support for the rte_flow_configure API. Provide the command line interface for the Flow management. Usage example: flow configure 0 queues_number 8 queues_size 256
--- app/test-pmd/cmdline_flow.c | 109 +++++++++++++++++++- app/test-pmd/config.c | 29 ++++++ app/test-pmd/testpmd.h | 5 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 34 +++++- 4 files changed, 174 insertions(+), 3 deletions(-)
app/test-pmd/cmdline_flow.c +108 -1
@@ -72,6 +72,7 @@ enum index {/* Top-level command. */ FLOW ,/* Sub-level commands. */ +CONFIGURE ,INDIRECT_ACTION ,VALIDATE , CREATE,
@@ -122,6 +123,13 @@ enum index {DUMP_ALL ,DUMP_ONE , +/* Configure arguments */ +CONFIG_QUEUES_NUMBER , +CONFIG_QUEUES_SIZE , +CONFIG_COUNTERS_NUMBER , +CONFIG_AGING_COUNTERS_NUMBER , +CONFIG_METERS_NUMBER , +/* Indirect action arguments */ INDIRECT_ACTION_CREATE , INDIRECT_ACTION_UPDATE,
@@ -846,6 +854,10 @@ struct buffer {enum index command;/**< Flow command. */ portid_t port;/**< Affected port ID. */ union { +struct { +struct rte_flow_port_attr port_attr; +struct rte_flow_queue_attr queue_attr; + } configure;/**< Configuration arguments. */ struct {uint32_t *action_id;uint32_t action_id_n;
@@ -927,6 +939,16 @@ static const enum index next_flex_item[] = { ZERO, }; +static const enum index next_config_attr[] = { +CONFIG_QUEUES_NUMBER , +CONFIG_QUEUES_SIZE , +CONFIG_COUNTERS_NUMBER , +CONFIG_AGING_COUNTERS_NUMBER , +CONFIG_METERS_NUMBER , +END , +ZERO , +}; +static const enum index next_ia_create_attr[] = {INDIRECT_ACTION_CREATE_ID ,INDIRECT_ACTION_INGRESS ,
@@ -1962,6 +1984,9 @@ static int parse_aged(struct context *, const struct token *,static int parse_isolate (struct context *,const struct token *,const char *,unsigned int ,void *,unsigned int ); +static int parse_configure (struct context *,const struct token *, +const char *,unsigned int , +void *,unsigned int );static int parse_tunnel (struct context *,const struct token *,const char *,unsigned int ,void *,unsigned int );
@@ -2187,7 +2212,8 @@ static const struct token token_list[] = { .type = "{command} {port_id} [{arg} [...]]", .help = "manage ingress/egress flow rules", .next = NEXT(NEXT_ENTRY - (INDIRECT_ACTION, + (CONFIGURE, + INDIRECT_ACTION, VALIDATE, CREATE, DESTROY,
@@ -2202,6 +2228,56 @@ static const struct token token_list[] = { .call = parse_init, },/* Top-level command. */ + [CONFIGURE] = { + .name = "configure", + .help = "configure flow rules", + .next =NEXT (next_config_attr, + NEXT_ENTRY(COMMON_PORT_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, port)), + .call = parse_configure, + }, +/* Configure arguments. */ + [CONFIG_QUEUES_NUMBER] = { + .name = "queues_number", + .help = "number of queues", + .next =NEXT (next_config_attr, + NEXT_ENTRY(COMMON_UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct buffer, + args.configure.port_attr.nb_queues)), + }, + [CONFIG_QUEUES_SIZE] = { + .name = "queues_size", + .help = "number of elements in queues", + .next =NEXT (next_config_attr, + NEXT_ENTRY(COMMON_UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct buffer, + args.configure.queue_attr.size)), + }, + [CONFIG_COUNTERS_NUMBER] = { + .name = "counters_number", + .help = "number of counters", + .next =NEXT (next_config_attr, + NEXT_ENTRY(COMMON_UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct buffer, + args.configure.port_attr.nb_counters)), + }, + [CONFIG_AGING_COUNTERS_NUMBER] = { + .name = "aging_counters_number", + .help = "number of aging counters", + .next =NEXT (next_config_attr, + NEXT_ENTRY(COMMON_UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct buffer, + args.configure.port_attr.nb_aging)), + }, + [CONFIG_METERS_NUMBER] = { + .name = "meters_number", + .help = "number of meters", + .next =NEXT (next_config_attr, + NEXT_ENTRY(COMMON_UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct buffer, + args.configure.port_attr.nb_meters)), + }, +/* Top-level command. */ [INDIRECT_ACTION] = { .name = "indirect_action", .type = "{command} {port_id} [{arg} [...]]",
@@ -7465,6 +7541,33 @@ parse_isolate(struct context *ctx, const struct token *token,return len; } +/** Parse tokens for configure command. */ +static int +parse_configure (struct context *ctx,const struct token *token, +const char *str,unsigned int len, +void *buf,unsigned int size) +{ +struct buffer *out = buf; + +/* Token name must match. */ +if (parse_default (ctx, token, str, len,NULL ,0 ) <0 ) +return -1 ; +/* Nothing else to do if there is no buffer. */ +if (!out) +return len; +if (!out->command) { +if (ctx->curr !=CONFIGURE ) +return -1 ; +if (sizeof (*out) > size) +return -1 ; + out->command = ctx->curr; + ctx->objdata =0 ; + ctx->object = out; + ctx->objmask =NULL ; + } +return len; +} + static int parse_flex(struct context *ctx, const struct token *token, const char *str, unsigned int len,
@@ -8691,6 +8794,10 @@ static void cmd_flow_parsed(const struct buffer *in) {switch (in->command) { +case CONFIGURE : +port_flow_configure (in->port, &in->args.configure.port_attr, + &in->args.configure.queue_attr); +break ;case INDIRECT_ACTION_CREATE : port_action_handle_create( in->port, in->args.vc.attr.group,
app/test-pmd/config.c +29 -0
@@ -1595,6 +1595,35 @@ action_alloc(portid_t port_id, uint32_t id,return 0 ; } +/** Configure flow management resources. */ +int +port_flow_configure (portid_t port_id, +const struct rte_flow_port_attr *port_attr, +const struct rte_flow_queue_attr *queue_attr) +{ +struct rte_port *port; +struct rte_flow_error error; +const struct rte_flow_queue_attr *attr_list[port_attr->nb_queues]; +int std_queue; + +if (port_id_is_invalid (port_id,ENABLED_WARN ) || + port_id == (portid_t )RTE_PORT_ALL ) +return -EINVAL ; + port = &ports[port_id]; + port->queue_nb = port_attr->nb_queues; + port->queue_sz = queue_attr->size; +for (std_queue =0 ; std_queue < port_attr->nb_queues; std_queue++) + attr_list[std_queue] = queue_attr; +/* Poisoning to make sure PMDs update it in case of error. */ +memset (&error,0x66 ,sizeof (error)); +if (rte_flow_configure (port_id, port_attr, attr_list, &error)) +return port_flow_complain (&error); +printf ("Configure flows on port %u: " +"number of queues %d with %d elements\n" , + port_id, port_attr->nb_queues, queue_attr->size); +return 0 ; +} +/** Create indirect action */ int port_action_handle_create(portid_t port_id, uint32_t id,
app/test-pmd/testpmd.h +5 -0
@@ -243,6 +243,8 @@ struct rte_port {struct rte_eth_txconf tx_conf[RTE_MAX_QUEUES_PER_PORT +1 ];/**< per queue tx configuration */ struct rte_ether_addr *mc_addr_pool;/**< pool of multicast addrs */ uint32_t mc_addr_nb;/**< nb. of addr. in mc_addr_pool */ +queueid_t queue_nb;/**< nb. of queues for flow rules */ +uint32_t queue_sz;/**< size of a queue for flow rules */ uint8_t slave_flag;/**< bonding slave port */ struct port_flow *flow_list;/**< Associated flows. */ struct port_indirect_action *actions_list;
@@ -885,6 +887,9 @@ struct rte_flow_action_handle *port_action_handle_get_by_id(portid_t port_id, uint32_t id);int port_action_handle_update (portid_t port_id,uint32_t id,const struct rte_flow_action *action); +int port_flow_configure (portid_t port_id, +const struct rte_flow_port_attr *port_attr, +const struct rte_flow_queue_attr *queue_attr); int port_flow_validate(portid_t port_id, const struct rte_flow_attr *attr, const struct rte_flow_item *pattern,
doc/guides/testpmd_app_ug/testpmd_funcs.rst +32 -2
@@ -3285,8 +3285,8 @@ Flow rules management --------------------- Control of the generic flow API (*rte_flow*) is fully exposed through the -``flow`` command (validation, creation, destruction, queries and operation -modes). +``flow`` command (configuration, validation, creation, destruction, queries +and operation modes). Considering *rte_flow* overlaps with all `Filter Functions`_, using both features simultaneously may cause undefined side-effects and is therefore
@@ -3309,6 +3309,14 @@ The first parameter stands for the operation mode. Possible operations and their general syntax are described below. They are covered in detail in the following sections. +- Configure flow management:: + + flow configure {port_id} + [queues_number {number}] [queues_size {size}] + [counters_number {number}] + [aging_counters_number {number}] + [meters_number {number}] + - Check whether a flow rule can be created:: flow validate {port_id}
@@ -3368,6 +3376,28 @@ following sections. flow tunnel list {port_id} +Configuring flow management library +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +``flow configure`` pre-allocates all the needed resources in the underlying +device to be used later at the flow creation. Flow queues are allocated as well +for asynchronous flow creation/destruction operations. It is bound to +``rte_flow_configure()``:: + + flow configure {port_id} + [queues_number {number}] [queues_size {size}] + [counters_number {number}] + [aging_counters_number {number}] + [meters_number {number}] + +If successful, it will show:: + + Configure flows on port #[...]: number of queues #[...] with #[...] elements + +Otherwise it will show an error message of the form:: + + Caught error type [...] ([...]): [...] + Creating a tunnel stub for offload ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Signature · 1 line
2.18.2
PATCH v2 5/10 app/testpmd: implement rte flow item/action template
In reply to Alexander KozyrevAdd testpmd support for the rte_flow_item_template and rte_flow_action_template APIs. Provide the command line interface for the template creation/destruction. Usage example:
testpmd> flow item_template 0 create item_template_id 2
template eth dst is 00:16:3e:31:15:c3 / end
testpmd> flow action_template 0 create action_template_id 4
template drop / end mask drop / end
testpmd> flow action_template 0 destroy action_template 4 testpmd> flow item_template 0 destroy item_template 2
--- app/test-pmd/cmdline_flow.c | 376 +++++++++++++++++++- app/test-pmd/config.c | 204 +++++++++++ app/test-pmd/testpmd.h | 22 ++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 97 +++++ 4 files changed, 697 insertions(+), 2 deletions(-)
app/test-pmd/cmdline_flow.c +374 -2
@@ -56,6 +56,8 @@ enum index {COMMON_POLICY_ID ,COMMON_FLEX_HANDLE ,COMMON_FLEX_TOKEN , +COMMON_ITEM_TEMPLATE_ID , +COMMON_ACTION_TEMPLATE_ID ,/* TOP-level command. */ ADD,
@@ -73,6 +75,8 @@ enum index {FLOW ,/* Sub-level commands. */ CONFIGURE , +ITEM_TEMPLATE , +ACTION_TEMPLATE ,INDIRECT_ACTION ,VALIDATE , CREATE,
@@ -91,6 +95,22 @@ enum index {FLEX_ITEM_CREATE ,FLEX_ITEM_DESTROY , +/* Item template arguments. */ +ITEM_TEMPLATE_CREATE , +ITEM_TEMPLATE_DESTROY , +ITEM_TEMPLATE_CREATE_ID , +ITEM_TEMPLATE_DESTROY_ID , +ITEM_TEMPLATE_RELAXED_MATCHING , +ITEM_TEMPLATE_SPEC , + +/* Action template arguments. */ +ACTION_TEMPLATE_CREATE , +ACTION_TEMPLATE_DESTROY , +ACTION_TEMPLATE_CREATE_ID , +ACTION_TEMPLATE_DESTROY_ID , +ACTION_TEMPLATE_SPEC , +ACTION_TEMPLATE_MASK , +/* Tunnel arguments. */ TUNNEL_CREATE , TUNNEL_CREATE_TYPE,
@@ -858,6 +878,10 @@ struct buffer {struct rte_flow_port_attr port_attr;struct rte_flow_queue_attr queue_attr; } configure;/**< Configuration arguments. */ +struct { +uint32_t *template_id; +uint32_t template_id_n; + } templ_destroy;/**< Template destroy arguments. */ struct {uint32_t *action_id;uint32_t action_id_n;
@@ -866,10 +890,13 @@ struct buffer {uint32_t action_id; } ia;/* Indirect action query arguments */ struct { +uint32_t it_id; +uint32_t at_id;struct rte_flow_attr attr;struct tunnel_ops tunnel_ops;struct rte_flow_item *pattern;struct rte_flow_action *actions; +struct rte_flow_action *masks;uint32_t pattern_n;uint32_t actions_n;uint8_t *data;
@@ -949,6 +976,43 @@ static const enum index next_config_attr[] = { ZERO, }; +static const enum index next_it_subcmd[] = { +ITEM_TEMPLATE_CREATE , +ITEM_TEMPLATE_DESTROY , +ZERO , +}; + +static const enum index next_it_attr[] = { +ITEM_TEMPLATE_CREATE_ID , +ITEM_TEMPLATE_RELAXED_MATCHING , +ITEM_TEMPLATE_SPEC , +ZERO , +}; + +static const enum index next_it_destroy_attr[] = { +ITEM_TEMPLATE_DESTROY_ID , +END , +ZERO , +}; + +static const enum index next_at_subcmd[] = { +ACTION_TEMPLATE_CREATE , +ACTION_TEMPLATE_DESTROY , +ZERO , +}; + +static const enum index next_at_attr[] = { +ACTION_TEMPLATE_CREATE_ID , +ACTION_TEMPLATE_SPEC , +ZERO , +}; + +static const enum index next_at_destroy_attr[] = { +ACTION_TEMPLATE_DESTROY_ID , +END , +ZERO , +}; +static const enum index next_ia_create_attr[] = {INDIRECT_ACTION_CREATE_ID ,INDIRECT_ACTION_INGRESS ,
@@ -1987,6 +2051,12 @@ static int parse_isolate(struct context *, const struct token *,static int parse_configure (struct context *,const struct token *,const char *,unsigned int ,void *,unsigned int ); +static int parse_template (struct context *,const struct token *, +const char *,unsigned int , +void *,unsigned int ); +static int parse_template_destroy (struct context *,const struct token *, +const char *,unsigned int , +void *,unsigned int );static int parse_tunnel (struct context *,const struct token *,const char *,unsigned int ,void *,unsigned int );
@@ -2056,6 +2126,10 @@ static int comp_set_modify_field_op(struct context *, const struct token *, unsigned int, char *, unsigned int);static int comp_set_modify_field_id (struct context *,const struct token *,unsigned int ,char *,unsigned int ); +static int comp_item_template_id (struct context *,const struct token *, +unsigned int ,char *,unsigned int ); +static int comp_action_template_id (struct context *,const struct token *, +unsigned int ,char *,unsigned int );/** Token definitions. */ static const struct token token_list[] = {
@@ -2206,6 +2280,20 @@ static const struct token token_list[] = { .call = parse_flex_handle, .comp = comp_none, }, + [COMMON_ITEM_TEMPLATE_ID] = { + .name = "{item_template_id}", + .type = "ITEM_TEMPLATE_ID", + .help = "item template id", + .call = parse_int, + .comp = comp_item_template_id, + }, + [COMMON_ACTION_TEMPLATE_ID] = { + .name = "{action_template_id}", + .type = "ACTION_TEMPLATE_ID", + .help = "action template id", + .call = parse_int, + .comp = comp_action_template_id, + },/* Top-level command. */ [FLOW] = { .name = "flow",
@@ -2213,6 +2301,8 @@ static const struct token token_list[] = { .help = "manage ingress/egress flow rules", .next = NEXT(NEXT_ENTRY (CONFIGURE, + ITEM_TEMPLATE, + ACTION_TEMPLATE, INDIRECT_ACTION, VALIDATE, CREATE,
@@ -2278,6 +2368,112 @@ static const struct token token_list[] = { args.configure.port_attr.nb_meters)), },/* Top-level command. */ + [ITEM_TEMPLATE] = { + .name = "item_template", + .type = "{command} {port_id} [{arg} [...]]", + .help = "manage item templates", + .next = NEXT(next_it_subcmd, NEXT_ENTRY(COMMON_PORT_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, port)), + .call = parse_template, + }, +/* Sub-level commands. */ + [ITEM_TEMPLATE_CREATE] = { + .name = "create", + .help = "create item template", + .next = NEXT(next_it_attr), + .call = parse_template, + }, + [ITEM_TEMPLATE_DESTROY] = { + .name = "destroy", + .help = "destroy item template", + .next = NEXT(NEXT_ENTRY(ITEM_TEMPLATE_DESTROY_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, port)), + .call = parse_template_destroy, + }, +/* Item arguments. */ + [ITEM_TEMPLATE_CREATE_ID] = { + .name = "item_template_id", + .help = "specify a item template id to create", + .next =NEXT (next_it_attr, + NEXT_ENTRY(COMMON_ITEM_TEMPLATE_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.it_id)), + }, + [ITEM_TEMPLATE_DESTROY_ID] = { + .name = "item_template", + .help = "specify an item template id to destroy", + .next =NEXT (next_it_destroy_attr, + NEXT_ENTRY(COMMON_ITEM_TEMPLATE_ID)), + .args = ARGS(ARGS_ENTRY_PTR(struct buffer, + args.templ_destroy.template_id)), + .call = parse_template_destroy, + }, + [ITEM_TEMPLATE_RELAXED_MATCHING] = { + .name = "relaxed", + .help = "is matching relaxed", + .next =NEXT (next_it_attr, + NEXT_ENTRY(COMMON_BOOLEAN)), + .args = ARGS(ARGS_ENTRY_BF(struct buffer, + args.vc.attr.reserved, 1)), + }, + [ITEM_TEMPLATE_SPEC] = { + .name = "template", + .help = "specify item to create item template", + .next = NEXT(next_item), + }, +/* Top-level command. */ + [ACTION_TEMPLATE] = { + .name = "action_template", + .type = "{command} {port_id} [{arg} [...]]", + .help = "manage action templates", + .next = NEXT(next_at_subcmd, NEXT_ENTRY(COMMON_PORT_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, port)), + .call = parse_template, + }, +/* Sub-level commands. */ + [ACTION_TEMPLATE_CREATE] = { + .name = "create", + .help = "create action template", + .next = NEXT(next_at_attr), + .call = parse_template, + }, + [ACTION_TEMPLATE_DESTROY] = { + .name = "destroy", + .help = "destroy action template", + .next = NEXT(NEXT_ENTRY(ACTION_TEMPLATE_DESTROY_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, port)), + .call = parse_template_destroy, + }, +/* Action arguments. */ + [ACTION_TEMPLATE_CREATE_ID] = { + .name = "action_template_id", + .help = "specify a action template id to create", + .next =NEXT (NEXT_ENTRY (ACTION_TEMPLATE_MASK ), +NEXT_ENTRY (ACTION_TEMPLATE_SPEC ), + NEXT_ENTRY(COMMON_ACTION_TEMPLATE_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.at_id)), + }, + [ACTION_TEMPLATE_DESTROY_ID] = { + .name = "action_template", + .help = "specify an action template id to destroy", + .next =NEXT (next_at_destroy_attr, + NEXT_ENTRY(COMMON_ACTION_TEMPLATE_ID)), + .args = ARGS(ARGS_ENTRY_PTR(struct buffer, + args.templ_destroy.template_id)), + .call = parse_template_destroy, + }, + [ACTION_TEMPLATE_SPEC] = { + .name = "template", + .help = "specify action to create action template", + .next = NEXT(next_action), + .call = parse_template, + }, + [ACTION_TEMPLATE_MASK] = { + .name = "mask", + .help = "specify action mask to create action template", + .next = NEXT(next_action), + .call = parse_template, + }, +/* Top-level command. */ [INDIRECT_ACTION] = { .name = "indirect_action", .type = "{command} {port_id} [{arg} [...]]",
@@ -2600,7 +2796,7 @@ static const struct token token_list[] = { .name = "end", .help = "end list of pattern items", .priv = PRIV_ITEM(END, 0), - .next = NEXT(NEXT_ENTRY(ACTIONS)), + .next = NEXT(NEXT_ENTRY(ACTIONS, END)), .call = parse_vc, }, [ITEM_VOID] = {
@@ -5704,7 +5900,9 @@ parse_vc(struct context *ctx, const struct token *token,if (!out)return len;if (!out->command) { -if (ctx->curr !=VALIDATE && ctx->curr !=CREATE ) +if (ctx->curr !=VALIDATE && ctx->curr !=CREATE && + ctx->curr !=ITEM_TEMPLATE_CREATE && + ctx->curr !=ACTION_TEMPLATE_CREATE )return -1 ;if (sizeof (*out) > size)return -1 ;
@@ -7568,6 +7766,114 @@ parse_configure(struct context *ctx, const struct token *token,return len; } +/** Parse tokens for template create command. */ +static int +parse_template (struct context *ctx,const struct token *token, +const char *str,unsigned int len, +void *buf,unsigned int size) +{ +struct buffer *out = buf; + +/* Token name must match. */ +if (parse_default (ctx, token, str, len,NULL ,0 ) <0 ) +return -1 ; +/* Nothing else to do if there is no buffer. */ +if (!out) +return len; +if (!out->command) { +if (ctx->curr !=ITEM_TEMPLATE && + ctx->curr !=ACTION_TEMPLATE ) +return -1 ; +if (sizeof (*out) > size) +return -1 ; + out->command = ctx->curr; + ctx->objdata =0 ; + ctx->object = out; + ctx->objmask =NULL ; + out->args.vc.data = (uint8_t *)out + size; +return len; + } +switch (ctx->curr) { +case ITEM_TEMPLATE_CREATE : + out->args.vc.pattern = + (void *)RTE_ALIGN_CEIL ((uintptr_t )(out +1 ), +sizeof (double )); + out->args.vc.it_id =UINT32_MAX ; + out->command = ctx->curr; + ctx->objdata =0 ; + ctx->object = out; + ctx->objmask =NULL ; +return len; +case ACTION_TEMPLATE_CREATE : + out->args.vc.at_id =UINT32_MAX ; + out->command = ctx->curr; + ctx->objdata =0 ; + ctx->object = out; + ctx->objmask =NULL ; +return len; +case ACTION_TEMPLATE_SPEC : + out->args.vc.actions = + (void *)RTE_ALIGN_CEIL ((uintptr_t )(out +1 ), +sizeof (double )); + ctx->object = out->args.vc.actions; + ctx->objmask =NULL ; +return len; +case ACTION_TEMPLATE_MASK : + out->args.vc.masks = + (void *)RTE_ALIGN_CEIL ((uintptr_t ) + (out->args.vc.actions + + out->args.vc.actions_n), +sizeof (double )); + ctx->object = out->args.vc.masks; + ctx->objmask =NULL ; +return len; +default : +return -1 ; + } +} + +/** Parse tokens for template destroy command. */ +static int +parse_template_destroy (struct context *ctx,const struct token *token, +const char *str,unsigned int len, +void *buf,unsigned int size) +{ +struct buffer *out = buf; +uint32_t *template_id; + +/* Token name must match. */ +if (parse_default (ctx, token, str, len,NULL ,0 ) <0 ) +return -1 ; +/* Nothing else to do if there is no buffer. */ +if (!out) +return len; +if (!out->command || + out->command ==ITEM_TEMPLATE || + out->command ==ACTION_TEMPLATE ) { +if (ctx->curr !=ITEM_TEMPLATE_DESTROY && + ctx->curr !=ACTION_TEMPLATE_DESTROY ) +return -1 ; +if (sizeof (*out) > size) +return -1 ; + out->command = ctx->curr; + ctx->objdata =0 ; + ctx->object = out; + ctx->objmask =NULL ; + out->args.templ_destroy.template_id = + (void *)RTE_ALIGN_CEIL ((uintptr_t )(out +1 ), +sizeof (double )); +return len; + } + template_id = out->args.templ_destroy.template_id + + out->args.templ_destroy.template_id_n++; +if ((uint8_t *)template_id > (uint8_t *)out + size) +return -1 ; + ctx->objdata =0 ; + ctx->object = template_id; + ctx->objmask =NULL ; +return len; +} + static int parse_flex(struct context *ctx, const struct token *token, const char *str, unsigned int len,
@@ -8535,6 +8841,54 @@ comp_set_modify_field_id(struct context *ctx, const struct token *token,return -1 ; } +/** Complete available item template IDs. */ +static int +comp_item_template_id (struct context *ctx,const struct token *token, +unsigned int ent,char *buf,unsigned int size) +{ +unsigned int i =0 ; +struct rte_port *port; +struct port_template *pt; + + (void )token; +if (port_id_is_invalid (ctx->port,DISABLED_WARN ) || + ctx->port == (portid_t )RTE_PORT_ALL ) +return -1 ; + port = &ports[ctx->port]; +for (pt = port->item_templ_list; pt !=NULL ; pt = pt->next) { +if (buf && i == ent) +return snprintf (buf, size,"%u" , pt->id); + ++i; + } +if (buf) +return -1 ; +return i; +} + +/** Complete available iaction template IDs. */ +static int +comp_action_template_id (struct context *ctx,const struct token *token, +unsigned int ent,char *buf,unsigned int size) +{ +unsigned int i =0 ; +struct rte_port *port; +struct port_template *pt; + + (void )token; +if (port_id_is_invalid (ctx->port,DISABLED_WARN ) || + ctx->port == (portid_t )RTE_PORT_ALL ) +return -1 ; + port = &ports[ctx->port]; +for (pt = port->action_templ_list; pt !=NULL ; pt = pt->next) { +if (buf && i == ent) +return snprintf (buf, size,"%u" , pt->id); + ++i; + } +if (buf) +return -1 ; +return i; +} +/** Internal context. */ static struct context cmd_flow_context;
@@ -8798,6 +9152,24 @@ cmd_flow_parsed(const struct buffer *in)port_flow_configure (in->port, &in->args.configure.port_attr, &in->args.configure.queue_attr);break ; +case ITEM_TEMPLATE_CREATE : +port_flow_item_template_create (in->port, in->args.vc.it_id, + in->args.vc.attr.reserved, in->args.vc.pattern); +break ; +case ITEM_TEMPLATE_DESTROY : +port_flow_item_template_destroy (in->port, + in->args.templ_destroy.template_id_n, + in->args.templ_destroy.template_id); +break ; +case ACTION_TEMPLATE_CREATE : +port_flow_action_template_create (in->port, in->args.vc.at_id, + in->args.vc.actions, in->args.vc.masks); +break ; +case ACTION_TEMPLATE_DESTROY : +port_flow_action_template_destroy (in->port, + in->args.templ_destroy.template_id_n, + in->args.templ_destroy.template_id); +break ;case INDIRECT_ACTION_CREATE : port_action_handle_create( in->port, in->args.vc.attr.group,
app/test-pmd/config.c +204 -0
216 lines not on this page · raw message
app/test-pmd/testpmd.h +22 -0
@@ -166,6 +166,17 @@ enum age_action_context_type { ACTION_AGE_CONTEXT_TYPE_INDIRECT_ACTION, }; +/** Descriptor for a template. */ +struct port_template { +struct port_template *next;/**< Next template in list. */ +struct port_template *tmp;/**< Temporary linking. */ +uint32_t id;/**< Template ID. */ +union { +struct rte_flow_item_template *itempl; +struct rte_flow_action_template *atempl; + } template;/**< PMD opaque template object */ +}; +/** Descriptor for a single flow. */ struct port_flow {struct port_flow *next;/**< Next flow in list. */
@@ -246,6 +257,8 @@ struct rte_port {queueid_t queue_nb;/**< nb. of queues for flow rules */ uint32_t queue_sz;/**< size of a queue for flow rules */ uint8_t slave_flag;/**< bonding slave port */ +struct port_template *item_templ_list;/**< Item templates. */ +struct port_template *action_templ_list;/**< Action templates. */ struct port_flow *flow_list;/**< Associated flows. */ struct port_indirect_action *actions_list;/**< Associated indirect actions. */
@@ -890,6 +903,15 @@ int port_action_handle_update(portid_t port_id, uint32_t id,int port_flow_configure (portid_t port_id,const struct rte_flow_port_attr *port_attr,const struct rte_flow_queue_attr *queue_attr); +int port_flow_item_template_create (portid_t port_id,uint32_t id,bool relaxed, +const struct rte_flow_item *pattern); +int port_flow_item_template_destroy (portid_t port_id,uint32_t n, +const uint32_t *template); +int port_flow_action_template_create (portid_t port_id,uint32_t id, +const struct rte_flow_action *actions, +const struct rte_flow_action *masks); +int port_flow_action_template_destroy (portid_t port_id,uint32_t n, +const uint32_t *template); int port_flow_validate(portid_t port_id, const struct rte_flow_attr *attr, const struct rte_flow_item *pattern,
doc/guides/testpmd_app_ug/testpmd_funcs.rst +97 -0
109 lines not on this page · raw message
Signature · 1 line
2.18.2
PATCH v2 6/10 app/testpmd: implement rte flow table
In reply to Alexander KozyrevAdd testpmd support for the rte_flow_table API. Provide the command line interface for the flow table creation/destruction. Usage example:
testpmd> flow table 0 create table_id 6
group 9 priority 4 ingress mode 1 rules_number 64 item_template 2 action_template 4
testpmd> flow table 0 destroy table 6
--- app/test-pmd/cmdline_flow.c | 315 ++++++++++++++++++++ app/test-pmd/config.c | 168 +++++++++++ app/test-pmd/testpmd.h | 15 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 53 ++++ 4 files changed, 551 insertions(+)
app/test-pmd/cmdline_flow.c +315 -0
@@ -58,6 +58,7 @@ enum index {COMMON_FLEX_TOKEN ,COMMON_ITEM_TEMPLATE_ID ,COMMON_ACTION_TEMPLATE_ID , +COMMON_TABLE_ID ,/* TOP-level command. */ ADD,
@@ -77,6 +78,7 @@ enum index {CONFIGURE ,ITEM_TEMPLATE ,ACTION_TEMPLATE , +TABLE ,INDIRECT_ACTION ,VALIDATE , CREATE,
@@ -111,6 +113,20 @@ enum index {ACTION_TEMPLATE_SPEC ,ACTION_TEMPLATE_MASK , +/* Table arguments. */ +TABLE_CREATE , +TABLE_DESTROY , +TABLE_CREATE_ID , +TABLE_DESTROY_ID , +TABLE_GROUP , +TABLE_PRIORITY , +TABLE_INGRESS , +TABLE_EGRESS , +TABLE_TRANSFER , +TABLE_RULES_NUMBER , +TABLE_ITEM_TEMPLATE , +TABLE_ACTION_TEMPLATE , +/* Tunnel arguments. */ TUNNEL_CREATE , TUNNEL_CREATE_TYPE,
@@ -882,6 +898,18 @@ struct buffer {uint32_t *template_id;uint32_t template_id_n; } templ_destroy;/**< Template destroy arguments. */ +struct { +uint32_t id; +struct rte_flow_table_attr attr; +uint32_t *item_id; +uint32_t item_id_n; +uint32_t *action_id; +uint32_t action_id_n; + } table;/**< Table arguments. */ +struct { +uint32_t *table_id; +uint32_t table_id_n; + } table_destroy;/**< Template destroy arguments. */ struct {uint32_t *action_id;uint32_t action_id_n;
@@ -1013,6 +1041,32 @@ static const enum index next_at_destroy_attr[] = { ZERO, }; +static const enum index next_table_subcmd[] = { +TABLE_CREATE , +TABLE_DESTROY , +ZERO , +}; + +static const enum index next_table_attr[] = { +TABLE_CREATE_ID , +TABLE_GROUP , +TABLE_PRIORITY , +TABLE_INGRESS , +TABLE_EGRESS , +TABLE_TRANSFER , +TABLE_RULES_NUMBER , +TABLE_ITEM_TEMPLATE , +TABLE_ACTION_TEMPLATE , +END , +ZERO , +}; + +static const enum index next_table_destroy_attr[] = { +TABLE_DESTROY_ID , +END , +ZERO , +}; +static const enum index next_ia_create_attr[] = {INDIRECT_ACTION_CREATE_ID ,INDIRECT_ACTION_INGRESS ,
@@ -2057,6 +2111,11 @@ static int parse_template(struct context *, const struct token *,static int parse_template_destroy (struct context *,const struct token *,const char *,unsigned int ,void *,unsigned int ); +static int parse_table (struct context *,const struct token *, +const char *,unsigned int ,void *,unsigned int ); +static int parse_table_destroy (struct context *,const struct token *, +const char *,unsigned int , +void *,unsigned int );static int parse_tunnel (struct context *,const struct token *,const char *,unsigned int ,void *,unsigned int );
@@ -2130,6 +2189,8 @@ static int comp_item_template_id(struct context *, const struct token *, unsigned int, char *, unsigned int);static int comp_action_template_id (struct context *,const struct token *,unsigned int ,char *,unsigned int ); +static int comp_table_id (struct context *,const struct token *, +unsigned int ,char *,unsigned int );/** Token definitions. */ static const struct token token_list[] = {
@@ -2294,6 +2355,13 @@ static const struct token token_list[] = { .call = parse_int, .comp = comp_action_template_id, }, + [COMMON_TABLE_ID] = { + .name = "{table_id}", + .type = "TABLE_ID", + .help = "table id", + .call = parse_int, + .comp = comp_table_id, + },/* Top-level command. */ [FLOW] = { .name = "flow",
@@ -2303,6 +2371,7 @@ static const struct token token_list[] = { (CONFIGURE ,ITEM_TEMPLATE ,ACTION_TEMPLATE , +TABLE ,INDIRECT_ACTION ,VALIDATE , CREATE,
@@ -2474,6 +2543,104 @@ static const struct token token_list[] = { .call = parse_template, },/* Top-level command. */ + [TABLE] = { + .name = "table", + .type = "{command} {port_id} [{arg} [...]]", + .help = "manage tables", + .next = NEXT(next_table_subcmd, NEXT_ENTRY(COMMON_PORT_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, port)), + .call = parse_table, + }, +/* Sub-level commands. */ + [TABLE_CREATE] = { + .name = "create", + .help = "create table", + .next = NEXT(next_table_attr), + .call = parse_table, + }, + [TABLE_DESTROY] = { + .name = "destroy", + .help = "destroy table", + .next = NEXT(NEXT_ENTRY(TABLE_DESTROY_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, port)), + .call = parse_table_destroy, + }, +/* Table arguments. */ + [TABLE_CREATE_ID] = { + .name = "table_id", + .help = "specify table id to create", + .next =NEXT (next_table_attr, + NEXT_ENTRY(COMMON_TABLE_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, args.table.id)), + }, + [TABLE_DESTROY_ID] = { + .name = "table", + .help = "specify table id to destroy", + .next =NEXT (next_table_destroy_attr, + NEXT_ENTRY(COMMON_TABLE_ID)), + .args = ARGS(ARGS_ENTRY_PTR(struct buffer, + args.table_destroy.table_id)), + .call = parse_table_destroy, + }, + [TABLE_GROUP] = { + .name = "group", + .help = "specify a group", + .next = NEXT(next_table_attr, NEXT_ENTRY(COMMON_GROUP_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, + args.table.attr.flow_attr.group)), + }, + [TABLE_PRIORITY] = { + .name = "priority", + .help = "specify a priority level", + .next = NEXT(next_table_attr, NEXT_ENTRY(COMMON_PRIORITY_LEVEL)), + .args = ARGS(ARGS_ENTRY(struct buffer, + args.table.attr.flow_attr.priority)), + }, + [TABLE_EGRESS] = { + .name = "egress", + .help = "affect rule to egress", + .next = NEXT(next_table_attr), + .call = parse_table, + }, + [TABLE_INGRESS] = { + .name = "ingress", + .help = "affect rule to ingress", + .next = NEXT(next_table_attr), + .call = parse_table, + }, + [TABLE_TRANSFER] = { + .name = "transfer", + .help = "affect rule to transfer", + .next = NEXT(next_table_attr), + .call = parse_table, + }, + [TABLE_RULES_NUMBER] = { + .name = "rules_number", + .help = "number of rules in table", + .next =NEXT (next_table_attr, + NEXT_ENTRY(COMMON_UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct buffer, + args.table.attr.nb_flows)), + }, + [TABLE_ITEM_TEMPLATE] = { + .name = "item_template", + .help = "specify item template id", + .next =NEXT (next_table_attr, + NEXT_ENTRY(COMMON_ITEM_TEMPLATE_ID)), + .args = ARGS(ARGS_ENTRY_PTR(struct buffer, + args.table.item_id)), + .call = parse_table, + }, + [TABLE_ACTION_TEMPLATE] = { + .name = "action_template", + .help = "specify action template id", + .next =NEXT (next_table_attr, + NEXT_ENTRY(COMMON_ACTION_TEMPLATE_ID)), + .args = ARGS(ARGS_ENTRY_PTR(struct buffer, + args.table.action_id)), + .call = parse_table, + }, +/* Top-level command. */ [INDIRECT_ACTION] = { .name = "indirect_action", .type = "{command} {port_id} [{arg} [...]]",
@@ -7874,6 +8041,119 @@ parse_template_destroy(struct context *ctx, const struct token *token,return len; } +/** Parse tokens for indirect action commands. */ +static int +parse_table (struct context *ctx,const struct token *token, +const char *str,unsigned int len, +void *buf,unsigned int size) +{ +struct buffer *out = buf; +uint32_t *template_id; + +/* Token name must match. */ +if (parse_default (ctx, token, str, len,NULL ,0 ) <0 ) +return -1 ; +/* Nothing else to do if there is no buffer. */ +if (!out) +return len; +if (!out->command) { +if (ctx->curr !=TABLE ) +return -1 ; +if (sizeof (*out) > size) +return -1 ; + out->command = ctx->curr; + ctx->objdata =0 ; + ctx->object = out; + ctx->objmask =NULL ; +return len; + } +switch (ctx->curr) { +case TABLE_CREATE : + out->command = ctx->curr; + ctx->objdata =0 ; + ctx->object = out; + ctx->objmask =NULL ; + out->args.table.id =UINT32_MAX ; +return len; +case TABLE_ITEM_TEMPLATE : + out->args.table.item_id = + (void *)RTE_ALIGN_CEIL ((uintptr_t )(out +1 ), +sizeof (double )); + template_id = out->args.table.item_id + + out->args.table.item_id_n++; +if ((uint8_t *)template_id > (uint8_t *)out + size) +return -1 ; + ctx->objdata =0 ; + ctx->object = template_id; + ctx->objmask =NULL ; +return len; +case TABLE_ACTION_TEMPLATE : + out->args.table.action_id = + (void *)RTE_ALIGN_CEIL ((uintptr_t ) + (out->args.table.item_id + + out->args.table.item_id_n), +sizeof (double )); + template_id = out->args.table.action_id + + out->args.table.action_id_n++; +if ((uint8_t *)template_id > (uint8_t *)out + size) +return -1 ; + ctx->objdata =0 ; + ctx->object = template_id; + ctx->objmask =NULL ; +return len; +case TABLE_INGRESS : + out->args.table.attr.flow_attr.ingress =1 ; +return len; +case TABLE_EGRESS : + out->args.table.attr.flow_attr.egress =1 ; +return len; +case TABLE_TRANSFER : + out->args.table.attr.flow_attr.transfer =1 ; +return len; +default : +return -1 ; + } +} + +/** Parse tokens for indirect action destroy command. */ +static int +parse_table_destroy (struct context *ctx,const struct token *token, +const char *str,unsigned int len, +void *buf,unsigned int size) +{ +struct buffer *out = buf; +uint32_t *table_id; + +/* Token name must match. */ +if (parse_default (ctx, token, str, len,NULL ,0 ) <0 ) +return -1 ; +/* Nothing else to do if there is no buffer. */ +if (!out) +return len; +if (!out->command || out->command ==TABLE ) { +if (ctx->curr !=TABLE_DESTROY ) +return -1 ; +if (sizeof (*out) > size) +return -1 ; + out->command = ctx->curr; + ctx->objdata =0 ; + ctx->object = out; + ctx->objmask =NULL ; + out->args.table_destroy.table_id = + (void *)RTE_ALIGN_CEIL ((uintptr_t )(out +1 ), +sizeof (double )); +return len; + } + table_id = out->args.table_destroy.table_id + + out->args.table_destroy.table_id_n++; +if ((uint8_t *)table_id > (uint8_t *)out + size) +return -1 ; + ctx->objdata =0 ; + ctx->object = table_id; + ctx->objmask =NULL ; +return len; +} + static int parse_flex(struct context *ctx, const struct token *token, const char *str, unsigned int len,
@@ -8889,6 +9169,30 @@ comp_action_template_id(struct context *ctx, const struct token *token,return i; } +/** Complete available table IDs. */ +static int +comp_table_id (struct context *ctx,const struct token *token, +unsigned int ent,char *buf,unsigned int size) +{ +unsigned int i =0 ; +struct rte_port *port; +struct port_table *pt; + + (void )token; +if (port_id_is_invalid (ctx->port,DISABLED_WARN ) || + ctx->port == (portid_t )RTE_PORT_ALL ) +return -1 ; + port = &ports[ctx->port]; +for (pt = port->table_list; pt !=NULL ; pt = pt->next) { +if (buf && i == ent) +return snprintf (buf, size,"%u" , pt->id); + ++i; + } +if (buf) +return -1 ; +return i; +} +/** Internal context. */ static struct context cmd_flow_context;
@@ -9170,6 +9474,17 @@ cmd_flow_parsed(const struct buffer *in) in->args.templ_destroy.template_id_n, in->args.templ_destroy.template_id);break ; +case TABLE_CREATE : +port_flow_table_create (in->port, in->args.table.id, + &in->args.table.attr, in->args.table.item_id_n, + in->args.table.item_id, in->args.table.action_id_n, + in->args.table.action_id); +break ; +case TABLE_DESTROY : +port_flow_table_destroy (in->port, + in->args.table_destroy.table_id_n, + in->args.table_destroy.table_id); +break ;case INDIRECT_ACTION_CREATE : port_action_handle_create( in->port, in->args.vc.attr.group,
app/test-pmd/config.c +168 -0
180 lines not on this page · raw message
app/test-pmd/testpmd.h +15 -0
@@ -177,6 +177,14 @@ struct port_template { } template;/**< PMD opaque template object */ }; +/** Descriptor for a flow table. */ +struct port_table { +struct port_table *next;/**< Next table in list. */ +struct port_table *tmp;/**< Temporary linking. */ +uint32_t id;/**< Table ID. */ +struct rte_flow_table *table;/**< PMD opaque template object */ +}; +/** Descriptor for a single flow. */ struct port_flow {struct port_flow *next;/**< Next flow in list. */
@@ -259,6 +267,7 @@ struct rte_port {uint8_t slave_flag;/**< bonding slave port */ struct port_template *item_templ_list;/**< Item templates. */ struct port_template *action_templ_list;/**< Action templates. */ +struct port_table *table_list;/**< Flow tables. */ struct port_flow *flow_list;/**< Associated flows. */ struct port_indirect_action *actions_list;/**< Associated indirect actions. */
@@ -912,6 +921,12 @@ int port_flow_action_template_create(portid_t port_id, uint32_t id, const struct rte_flow_action *masks);int port_flow_action_template_destroy (portid_t port_id,uint32_t n,const uint32_t *template); +int port_flow_table_create (portid_t port_id,uint32_t id, +const struct rte_flow_table_attr *table_attr, +uint32_t nb_item_templates,uint32_t *item_templates, +uint32_t nb_action_templates,uint32_t *action_templates); +int port_flow_table_destroy (portid_t port_id, +uint32_t n,const uint32_t *table); int port_flow_validate(portid_t port_id, const struct rte_flow_attr *attr, const struct rte_flow_item *pattern,
doc/guides/testpmd_app_ug/testpmd_funcs.rst +53 -0
65 lines not on this page · raw message
Signature · 1 line
2.18.2
PATCH v2 7/10 app/testpmd: implement rte flow queue create flow
In reply to Alexander KozyrevAdd testpmd support for the rte_flow_q_create/rte_flow_q_destroy API. Provide the command line interface for enqueueing flow creation/destruction operations. Usage example:
testpmd> flow queue 0 create 0 drain yes table 6
item_template 0 action_template 0
pattern eth dst is 00:16:3e:31:15:c3 / end actions drop / end
testpmd> flow queue 0 destroy 0 drain yes rule 0
--- app/test-pmd/cmdline_flow.c | 266 +++++++++++++++++++- app/test-pmd/config.c | 153 +++++++++++ app/test-pmd/testpmd.h | 7 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 55 ++++ 4 files changed, 480 insertions(+), 1 deletion(-)
app/test-pmd/cmdline_flow.c +265 -1
@@ -59,6 +59,7 @@ enum index {COMMON_ITEM_TEMPLATE_ID ,COMMON_ACTION_TEMPLATE_ID ,COMMON_TABLE_ID , +COMMON_QUEUE_ID ,/* TOP-level command. */ ADD,
@@ -91,6 +92,7 @@ enum index {ISOLATE ,TUNNEL ,FLEX , +QUEUE ,/* Flex arguments */ FLEX_ITEM_INIT,
@@ -113,6 +115,22 @@ enum index {ACTION_TEMPLATE_SPEC ,ACTION_TEMPLATE_MASK , +/* Queue arguments. */ +QUEUE_CREATE , +QUEUE_DESTROY , + +/* Queue create arguments. */ +QUEUE_CREATE_ID , +QUEUE_CREATE_DRAIN , +QUEUE_TABLE , +QUEUE_ITEM_TEMPLATE , +QUEUE_ACTION_TEMPLATE , +QUEUE_SPEC , + +/* Queue destroy arguments. */ +QUEUE_DESTROY_ID , +QUEUE_DESTROY_DRAIN , +/* Table arguments. */ TABLE_CREATE , TABLE_DESTROY,
@@ -889,6 +907,8 @@ struct token { struct buffer { enum index command; /**< Flow command. */ portid_t port; /**< Affected port ID. */ + queueid_t queue; /** Async queue ID. */ + bool drain; /** Drain the queue on async oparation */ union { struct { struct rte_flow_port_attr port_attr;
@@ -918,6 +938,7 @@ struct buffer {uint32_t action_id; } ia;/* Indirect action query arguments */ struct { +uint32_t table_id;uint32_t it_id;uint32_t at_id;struct rte_flow_attr attr;
@@ -1067,6 +1088,18 @@ static const enum index next_table_destroy_attr[] = { ZERO, }; +static const enum index next_queue_subcmd[] = { +QUEUE_CREATE , +QUEUE_DESTROY , +ZERO , +}; + +static const enum index next_queue_destroy_attr[] = { +QUEUE_DESTROY_ID , +END , +ZERO , +}; +static const enum index next_ia_create_attr[] = {INDIRECT_ACTION_CREATE_ID ,INDIRECT_ACTION_INGRESS ,
@@ -2116,6 +2149,12 @@ static int parse_table(struct context *, const struct token *,static int parse_table_destroy (struct context *,const struct token *,const char *,unsigned int ,void *,unsigned int ); +static int parse_qo (struct context *,const struct token *, +const char *,unsigned int , +void *,unsigned int ); +static int parse_qo_destroy (struct context *,const struct token *, +const char *,unsigned int , +void *,unsigned int );static int parse_tunnel (struct context *,const struct token *,const char *,unsigned int ,void *,unsigned int );
@@ -2191,6 +2230,8 @@ static int comp_action_template_id(struct context *, const struct token *, unsigned int, char *, unsigned int);static int comp_table_id (struct context *,const struct token *,unsigned int ,char *,unsigned int ); +static int comp_queue_id (struct context *,const struct token *, +unsigned int ,char *,unsigned int );/** Token definitions. */ static const struct token token_list[] = {
@@ -2362,6 +2403,13 @@ static const struct token token_list[] = { .call = parse_int, .comp = comp_table_id, }, + [COMMON_QUEUE_ID] = { + .name = "{queue_id}", + .type = "QUEUE_ID", + .help = "queue id", + .call = parse_int, + .comp = comp_queue_id, + },/* Top-level command. */ [FLOW] = { .name = "flow",
@@ -2383,7 +2431,8 @@ static const struct token token_list[] = { QUERY,ISOLATE ,TUNNEL , - FLEX)), +FLEX , + QUEUE)), .call = parse_init, },/* Top-level command. */
@@ -2641,6 +2690,83 @@ static const struct token token_list[] = { .call = parse_table, },/* Top-level command. */ + [QUEUE] = { + .name = "queue", + .help = "queue a flow rule operation", + .next = NEXT(next_queue_subcmd, NEXT_ENTRY(COMMON_PORT_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, port)), + .call = parse_qo, + }, +/* Sub-level commands. */ + [QUEUE_CREATE] = { + .name = "create", + .help = "create a flow rule", + .next = NEXT(NEXT_ENTRY(QUEUE_TABLE), NEXT_ENTRY(COMMON_QUEUE_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, queue)), + .call = parse_qo, + }, + [QUEUE_DESTROY] = { + .name = "destroy", + .help = "destroy a flow rule", + .next =NEXT (NEXT_ENTRY (QUEUE_DESTROY_ID ), + NEXT_ENTRY(COMMON_QUEUE_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, queue)), + .call = parse_qo_destroy, + }, +/* Queue arguments. */ + [QUEUE_TABLE] = { + .name = "table", + .help = "specify table id", + .next =NEXT (NEXT_ENTRY (QUEUE_ITEM_TEMPLATE ), + NEXT_ENTRY(COMMON_TABLE_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, + args.vc.table_id)), + .call = parse_qo, + }, + [QUEUE_ITEM_TEMPLATE] = { + .name = "item_template", + .help = "specify item template id", + .next =NEXT (NEXT_ENTRY (QUEUE_ACTION_TEMPLATE ), + NEXT_ENTRY(COMMON_ITEM_TEMPLATE_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, + args.vc.it_id)), + .call = parse_qo, + }, + [QUEUE_ACTION_TEMPLATE] = { + .name = "action_template", + .help = "specify action template id", + .next =NEXT (NEXT_ENTRY (QUEUE_CREATE_DRAIN ), + NEXT_ENTRY(COMMON_ACTION_TEMPLATE_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, + args.vc.at_id)), + .call = parse_qo, + }, + [QUEUE_CREATE_DRAIN] = { + .name = "drain", + .help = "drain queue immediately", + .next =NEXT (NEXT_ENTRY (ITEM_PATTERN ), + NEXT_ENTRY(COMMON_BOOLEAN)), + .args = ARGS(ARGS_ENTRY(struct buffer, drain)), + .call = parse_qo, + }, + [QUEUE_DESTROY_DRAIN] = { + .name = "drain", + .help = "drain queue immediately", + .next =NEXT (NEXT_ENTRY (QUEUE_DESTROY_ID ), + NEXT_ENTRY(COMMON_BOOLEAN)), + .args = ARGS(ARGS_ENTRY(struct buffer, drain)), + .call = parse_qo_destroy, + }, + [QUEUE_DESTROY_ID] = { + .name = "rule", + .help = "specify rule id to destroy", + .next =NEXT (next_queue_destroy_attr, + NEXT_ENTRY(COMMON_UNSIGNED)), + .args = ARGS(ARGS_ENTRY_PTR(struct buffer, + args.destroy.rule)), + .call = parse_qo_destroy, + }, +/* Top-level command. */ [INDIRECT_ACTION] = { .name = "indirect_action", .type = "{command} {port_id} [{arg} [...]]",
@@ -8154,6 +8280,111 @@ parse_table_destroy(struct context *ctx, const struct token *token,return len; } +/** Parse tokens for queue create commands. */ +static int +parse_qo (struct context *ctx,const struct token *token, +const char *str,unsigned int len, +void *buf,unsigned int size) +{ +struct buffer *out = buf; + +/* Token name must match. */ +if (parse_default (ctx, token, str, len,NULL ,0 ) <0 ) +return -1 ; +/* Nothing else to do if there is no buffer. */ +if (!out) +return len; +if (!out->command) { +if (ctx->curr !=QUEUE ) +return -1 ; +if (sizeof (*out) > size) +return -1 ; + out->command = ctx->curr; + ctx->objdata =0 ; + ctx->object = out; + ctx->objmask =NULL ; + out->args.vc.data = (uint8_t *)out + size; +return len; + } +switch (ctx->curr) { +case QUEUE_CREATE : + out->command = ctx->curr; + ctx->objdata =0 ; + ctx->object = out; + ctx->objmask =NULL ; +return len; +case QUEUE_TABLE : +case QUEUE_ITEM_TEMPLATE : +case QUEUE_ACTION_TEMPLATE : +case QUEUE_CREATE_DRAIN : +return len; +case ITEM_PATTERN : + out->args.vc.pattern = + (void *)RTE_ALIGN_CEIL ((uintptr_t )(out +1 ), +sizeof (double )); + ctx->object = out->args.vc.pattern; + ctx->objmask =NULL ; +return len; +case ACTIONS : + out->args.vc.actions = + (void *)RTE_ALIGN_CEIL ((uintptr_t ) + (out->args.vc.pattern + + out->args.vc.pattern_n), +sizeof (double )); + ctx->object = out->args.vc.actions; + ctx->objmask =NULL ; +return len; +default : +return -1 ; + } +} + +/** Parse tokens for queue destroy command. */ +static int +parse_qo_destroy (struct context *ctx,const struct token *token, +const char *str,unsigned int len, +void *buf,unsigned int size) +{ +struct buffer *out = buf; +uint32_t *flow_id; + +/* Token name must match. */ +if (parse_default (ctx, token, str, len,NULL ,0 ) <0 ) +return -1 ; +/* Nothing else to do if there is no buffer. */ +if (!out) +return len; +if (!out->command || out->command ==QUEUE ) { +if (ctx->curr !=QUEUE_DESTROY ) +return -1 ; +if (sizeof (*out) > size) +return -1 ; + out->command = ctx->curr; + ctx->objdata =0 ; + ctx->object = out; + ctx->objmask =NULL ; + out->args.destroy.rule = + (void *)RTE_ALIGN_CEIL ((uintptr_t )(out +1 ), +sizeof (double )); +return len; + } +switch (ctx->curr) { +case QUEUE_DESTROY_ID : + flow_id = out->args.destroy.rule + + out->args.destroy.rule_n++; +if ((uint8_t *)flow_id > (uint8_t *)out + size) +return -1 ; + ctx->objdata =0 ; + ctx->object = flow_id; + ctx->objmask =NULL ; +return len; +case QUEUE_DESTROY_DRAIN : +return len; +default : +return -1 ; + } +} + static int parse_flex(struct context *ctx, const struct token *token, const char *str, unsigned int len,
@@ -9193,6 +9424,28 @@ comp_table_id(struct context *ctx, const struct token *token,return i; } +/** Complete available queue IDs. */ +static int +comp_queue_id (struct context *ctx,const struct token *token, +unsigned int ent,char *buf,unsigned int size) +{ +unsigned int i =0 ; +struct rte_port *port; + + (void )token; +if (port_id_is_invalid (ctx->port,DISABLED_WARN ) || + ctx->port == (portid_t )RTE_PORT_ALL ) +return -1 ; + port = &ports[ctx->port]; +for (i =0 ; i < port->queue_nb; i++) { +if (buf && i == ent) +return snprintf (buf, size,"%u" , i); + } +if (buf) +return -1 ; +return i; +} +/** Internal context. */ static struct context cmd_flow_context;
@@ -9485,6 +9738,17 @@ cmd_flow_parsed(const struct buffer *in) in->args.table_destroy.table_id_n, in->args.table_destroy.table_id);break ; +case QUEUE_CREATE : +port_queue_flow_create (in->port, in->queue, in->drain, + in->args.vc.table_id, in->args.vc.it_id, + in->args.vc.at_id, in->args.vc.pattern, + in->args.vc.actions); +break ; +case QUEUE_DESTROY : +port_queue_flow_destroy (in->port, in->queue, in->drain, + in->args.destroy.rule_n, + in->args.destroy.rule); +break ;case INDIRECT_ACTION_CREATE : port_action_handle_create( in->port, in->args.vc.attr.group,
app/test-pmd/config.c +153 -0
159 lines not on this page · raw message
app/test-pmd/testpmd.h +7 -0
@@ -927,6 +927,13 @@ int port_flow_table_create(portid_t port_id, uint32_t id, uint32_t nb_action_templates, uint32_t *action_templates);int port_flow_table_destroy (portid_t port_id,uint32_t n,const uint32_t *table); +int port_queue_flow_create (portid_t port_id,queueid_t queue_id, +bool drain,uint32_t table_id, +uint32_t item_id,uint32_t action_id, +const struct rte_flow_item *pattern, +const struct rte_flow_action *actions); +int port_queue_flow_destroy (portid_t port_id,queueid_t queue_id, +bool drain,uint32_t n,const uint32_t *rule); int port_flow_validate(portid_t port_id, const struct rte_flow_attr *attr, const struct rte_flow_item *pattern,
doc/guides/testpmd_app_ug/testpmd_funcs.rst +55 -0
73 lines not on this page · raw message
Signature · 1 line
2.18.2
PATCH v2 8/10 app/testpmd: implement rte flow queue drain
In reply to Alexander KozyrevAdd testpmd support for the rte_flow_q_drain API. Provide the command line interface for the queue draining. Usage example: flow queue 0 drain 0
--- app/test-pmd/cmdline_flow.c | 56 ++++++++++++++++++++- app/test-pmd/config.c | 28 +++++++++++ app/test-pmd/testpmd.h | 1 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 21 ++++++++ 4 files changed, 105 insertions(+), 1 deletion(-)
app/test-pmd/cmdline_flow.c +55 -1
@@ -93,6 +93,7 @@ enum index {TUNNEL ,FLEX ,QUEUE , +DRAIN ,/* Flex arguments */ FLEX_ITEM_INIT,
@@ -131,6 +132,9 @@ enum index {QUEUE_DESTROY_ID ,QUEUE_DESTROY_DRAIN , +/* Drain arguments. */ +DRAIN_QUEUE , +/* Table arguments. */ TABLE_CREATE , TABLE_DESTROY,
@@ -2155,6 +2159,9 @@ static int parse_qo(struct context *, const struct token *,static int parse_qo_destroy (struct context *,const struct token *,const char *,unsigned int ,void *,unsigned int ); +static int parse_drain (struct context *,const struct token *, +const char *,unsigned int , +void *,unsigned int );static int parse_tunnel (struct context *,const struct token *,const char *,unsigned int ,void *,unsigned int );
@@ -2432,7 +2439,8 @@ static const struct token token_list[] = { ISOLATE,TUNNEL ,FLEX , - QUEUE)), +QUEUE , + DRAIN)), .call = parse_init, },/* Top-level command. */
@@ -2767,6 +2775,21 @@ static const struct token token_list[] = { .call = parse_qo_destroy, },/* Top-level command. */ + [DRAIN] = { + .name = "drain", + .help = "drain a flow queue", + .next = NEXT(NEXT_ENTRY(DRAIN_QUEUE), NEXT_ENTRY(COMMON_PORT_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, port)), + .call = parse_drain, + }, +/* Sub-level commands. */ + [DRAIN_QUEUE] = { + .name = "queue", + .help = "specify queue id", + .next = NEXT(NEXT_ENTRY(END), NEXT_ENTRY(COMMON_QUEUE_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, queue)), + }, +/* Top-level command. */ [INDIRECT_ACTION] = { .name = "indirect_action", .type = "{command} {port_id} [{arg} [...]]",
@@ -8385,6 +8408,34 @@ parse_qo_destroy(struct context *ctx, const struct token *token, } } +/** Parse tokens for drain queue command. */ +static int +parse_drain (struct context *ctx,const struct token *token, +const char *str,unsigned int len, +void *buf,unsigned int size) +{ +struct buffer *out = buf; + +/* Token name must match. */ +if (parse_default (ctx, token, str, len,NULL ,0 ) <0 ) +return -1 ; +/* Nothing else to do if there is no buffer. */ +if (!out) +return len; +if (!out->command) { +if (ctx->curr !=DRAIN ) +return -1 ; +if (sizeof (*out) > size) +return -1 ; + out->command = ctx->curr; + ctx->objdata =0 ; + ctx->object = out; + ctx->objmask =NULL ; + out->args.vc.data = (uint8_t *)out + size; + } +return len; +} + static int parse_flex(struct context *ctx, const struct token *token, const char *str, unsigned int len,
@@ -9749,6 +9800,9 @@ cmd_flow_parsed(const struct buffer *in) in->args.destroy.rule_n, in->args.destroy.rule);break ; +case DRAIN : +port_queue_flow_drain (in->port, in->queue); +break ;case INDIRECT_ACTION_CREATE : port_action_handle_create( in->port, in->args.vc.attr.group,
app/test-pmd/config.c +28 -0
@@ -2564,6 +2564,34 @@ port_queue_flow_destroy(portid_t port_id, queueid_t queue_id,return ret; } +/** Drain all the queue operations down the queue. */ +int +port_queue_flow_drain (portid_t port_id,queueid_t queue_id) +{ +struct rte_port *port; +struct rte_flow_error error; +int ret =0 ; + +if (port_id_is_invalid (port_id,ENABLED_WARN ) || + port_id == (portid_t )RTE_PORT_ALL ) +return -EINVAL ; + port = &ports[port_id]; + +if (queue_id >= port->queue_nb) { +printf ("Queue #%u is invalid\n" , queue_id); +return -EINVAL ; + } + +memset (&error,0x55 ,sizeof (error)); + ret =rte_flow_q_drain (port_id, queue_id, &error); +if (ret <0 ) { +printf ("Failed to drain queue\n" ); +return -EINVAL ; + } +printf ("Queue #%u drained\n" , queue_id); +return ret; +} +/** Create flow rule. */ int port_flow_create(portid_t port_id,
app/test-pmd/testpmd.h +1 -0
@@ -934,6 +934,7 @@ int port_queue_flow_create(portid_t port_id, queueid_t queue_id, const struct rte_flow_action *actions);int port_queue_flow_destroy (portid_t port_id,queueid_t queue_id,bool drain,uint32_t n,const uint32_t *rule); +int port_queue_flow_drain (portid_t port_id,queueid_t queue_id); int port_flow_validate(portid_t port_id, const struct rte_flow_attr *attr, const struct rte_flow_item *pattern,
doc/guides/testpmd_app_ug/testpmd_funcs.rst +21 -0
@@ -3368,6 +3368,10 @@ following sections. flow queue {port_id} destroy {queue_id} [drain {boolean}] rule {rule_id} [...] +- Drain a queue:: + + flow drain {port_id} queue {queue_id} + - Create a flow rule:: flow create {port_id}
@@ -3561,6 +3565,23 @@ The usual error message is shown when a table cannot be destroyed:: Caught error type [...] ([...]): [...] +Draining a flow queue +~~~~~~~~~~~~~~~~~~~~~ + +``flow drain`` drains the specific queue to push all the +outstanding queued operations to the underlying device immediately. +It is bound to ``rte_flow_q_drain()``:: + + flow drain {port_id} queue {queue_id} + +If successful, it will show:: + + Queue #[...] drained + +The usual error message is shown when a queue cannot be drained:: + + Caught error type [...] ([...]): [...] + Creating a tunnel stub for offload ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Signature · 1 line
2.18.2
PATCH v2 9/10 app/testpmd: implement rte flow queue dequeue
In reply to Alexander KozyrevAdd testpmd support for the rte_flow_q_dequeue API. Provide the command line interface for operations dequeue. Usage example: flow dequeue 0 queue 0
--- app/test-pmd/cmdline_flow.c | 54 +++++++++++++++ app/test-pmd/config.c | 74 +++++++++++++-------- app/test-pmd/testpmd.h | 1 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 25 +++++++ 4 files changed, 126 insertions(+), 28 deletions(-)
app/test-pmd/cmdline_flow.c +54 -0
@@ -93,6 +93,7 @@ enum index {TUNNEL ,FLEX ,QUEUE , +DEQUEUE , DRAIN,/* Flex arguments */
@@ -132,6 +133,9 @@ enum index {QUEUE_DESTROY_ID ,QUEUE_DESTROY_DRAIN , +/* Dequeue arguments. */ +DEQUEUE_QUEUE , +/* Drain arguments. */ DRAIN_QUEUE,
@@ -2159,6 +2163,9 @@ static int parse_qo(struct context *, const struct token *,static int parse_qo_destroy (struct context *,const struct token *,const char *,unsigned int ,void *,unsigned int ); +static int parse_dequeue (struct context *,const struct token *, +const char *,unsigned int , +void *,unsigned int );static int parse_drain (struct context *,const struct token *,const char *,unsigned int ,void *,unsigned int );
@@ -2440,6 +2447,7 @@ static const struct token token_list[] = { TUNNEL,FLEX ,QUEUE , +DEQUEUE , DRAIN)), .call = parse_init, },
@@ -2775,6 +2783,21 @@ static const struct token token_list[] = { .call = parse_qo_destroy, },/* Top-level command. */ + [DEQUEUE] = { + .name = "dequeue", + .help = "dequeue flow operations", + .next = NEXT(NEXT_ENTRY(DEQUEUE_QUEUE), NEXT_ENTRY(COMMON_PORT_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, port)), + .call = parse_dequeue, + }, +/* Sub-level commands. */ + [DEQUEUE_QUEUE] = { + .name = "queue", + .help = "specify queue id", + .next = NEXT(NEXT_ENTRY(END), NEXT_ENTRY(COMMON_QUEUE_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, queue)), + }, +/* Top-level command. */ [DRAIN] = { .name = "drain", .help = "drain a flow queue",
@@ -8408,6 +8431,34 @@ parse_qo_destroy(struct context *ctx, const struct token *token, } } +/** Parse tokens for dequeue command. */ +static int +parse_dequeue (struct context *ctx,const struct token *token, +const char *str,unsigned int len, +void *buf,unsigned int size) +{ +struct buffer *out = buf; + +/* Token name must match. */ +if (parse_default (ctx, token, str, len,NULL ,0 ) <0 ) +return -1 ; +/* Nothing else to do if there is no buffer. */ +if (!out) +return len; +if (!out->command) { +if (ctx->curr !=DEQUEUE ) +return -1 ; +if (sizeof (*out) > size) +return -1 ; + out->command = ctx->curr; + ctx->objdata =0 ; + ctx->object = out; + ctx->objmask =NULL ; + out->args.vc.data = (uint8_t *)out + size; + } +return len; +} +/** Parse tokens for drain queue command. */ static int parse_drain(struct context *ctx, const struct token *token,
@@ -9800,6 +9851,9 @@ cmd_flow_parsed(const struct buffer *in) in->args.destroy.rule_n, in->args.destroy.rule);break ; +case DEQUEUE : +port_queue_flow_dequeue (in->port, in->queue); +break ;case DRAIN :port_queue_flow_drain (in->port, in->queue);break ;
app/test-pmd/config.c +46 -28
110 lines not on this page · raw message
app/test-pmd/testpmd.h +1 -0
@@ -935,6 +935,7 @@ int port_queue_flow_create(portid_t port_id, queueid_t queue_id,int port_queue_flow_destroy (portid_t port_id,queueid_t queue_id,bool drain,uint32_t n,const uint32_t *rule);int port_queue_flow_drain (portid_t port_id,queueid_t queue_id); +int port_queue_flow_dequeue (portid_t port_id,queueid_t queue_id); int port_flow_validate(portid_t port_id, const struct rte_flow_attr *attr, const struct rte_flow_item *pattern,
doc/guides/testpmd_app_ug/testpmd_funcs.rst +25 -0
@@ -3372,6 +3372,10 @@ following sections. flow drain {port_id} queue {queue_id} +- Dequeue all operations from a queue:: + + flow dequeue {port_id} queue {queue_id} + - Create a flow rule:: flow create {port_id}
@@ -3582,6 +3586,23 @@ The usual error message is shown when a queue cannot be drained:: Caught error type [...] ([...]): [...] +Dequeueing flow operations +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +``flow dequeue`` asks the underlying device about flow queue operations +results and return all the processed (successfully or not) operations. +It is bound to ``rte_flow_q_dequeue()``:: + + flow dequeue {port_id} queue {queue_id} + +If successful, it will show:: + + Queue #[...] dequeued #[...] operations (#[...] failed, #[...] succeeded) + +The usual error message is shown when a queue cannot be drained:: + + Caught error type [...] ([...]): [...] + Creating a tunnel stub for offload ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -3711,6 +3732,8 @@ Otherwise it will show an error message of the form:: This command uses the same pattern items and actions as ``flow create``, their format is described in `Creating flow rules`_. +``flow queue dequeue`` must be called to retrieve the operation status. + Attributes ^^^^^^^^^^
@@ -4444,6 +4467,8 @@ message is shown when a rule cannot be destroyed:: Caught error type [...] ([...]): [...] +``flow queue dequeue`` must be called to retrieve the operation status. + Querying flow rules ~~~~~~~~~~~~~~~~~~~
Signature · 1 line
2.18.2
PATCH v2 10/10 app/testpmd: implement rte flow queue indirect action
In reply to Alexander KozyrevAdd testpmd support for the rte_flow_q_action_handle API. Provide the command line interface for operations dequeue. Usage example:
flow queue 0 indirect_action 0 create action_id 9
ingress drain yes action rss / end
flow queue 0 indirect_action 0 update action_id 9
action queue index 0 / end
flow queue 0 indirect_action 0 destroy action_id 9
--- app/test-pmd/cmdline_flow.c | 276 ++++++++++++++++++++ app/test-pmd/config.c | 131 ++++++++++ app/test-pmd/testpmd.h | 10 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 65 +++++ 4 files changed, 482 insertions(+)
app/test-pmd/cmdline_flow.c +276 -0
@@ -120,6 +120,7 @@ enum index {/* Queue arguments. */ QUEUE_CREATE ,QUEUE_DESTROY , +QUEUE_INDIRECT_ACTION ,/* Queue create arguments. */ QUEUE_CREATE_ID,
@@ -133,6 +134,26 @@ enum index {QUEUE_DESTROY_ID ,QUEUE_DESTROY_DRAIN , +/* Queue indirect action arguments */ +QUEUE_INDIRECT_ACTION_CREATE , +QUEUE_INDIRECT_ACTION_UPDATE , +QUEUE_INDIRECT_ACTION_DESTROY , + +/* Queue indirect action create arguments */ +QUEUE_INDIRECT_ACTION_CREATE_ID , +QUEUE_INDIRECT_ACTION_INGRESS , +QUEUE_INDIRECT_ACTION_EGRESS , +QUEUE_INDIRECT_ACTION_TRANSFER , +QUEUE_INDIRECT_ACTION_CREATE_DRAIN , +QUEUE_INDIRECT_ACTION_SPEC , + +/* Queue indirect action update arguments */ +QUEUE_INDIRECT_ACTION_UPDATE_DRAIN , + +/* Queue indirect action destroy arguments */ +QUEUE_INDIRECT_ACTION_DESTROY_ID , +QUEUE_INDIRECT_ACTION_DESTROY_DRAIN , +/* Dequeue arguments. */ DEQUEUE_QUEUE,
@@ -1099,6 +1120,7 @@ static const enum index next_table_destroy_attr[] = {static const enum index next_queue_subcmd[] = {QUEUE_CREATE ,QUEUE_DESTROY , +QUEUE_INDIRECT_ACTION ,ZERO , };
@@ -1108,6 +1130,36 @@ static const enum index next_queue_destroy_attr[] = { ZERO, }; +static const enum index next_qia_subcmd[] = { +QUEUE_INDIRECT_ACTION_CREATE , +QUEUE_INDIRECT_ACTION_UPDATE , +QUEUE_INDIRECT_ACTION_DESTROY , +ZERO , +}; + +static const enum index next_qia_create_attr[] = { +QUEUE_INDIRECT_ACTION_CREATE_ID , +QUEUE_INDIRECT_ACTION_INGRESS , +QUEUE_INDIRECT_ACTION_EGRESS , +QUEUE_INDIRECT_ACTION_TRANSFER , +QUEUE_INDIRECT_ACTION_CREATE_DRAIN , +QUEUE_INDIRECT_ACTION_SPEC , +ZERO , +}; + +static const enum index next_qia_update_attr[] = { +QUEUE_INDIRECT_ACTION_UPDATE_DRAIN , +QUEUE_INDIRECT_ACTION_SPEC , +ZERO , +}; + +static const enum index next_qia_destroy_attr[] = { +QUEUE_INDIRECT_ACTION_DESTROY_DRAIN , +QUEUE_INDIRECT_ACTION_DESTROY_ID , +END , +ZERO , +}; +static const enum index next_ia_create_attr[] = {INDIRECT_ACTION_CREATE_ID ,INDIRECT_ACTION_INGRESS ,
@@ -2163,6 +2215,12 @@ static int parse_qo(struct context *, const struct token *,static int parse_qo_destroy (struct context *,const struct token *,const char *,unsigned int ,void *,unsigned int ); +static int parse_qia (struct context *,const struct token *, +const char *,unsigned int , +void *,unsigned int ); +static int parse_qia_destroy (struct context *,const struct token *, +const char *,unsigned int , +void *,unsigned int );static int parse_dequeue (struct context *,const struct token *,const char *,unsigned int ,void *,unsigned int );
@@ -2729,6 +2787,13 @@ static const struct token token_list[] = { .args = ARGS(ARGS_ENTRY(struct buffer, queue)), .call = parse_qo_destroy, }, + [QUEUE_INDIRECT_ACTION] = { + .name = "indirect_action", + .help = "queue indirect actions", + .next = NEXT(next_qia_subcmd, NEXT_ENTRY(COMMON_QUEUE_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, queue)), + .call = parse_qia, + },/* Queue arguments. */ [QUEUE_TABLE] = { .name = "table",
@@ -2782,6 +2847,90 @@ static const struct token token_list[] = { args.destroy.rule)), .call = parse_qo_destroy, }, +/* Queue indirect action arguments */ + [QUEUE_INDIRECT_ACTION_CREATE] = { + .name = "create", + .help = "create indirect action", + .next = NEXT(next_qia_create_attr), + .call = parse_qia, + }, + [QUEUE_INDIRECT_ACTION_UPDATE] = { + .name = "update", + .help = "update indirect action", + .next =NEXT (next_qia_update_attr, + NEXT_ENTRY(COMMON_INDIRECT_ACTION_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.attr.group)), + .call = parse_qia, + }, + [QUEUE_INDIRECT_ACTION_DESTROY] = { + .name = "destroy", + .help = "destroy indirect action", + .next = NEXT(next_qia_destroy_attr), + .call = parse_qia_destroy, + }, +/* Indirect action destroy arguments. */ + [QUEUE_INDIRECT_ACTION_DESTROY_DRAIN] = { + .name = "drain", + .help = "drain operation immediately", + .next =NEXT (next_qia_destroy_attr, + NEXT_ENTRY(COMMON_BOOLEAN)), + .args = ARGS(ARGS_ENTRY(struct buffer, drain)), + }, + [QUEUE_INDIRECT_ACTION_DESTROY_ID] = { + .name = "action_id", + .help = "specify a indirect action id to destroy", + .next =NEXT (next_qia_destroy_attr, + NEXT_ENTRY(COMMON_INDIRECT_ACTION_ID)), + .args = ARGS(ARGS_ENTRY_PTR(struct buffer, + args.ia_destroy.action_id)), + .call = parse_qia_destroy, + }, +/* Indirect action update arguments. */ + [QUEUE_INDIRECT_ACTION_UPDATE_DRAIN] = { + .name = "drain", + .help = "drain operation immediately", + .next =NEXT (next_qia_update_attr, + NEXT_ENTRY(COMMON_BOOLEAN)), + .args = ARGS(ARGS_ENTRY(struct buffer, drain)), + }, +/* Indirect action create arguments. */ + [QUEUE_INDIRECT_ACTION_CREATE_ID] = { + .name = "action_id", + .help = "specify a indirect action id to create", + .next =NEXT (next_qia_create_attr, + NEXT_ENTRY(COMMON_INDIRECT_ACTION_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.attr.group)), + }, + [QUEUE_INDIRECT_ACTION_INGRESS] = { + .name = "ingress", + .help = "affect rule to ingress", + .next = NEXT(next_qia_create_attr), + .call = parse_qia, + }, + [QUEUE_INDIRECT_ACTION_EGRESS] = { + .name = "egress", + .help = "affect rule to egress", + .next = NEXT(next_qia_create_attr), + .call = parse_qia, + }, + [QUEUE_INDIRECT_ACTION_TRANSFER] = { + .name = "transfer", + .help = "affect rule to transfer", + .next = NEXT(next_qia_create_attr), + .call = parse_qia, + }, + [QUEUE_INDIRECT_ACTION_CREATE_DRAIN] = { + .name = "drain", + .help = "drain operation immediately", + .next =NEXT (next_qia_create_attr, + NEXT_ENTRY(COMMON_BOOLEAN)), + .args = ARGS(ARGS_ENTRY(struct buffer, drain)), + }, + [QUEUE_INDIRECT_ACTION_SPEC] = { + .name = "action", + .help = "specify action to create indirect handle", + .next = NEXT(next_action), + },/* Top-level command. */ [DEQUEUE] = { .name = "dequeue",
@@ -6181,6 +6330,110 @@ parse_ia_destroy(struct context *ctx, const struct token *token,return len; } +/** Parse tokens for indirect action commands. */ +static int +parse_qia (struct context *ctx,const struct token *token, +const char *str,unsigned int len, +void *buf,unsigned int size) +{ +struct buffer *out = buf; + +/* Token name must match. */ +if (parse_default (ctx, token, str, len,NULL ,0 ) <0 ) +return -1 ; +/* Nothing else to do if there is no buffer. */ +if (!out) +return len; +if (!out->command) { +if (ctx->curr !=QUEUE ) +return -1 ; +if (sizeof (*out) > size) +return -1 ; + out->args.vc.data = (uint8_t *)out + size; +return len; + } +switch (ctx->curr) { +case QUEUE_INDIRECT_ACTION : +return len; +case QUEUE_INDIRECT_ACTION_CREATE : +case QUEUE_INDIRECT_ACTION_UPDATE : + out->args.vc.actions = + (void *)RTE_ALIGN_CEIL ((uintptr_t )(out +1 ), +sizeof (double )); + out->args.vc.attr.group =UINT32_MAX ; + out->command = ctx->curr; + ctx->objdata =0 ; + ctx->object = out; + ctx->objmask =NULL ; +return len; +case QUEUE_INDIRECT_ACTION_EGRESS : + out->args.vc.attr.egress =1 ; +return len; +case QUEUE_INDIRECT_ACTION_INGRESS : + out->args.vc.attr.ingress =1 ; +return len; +case QUEUE_INDIRECT_ACTION_TRANSFER : + out->args.vc.attr.transfer =1 ; +return len; +case QUEUE_INDIRECT_ACTION_CREATE_DRAIN : +return len; +default : +return -1 ; + } +} + +/** Parse tokens for indirect action destroy command. */ +static int +parse_qia_destroy (struct context *ctx,const struct token *token, +const char *str,unsigned int len, +void *buf,unsigned int size) +{ +struct buffer *out = buf; +uint32_t *action_id; + +/* Token name must match. */ +if (parse_default (ctx, token, str, len,NULL ,0 ) <0 ) +return -1 ; +/* Nothing else to do if there is no buffer. */ +if (!out) +return len; +if (!out->command || out->command ==QUEUE ) { +if (ctx->curr !=QUEUE_INDIRECT_ACTION_DESTROY ) +return -1 ; +if (sizeof (*out) > size) +return -1 ; + out->command = ctx->curr; + ctx->objdata =0 ; + ctx->object = out; + ctx->objmask =NULL ; + out->args.ia_destroy.action_id = + (void *)RTE_ALIGN_CEIL ((uintptr_t )(out +1 ), +sizeof (double )); +return len; + } +switch (ctx->curr) { +case QUEUE_INDIRECT_ACTION : + out->command = ctx->curr; + ctx->objdata =0 ; + ctx->object = out; + ctx->objmask =NULL ; +return len; +case QUEUE_INDIRECT_ACTION_DESTROY_ID : + action_id = out->args.ia_destroy.action_id + + out->args.ia_destroy.action_id_n++; +if ((uint8_t *)action_id > (uint8_t *)out + size) +return -1 ; + ctx->objdata =0 ; + ctx->object = action_id; + ctx->objmask =NULL ; +return len; +case QUEUE_INDIRECT_ACTION_DESTROY_DRAIN : +return len; +default : +return -1 ; + } +} +/** Parse tokens for meter policy action commands. */ static int parse_mp(struct context *ctx, const struct token *token,
@@ -9857,6 +10110,29 @@ cmd_flow_parsed(const struct buffer *in)case DRAIN :port_queue_flow_drain (in->port, in->queue);break ; +case QUEUE_INDIRECT_ACTION_CREATE : +port_queue_action_handle_create ( + in->port, in->queue, in->drain, + in->args.vc.attr.group, + &((const struct rte_flow_indir_action_conf ) { + .ingress = in->args.vc.attr.ingress, + .egress = in->args.vc.attr.egress, + .transfer = in->args.vc.attr.transfer, + }), + in->args.vc.actions); +break ; +case QUEUE_INDIRECT_ACTION_DESTROY : +port_queue_action_handle_destroy (in->port, + in->queue, in->drain, + in->args.ia_destroy.action_id_n, + in->args.ia_destroy.action_id); +break ; +case QUEUE_INDIRECT_ACTION_UPDATE : +port_queue_action_handle_update (in->port, + in->queue, in->drain, + in->args.vc.attr.group, + in->args.vc.actions); +break ;case INDIRECT_ACTION_CREATE : port_action_handle_create( in->port, in->args.vc.attr.group,
app/test-pmd/config.c +131 -0
137 lines not on this page · raw message
app/test-pmd/testpmd.h +10 -0
@@ -934,6 +934,16 @@ int port_queue_flow_create(portid_t port_id, queueid_t queue_id, const struct rte_flow_action *actions);int port_queue_flow_destroy (portid_t port_id,queueid_t queue_id,bool drain,uint32_t n,const uint32_t *rule); +int port_queue_action_handle_create (portid_t port_id,uint32_t queue_id, +bool drain,uint32_t id, +const struct rte_flow_indir_action_conf *conf, +const struct rte_flow_action *action); +int port_queue_action_handle_destroy (portid_t port_id, +uint32_t queue_id,bool drain, +uint32_t n,const uint32_t *action); +int port_queue_action_handle_update (portid_t port_id,uint32_t queue_id, +bool drain,uint32_t id, +const struct rte_flow_action *action);int port_queue_flow_drain (portid_t port_id,queueid_t queue_id);int port_queue_flow_dequeue (portid_t port_id,queueid_t queue_id); int port_flow_validate(portid_t port_id,
doc/guides/testpmd_app_ug/testpmd_funcs.rst +65 -0
83 lines not on this page · raw message
Signature · 1 line
2.18.2
Quoted 32 lines
-----Original Message-----
From: Alexander Kozyrev <[email protected]>
Sent: Tuesday, January 18, 2022 11:30 PM
To: [email protected]
Cc: Ori Kam <[email protected]>; NBU-Contact-Thomas Monjalon (EXTERNAL) <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH v2 00/10] ethdev: datapath-focused flow rules managementThree major changes to a generic RTE Flow API were implemented in order to speed up flow rule insertion/destruction and adapt the API to the needs of a datapath-focused flow rules management applications:
1. Pre-configuration hints.
Application may give us some hints on what type of resources are needed. Introduce the configuration routine to prepare all the needed resources inside a PMD/HW before any flow rules are created at the init stage.2. Flow grouping using templates.
Use the knowledge about which flow rules are to be used in an application and prepare item and action templates for them in advance. Group flow rules with common patterns and actions together for better resource management.3. Queue-based flow management.
Perform flow rule insertion/destruction asynchronously to spare the datapath from blocking on RTE Flow API and allow it to continue with packet processing. Enqueue flow rules operations and poll for the results later.
Quoted 7 lines
testpmd examples are part of the patch series. PMD changes will follow.
RFC:
https://patchwork.dpdk.org/project/dpdk/cover/20211006044835.3936226-1-
[email protected]/Signed-off-by Alexander Kozyrev <[email protected]>
Quoted 34 lines
---
v2: fixed patch series threadAlexander Kozyrev (10):
ethdev: introduce flow pre-configuration hints
ethdev: add flow item/action templates
ethdev: bring in async queue-based flow rules operations app/testpmd: implement rte flow configure app/testpmd: implement rte flow item/action template app/testpmd: implement rte flow table app/testpmd: implement rte flow queue create flow app/testpmd: implement rte flow queue drain app/testpmd: implement rte flow queue dequeue app/testpmd: implement rte flow queue indirect actionapp/test-pmd/cmdline_flow.c | 1484 ++++++++++++++++- app/test-pmd/config.c | 731 ++++++++ app/test-pmd/testpmd.h | 61 + doc/guides/prog_guide/img/rte_flow_q_init.svg | 71 + .../prog_guide/img/rte_flow_q_usage.svg | 60 + doc/guides/prog_guide/rte_flow.rst | 319 ++++ doc/guides/rel_notes/release_22_03.rst | 19 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 350 +++- lib/ethdev/rte_flow.c | 332 ++++ lib/ethdev/rte_flow.h | 680 ++++++++ lib/ethdev/rte_flow_driver.h | 103 ++ lib/ethdev/version.map | 16 + 12 files changed, 4203 insertions(+), 23 deletions(-) create mode 100644 doc/guides/prog_guide/img/rte_flow_q_init.svg create mode 100644 doc/guides/prog_guide/img/rte_flow_q_usage.svg--
2.18.2
Hi Alex,
Quoted 36 lines
-----Original Message-----
From: Suanming Mou <[email protected]>
Subject: RE: [PATCH v2 00/10] ethdev: datapath-focused flow rules managementQuoted 30 lines
-----Original Message-----
From: Alexander Kozyrev <[email protected]>
Sent: Tuesday, January 18, 2022 11:30 PM
To: [email protected]
Cc: Ori Kam <[email protected]>; NBU-Contact-Thomas Monjalon (EXTERNAL) <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH v2 00/10] ethdev: datapath-focused flow rules managementThree major changes to a generic RTE Flow API were implemented in order to speed up flow rule insertion/destruction and adapt the API to the needs of a datapath-focused flow rules management applications:
1. Pre-configuration hints.
Application may give us some hints on what type of resources are needed. Introduce the configuration routine to prepare all the needed resources inside a PMD/HW before any flow rules are created at the init stage.2. Flow grouping using templates.
Use the knowledge about which flow rules are to be used in an application and prepare item and action templates for them in advance. Group flow rules with common patterns and actions together for better resource management.3. Queue-based flow management.
Perform flow rule insertion/destruction asynchronously to spare the datapath from blocking on RTE Flow API and allow it to continue with packet processing. Enqueue flow rules operations and poll for the results later.
Quoted 42 lines
Quoted 7 lines
testpmd examples are part of the patch series. PMD changes will follow.
RFC:
https://patchwork.dpdk.org/project/dpdk/cover/20211006044835.3936226-1-
[email protected]/Signed-off-by Alexander Kozyrev <[email protected]>Reviewed-by Suanming Mou <[email protected]>Quoted 34 lines
---
v2: fixed patch series threadAlexander Kozyrev (10):
ethdev: introduce flow pre-configuration hints
ethdev: add flow item/action templates
ethdev: bring in async queue-based flow rules operations app/testpmd: implement rte flow configure app/testpmd: implement rte flow item/action template app/testpmd: implement rte flow table app/testpmd: implement rte flow queue create flow app/testpmd: implement rte flow queue drain app/testpmd: implement rte flow queue dequeue app/testpmd: implement rte flow queue indirect actionapp/test-pmd/cmdline_flow.c | 1484 ++++++++++++++++- app/test-pmd/config.c | 731 ++++++++ app/test-pmd/testpmd.h | 61 + doc/guides/prog_guide/img/rte_flow_q_init.svg | 71 + .../prog_guide/img/rte_flow_q_usage.svg | 60 + doc/guides/prog_guide/rte_flow.rst | 319 ++++ doc/guides/rel_notes/release_22_03.rst | 19 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 350 +++- lib/ethdev/rte_flow.c | 332 ++++ lib/ethdev/rte_flow.h | 680 ++++++++ lib/ethdev/rte_flow_driver.h | 103 ++ lib/ethdev/version.map | 16 + 12 files changed, 4203 insertions(+), 23 deletions(-) create mode 100644 doc/guides/prog_guide/img/rte_flow_q_init.svg create mode 100644 doc/guides/prog_guide/img/rte_flow_q_usage.svg--
2.18.2
Thanks,
Ori
v3 cover ethdev: datapath-focused flow rules management
In reply to Alexander KozyrevThree major changes to a generic RTE Flow API were implemented in order to speed up flow rule insertion/destruction and adapt the API to the needs of a datapath-focused flow rules management applications:
1. Pre-configuration hints.
Application may give us some hints on what type of resources are needed. Introduce the configuration routine to prepare all the needed resources inside a PMD/HW before any flow rules are created at the init stage.
2. Flow grouping using templates.
Use the knowledge about which flow rules are to be used in an application and prepare item and action templates for them in advance. Group flow rules with common patterns and actions together for better resource management.
3. Queue-based flow management.
Perform flow rule insertion/destruction asynchronously to spare the datapath from blocking on RTE Flow API and allow it to continue with packet processing. Enqueue flow rules operations and poll for the results later.
testpmd examples are part of the patch series. PMD changes will follow.
RFC: https://patchwork.dpdk.org/project/dpdk/cover/[email protected]/
---
v3: addressed review comments and updated documentation
- added API to get info about pre-configurable resources
- renamed rte_flow_item_template to rte_flow_pattern_template
- renamed drain operation attribute to postpone
- renamed rte_flow_q_drain to rte_flow_q_push
- renamed rte_flow_q_dequeue to rte_flow_q_pull
v2: fixed patch series thread
Alexander Kozyrev (10):
ethdev: introduce flow pre-configuration hints
ethdev: add flow item/action templates
ethdev: bring in async queue-based flow rules operations app/testpmd: implement rte flow configuration app/testpmd: implement rte flow template management app/testpmd: implement rte flow table management app/testpmd: implement rte flow queue flow operations app/testpmd: implement rte flow push operations app/testpmd: implement rte flow pull operations app/testpmd: implement rte flow queue indirect actions
app/test-pmd/cmdline_flow.c | 1495 ++++++++++++++++- app/test-pmd/config.c | 770 +++++++++ app/test-pmd/testpmd.h | 66 + doc/guides/prog_guide/img/rte_flow_q_init.svg | 71 + .../prog_guide/img/rte_flow_q_usage.svg | 60 + doc/guides/prog_guide/rte_flow.rst | 318 ++++ doc/guides/rel_notes/release_22_03.rst | 20 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 375 ++++- lib/ethdev/rte_flow.c | 352 ++++ lib/ethdev/rte_flow.h | 698 ++++++++ lib/ethdev/rte_flow_driver.h | 102 ++ lib/ethdev/version.map | 17 + 12 files changed, 4324 insertions(+), 20 deletions(-) create mode 100644 doc/guides/prog_guide/img/rte_flow_q_init.svg create mode 100644 doc/guides/prog_guide/img/rte_flow_q_usage.svg
Signature · 1 line
2.18.2
PATCH v3 1/10 ethdev: introduce flow pre-configuration hints
The flow rules creation/destruction at a large scale incurs a performance penalty and may negatively impact the packet processing when used as part of the datapath logic. This is mainly because software/hardware resources are allocated and prepared during the flow rule creation.
In order to optimize the insertion rate, PMD may use some hints provided by the application at the initialization phase. The rte_flow_configure() function allows to pre-allocate all the needed resources beforehand. These resources can be used at a later stage without costly allocations. Every PMD may use only the subset of hints and ignore unused ones or fail in case the requested configuration is not supported.
The rte_flow_info_get() is available to retrieve the information about supported pre-configurable resources. Both these functions must be called before any other usage of the flow API engine.
--- doc/guides/prog_guide/rte_flow.rst | 37 ++++++++++++ doc/guides/rel_notes/release_22_03.rst | 4 ++ lib/ethdev/rte_flow.c | 40 +++++++++++++ lib/ethdev/rte_flow.h | 82 ++++++++++++++++++++++++++ lib/ethdev/rte_flow_driver.h | 10 ++++ lib/ethdev/version.map | 4 ++ 6 files changed, 177 insertions(+)
doc/guides/prog_guide/rte_flow.rst +37 -0
@@ -3589,6 +3589,43 @@ Return values: - 0 on success, a negative errno value otherwise and ``rte_errno`` is set. +Flow engine configuration +------------------------- + +Configure flow API management. + +An application may provide some hints at the initialization phase about +rules engine configuration and/or expected flow rules characteristics. +These hints may be used by PMD to pre-allocate resources and configure NIC. + +Configuration +~~~~~~~~~~~~~ + +This function performs the flow API management configuration and +pre-allocates needed resources beforehand to avoid costly allocations later. +Hints about the expected number of counters or meters in an application, +for example, allow PMD to prepare and optimize NIC memory layout in advance. +``rte_flow_configure()`` must be called before any flow rule is created, +but after an Ethernet device is configured. + +.. code-block:: c + + int + rte_flow_configure(uint16_t port_id, + const struct rte_flow_port_attr *port_attr, + struct rte_flow_error *error); + +Information about resources that can benefit from pre-allocation can be +retrieved via ``rte_flow_info_get()`` API. It returns the maximum number +of pre-configurable resources for a given port on a system. + +.. code-block:: c + + int + rte_flow_info_get(uint16_t port_id, + struct rte_flow_port_attr *port_attr, + struct rte_flow_error *error); + .. _flow_isolated_mode: Flow isolated mode
doc/guides/rel_notes/release_22_03.rst +4 -0
@@ -55,6 +55,10 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* ethdev: Added ``rte_flow_configure`` API to configure Flow Management + engine, allowing to pre-allocate some resources for better performance. + Added ``rte_flow_info_get`` API to retrieve pre-configurable resources. + * **Updated AF_XDP PMD** * Added support for libxdp >=v1.2.2.
lib/ethdev/rte_flow.c +40 -0
@@ -1391,3 +1391,43 @@ rte_flow_flex_item_release(uint16_t port_id, ret = ops->flex_item_release (dev, handle, error);return flow_err (port_id, ret, error); } + +int +rte_flow_info_get (uint16_t port_id, +struct rte_flow_port_attr *port_attr, +struct rte_flow_error *error) +{ +struct rte_eth_dev *dev = &rte_eth_devices[port_id]; +const struct rte_flow_ops *ops =rte_flow_ops_get (port_id, error); + +if (unlikely (!ops)) +return -rte_errno; +if (likely (!!ops->info_get)) { +return flow_err (port_id, + ops->info_get (dev, port_attr, error), + error); + } +return rte_flow_error_set (error,ENOTSUP , +RTE_FLOW_ERROR_TYPE_UNSPECIFIED , +NULL ,rte_strerror (ENOTSUP )); +} + +int +rte_flow_configure (uint16_t port_id, +const struct rte_flow_port_attr *port_attr, +struct rte_flow_error *error) +{ +struct rte_eth_dev *dev = &rte_eth_devices[port_id]; +const struct rte_flow_ops *ops =rte_flow_ops_get (port_id, error); + +if (unlikely (!ops)) +return -rte_errno; +if (likely (!!ops->configure)) { +return flow_err (port_id, + ops->configure (dev, port_attr, error), + error); + } +return rte_flow_error_set (error,ENOTSUP , +RTE_FLOW_ERROR_TYPE_UNSPECIFIED , +NULL ,rte_strerror (ENOTSUP )); +}
lib/ethdev/rte_flow.h +82 -0
88 lines not on this page · raw message
lib/ethdev/rte_flow_driver.h +10 -0
@@ -152,6 +152,16 @@ struct rte_flow_ops { (struct rte_eth_dev *dev, const struct rte_flow_item_flex_handle *handle, struct rte_flow_error *error); +/** See rte_flow_info_get() */ +int (*info_get) + (struct rte_eth_dev *dev, +struct rte_flow_port_attr *port_attr, +struct rte_flow_error *err); +/** See rte_flow_configure() */ +int (*configure) + (struct rte_eth_dev *dev, +const struct rte_flow_port_attr *port_attr, +struct rte_flow_error *err); };/**
lib/ethdev/version.map +4 -0
@@ -256,6 +256,10 @@ EXPERIMENTAL { rte_flow_flex_item_create; rte_flow_flex_item_release; rte_flow_pick_transfer_proxy; + + # added in 22.03 + rte_flow_info_get; + rte_flow_configure; }; INTERNAL {
Signature · 1 line
2.18.2
RE: [PATCH v3 01/10] ethdev: introduce flow pre-configuration hints
Hi Alexander,
Quoted 17 lines
-----Original Message-----
From: Alexander Kozyrev <[email protected]>
Sent: Sunday, February 6, 2022 5:25 AM
Subject: [PATCH v3 01/10] ethdev: introduce flow pre-configuration hintsThe flow rules creation/destruction at a large scale incurs a performance penalty and may negatively impact the packet processing when used as part of the datapath logic. This is mainly because software/hardware resources are allocated and prepared during the flow rule creation.
In order to optimize the insertion rate, PMD may use some hints provided by the application at the initialization phase. The
rte_flow_configure()function allows to pre-allocate all the needed resources beforehand. These resources can be used at a later stage without costly allocations. Every PMD may use only the subset of hints and ignore unused ones or fail in case the requested configuration is not supported.
Quoted 6 lines
The
rte_flow_info_get()is available to retrieve the information about supported pre-configurable resources. Both these functions must be called before any other usage of the flow API engine.Signed-off-by Alexander Kozyrev <[email protected]>---
Best,
Ori
Re: [PATCH v3 01/10] ethdev: introduce flow pre-configuration hints
In reply to Alexander KozyrevQuoted 32 lines · Alexander Kozyrev
The flow rules creation/destruction at a large scale incurs a performance penalty and may negatively impact the packet processing when used as part of the datapath logic. This is mainly because software/hardware resources are allocated and prepared during the flow rule creation.
In order to optimize the insertion rate, PMD may use some hints provided by the application at the initialization phase. The
rte_flow_configure()function allows to pre-allocate all the needed resources beforehand. These resources can be used at a later stage without costly allocations. Every PMD may use only the subset of hints and ignore unused ones or fail in case the requested configuration is not supported.The
rte_flow_info_get()is available to retrieve the information about supported pre-configurable resources. Both these functions must be called before any other usage of the flow API engine.Signed-off-by Alexander Kozyrev <[email protected]>--- doc/guides/prog_guide/rte_flow.rst | 37 ++++++++++++ doc/guides/rel_notes/release_22_03.rst | 4 ++ lib/ethdev/rte_flow.c | 40 +++++++++++++ lib/ethdev/rte_flow.h | 82 ++++++++++++++++++++++++++ lib/ethdev/rte_flow_driver.h | 10 ++++ lib/ethdev/version.map | 4 ++ 6 files changed, 177 insertions(+)doc/guides/prog_guide/rte_flow.rst +0
-0
doc/guides/prog_guide/rte_flow.rst Return values: · line 3598
Quoted 10 lines
doc/guides/prog_guide/rte_flow.rst +7
-0@@ -3589,6 +3589,43 @@ Return values: - 0 on success, a negative errno value otherwise and ``rte_errno`` is set. +Flow engine configuration +------------------------- + +Configure flow API management. + +An application may provide some hints at the initialization phase about +rules engine configuration and/or expected flow rules characteristics.
IMO, We can explicitly remove _hint_ in the documentation. When we add new paramers to configure, it may not be hit.
doc/guides/prog_guide/rte_flow.rst Return values: · line 3599
Quoted 1 line
doc/guides/prog_guide/rte_flow.rst +1
-0+These hints may be used by PMD to pre-allocate resources and configure NIC.
hints->parameters
Quoted 106 lines
doc/guides/prog_guide/rte_flow.rst +29
-0+ +Configuration +~~~~~~~~~~~~~ + +This function performs the flow API management configuration and +pre-allocates needed resources beforehand to avoid costly allocations later. +Hints about the expected number of counters or meters in an application, +for example, allow PMD to prepare and optimize NIC memory layout in advance. +``rte_flow_configure()`` must be called before any flow rule is created, +but after an Ethernet device is configured. + +.. code-block:: c + + int + rte_flow_configure(uint16_t port_id, + const struct rte_flow_port_attr *port_attr, + struct rte_flow_error *error); + +Information about resources that can benefit from pre-allocation can be +retrieved via ``rte_flow_info_get()`` API. It returns the maximum number +of pre-configurable resources for a given port on a system. + +.. code-block:: c + + int + rte_flow_info_get(uint16_t port_id, + struct rte_flow_port_attr *port_attr, + struct rte_flow_error *error); + .. _flow_isolated_mode: Flow isolated modedoc/guides/rel_notes/release_22_03.rst +4
-0@@ -55,6 +55,10 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* ethdev: Added ``rte_flow_configure`` API to configure Flow Management + engine, allowing to pre-allocate some resources for better performance. + Added ``rte_flow_info_get`` API to retrieve pre-configurable resources. + * **Updated AF_XDP PMD** * Added support for libxdp >=v1.2.2.lib/ethdev/rte_flow.c +40
-0@@ -1391,3 +1391,43 @@ rte_flow_flex_item_release(uint16_t port_id, ret = ops->flex_item_release (dev, handle, error);return flow_err (port_id, ret, error); } + +int +rte_flow_info_get (uint16_t port_id, +struct rte_flow_port_attr *port_attr, +struct rte_flow_error *error) +{ +struct rte_eth_dev *dev = &rte_eth_devices[port_id]; +const struct rte_flow_ops *ops =rte_flow_ops_get (port_id, error); + +if (unlikely (!ops)) +return -rte_errno; +if (likely (!!ops->info_get)) { +return flow_err (port_id, + ops->info_get (dev, port_attr, error), + error); + } +return rte_flow_error_set (error,ENOTSUP , +RTE_FLOW_ERROR_TYPE_UNSPECIFIED , +NULL ,rte_strerror (ENOTSUP )); +} + +int +rte_flow_configure (uint16_t port_id, +const struct rte_flow_port_attr *port_attr, +struct rte_flow_error *error) +{ +struct rte_eth_dev *dev = &rte_eth_devices[port_id]; +const struct rte_flow_ops *ops =rte_flow_ops_get (port_id, error); + +if (unlikely (!ops)) +return -rte_errno; +if (likely (!!ops->configure)) { +return flow_err (port_id, + ops->configure (dev, port_attr, error), + error); + } +return rte_flow_error_set (error,ENOTSUP , +RTE_FLOW_ERROR_TYPE_UNSPECIFIED , +NULL ,rte_strerror (ENOTSUP )); +}lib/ethdev/rte_flow.h +3
-0@@ -4853,6 +4853,88 @@ rte_flow_flex_item_release(uint16_t port_id,const struct rte_flow_item_flex_handle *handle, struct rte_flow_error *error); +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice.
lib/ethdev/rte_flow.h rte_flow_flex_item_release(uint16_t port_id, · line 4868
Quoted 10 lines
lib/ethdev/rte_flow.h +10
-0+* +* Resource pre-allocation settings. +* The zero value means on demand resource allocations only. +* +*/ +struct rte_flow_port_attr { +/** +* Version of the struct layout, should be 0. +*/ +uint32_t version;
IMO, it is not concluded to use the version in the public API.
Quoted 16 lines
lib/ethdev/rte_flow.h +16
-0+/** +* Number of counter actions pre-configured. +* @see RTE_FLOW_ACTION_TYPE_COUNT +*/ +uint32_t nb_counters; +/** +* Number of aging flows actions pre-configured. +* @see RTE_FLOW_ACTION_TYPE_AGE +*/ +uint32_t nb_aging_flows; +/** +* Number of traffic metering actions pre-configured. +* @see RTE_FLOW_ACTION_TYPE_METER +*/ +uint32_t nb_meters; +};
lib/ethdev/rte_flow.h rte_flow_flex_item_release(uint16_t port_id, · line 4894
Quoted 10 lines
lib/ethdev/rte_flow.h +10
-0+ +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Retrieve configuration attributes supported by the port. +* +* @param port_id +* Port identifier of Ethernet device. +* @param[in] port_attr
By default all parameters are "in", no need for additional "in" for just input.
Quoted 9 lines
lib/ethdev/rte_flow.h +9
-0+* Port configuration attributes. +* @param[out] error +* Perform verbose error reporting if not NULL. +* PMDs initialize this structure in case of error only. +* +* @return +* 0 on success, a negative errno value otherwise and rte_errno is set. +*/ +__rte_experimental
lib/ethdev/rte_flow.h rte_flow_flex_item_release(uint16_t port_id, · line 4913
Quoted 10 lines
lib/ethdev/rte_flow.h +10
-0+int +rte_flow_info_get (uint16_t port_id, +struct rte_flow_port_attr *port_attr, +struct rte_flow_error *error); + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Pre-configure the port's flow API engine.
IMO, s/ Pre-configure/Configure/
lib/ethdev/rte_flow.h rte_flow_flex_item_release(uint16_t port_id, · line 4924
Quoted 11 lines
lib/ethdev/rte_flow.h +11
-0+* +* This API can only be invoked before the application +* starts using the rest of the flow library functions. +* +* The API can be invoked multiple times to change the +* settings. The port, however, may reject the changes. +* +* @param port_id +* Port identifier of Ethernet device. +* @param[in] port_attr +* Port configuration attributes.
IMO, we need to have comments, the values should be <= the values got it from rte_flow_info_get().
Also 0 representations the default value.
Quoted 58 lines
lib/ethdev/rte_flow.h +13
-0+* @param[out] error +* Perform verbose error reporting if not NULL. +* PMDs initialize this structure in case of error only. +* +* @return +* 0 on success, a negative errno value otherwise and rte_errno is set. +*/ +__rte_experimental +int +rte_flow_configure (uint16_t port_id, +const struct rte_flow_port_attr *port_attr, +struct rte_flow_error *error); +#ifdef
__cplusplus
}
#endiflib/ethdev/rte_flow_driver.h +10
-0@@ -152,6 +152,16 @@ struct rte_flow_ops { (struct rte_eth_dev *dev, const struct rte_flow_item_flex_handle *handle, struct rte_flow_error *error); +/** See rte_flow_info_get() */ +int (*info_get) + (struct rte_eth_dev *dev, +struct rte_flow_port_attr *port_attr, +struct rte_flow_error *err); +/** See rte_flow_configure() */ +int (*configure) + (struct rte_eth_dev *dev, +const struct rte_flow_port_attr *port_attr, +struct rte_flow_error *err); };/** lib/ethdev/version.map +4
-1@@ -256,6 +256,10 @@ EXPERIMENTAL { rte_flow_flex_item_create; rte_flow_flex_item_release; rte_flow_pick_transfer_proxy; + + # added in 22.03 + rte_flow_info_get; + rte_flow_configure; }; INTERNAL { --2.18.2
RE: [PATCH v3 01/10] ethdev: introduce flow pre-configuration hints
Quoted 49 lines · On Monday, February 7, 2022 9:52 Jerin Jacob <[email protected]> wrote:
Quoted 27 lines · Alexander Kozyrev
The flow rules creation/destruction at a large scale incurs a performance penalty and may negatively impact the packet processing when used as part of the datapath logic. This is mainly because software/hardware resources are allocated and prepared during the flow rule creation.
In order to optimize the insertion rate, PMD may use some hints provided by the application at the initialization phase. The
rte_flow_configure()function allows to pre-allocate all the needed resources beforehand. These resources can be used at a later stage without costly allocations. Every PMD may use only the subset of hints and ignore unused ones or fail in case the requested configuration is not supported.The
rte_flow_info_get()is available to retrieve the information about supported pre-configurable resources. Both these functions must be called before any other usage of the flow API engine.Signed-off-by Alexander Kozyrev <[email protected]>--- doc/guides/prog_guide/rte_flow.rst | 37 ++++++++++++ doc/guides/rel_notes/release_22_03.rst | 4 ++ lib/ethdev/rte_flow.c | 40 +++++++++++++ lib/ethdev/rte_flow.h | 82 ++++++++++++++++++++++++++ lib/ethdev/rte_flow_driver.h | 10 ++++ lib/ethdev/version.map | 4 ++ 6 files changed, 177 insertions(+)Review
Quoted 1 line
(quoted diff) +0
-0
b/doc/guides/prog_guide/rte_flow.rstQuoted 4 lines
index
b4aa9c47c2..5b4c5dd609100644doc/guides/prog_guide/rte_flow.rst Return values: · line 3598
Quoted 10 lines
doc/guides/prog_guide/rte_flow.rst +7
-0@@ -3589,6 +3589,43 @@ Return values: - 0 on success, a negative errno value otherwise and ``rte_errno`` is set. +Flow engine configuration +------------------------- + +Configure flow API management. + +An application may provide some hints at the initialization phase about +rules engine configuration and/or expected flow rules characteristics.IMO, We can explicitly remove _hint_ in the documentation. When we add new paramers to configure, it may not be hit.
Quoted 4 lines
doc/guides/prog_guide/rte_flow.rst Return values: · line 3599
Quoted 1 line
doc/guides/prog_guide/rte_flow.rst +1
-0+These hints may be used by PMD to pre-allocate resources and configureNIC.
hints->parameters
Sounds good, let's call them parameters and PDM will decide to use them or not anyway.
Quoted 107 lines
doc/guides/prog_guide/rte_flow.rst Return values:
Quoted 6 lines
doc/guides/prog_guide/rte_flow.rst +6
-0+ +Configuration +~~~~~~~~~~~~~ + +This function performs the flow API management configuration and +pre-allocates needed resources beforehand to avoid costly allocationslater.
doc/guides/prog_guide/rte_flow.rst Return values: · line 3607
Quoted 2 lines
doc/guides/prog_guide/rte_flow.rst +2
-0+Hints about the expected number of counters or meters in an application, +for example, allow PMD to prepare and optimize NIC memory layout inadvance.
Review
Quoted 25 lines
doc/guides/prog_guide/rte_flow.rst +21
-0+``rte_flow_configure()`` must be called before any flow rule is created, +but after an Ethernet device is configured. + +.. code-block:: c + + int + rte_flow_configure(uint16_t port_id, + const struct rte_flow_port_attr *port_attr, + struct rte_flow_error *error); + +Information about resources that can benefit from pre-allocation can be +retrieved via ``rte_flow_info_get()`` API. It returns the maximum number +of pre-configurable resources for a given port on a system. + +.. code-block:: c + + int + rte_flow_info_get(uint16_t port_id, + struct rte_flow_port_attr *port_attr, + struct rte_flow_error *error); + .. _flow_isolated_mode: Flow isolated mode(quoted diff) +0
-0
b/doc/guides/rel_notes/release_22_03.rstdoc/guides/rel_notes/release_22_03.rst New Features · line 58
Quoted 8 lines
index
bf2e3f78a9..8593db3f6a100644doc/guides/rel_notes/release_22_03.rst +1
-0@@ -55,6 +55,10 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* ethdev: Added ``rte_flow_configure`` API to configure FlowManagement
Quoted 62 lines
doc/guides/rel_notes/release_22_03.rst +3
-0+ engine, allowing to pre-allocate some resources for better performance. + Added ``rte_flow_info_get`` API to retrieve pre-configurable resources. + * **Updated AF_XDP PMD** * Added support for libxdp >=v1.2.2.lib/ethdev/rte_flow.c +40
-0@@ -1391,3 +1391,43 @@ rte_flow_flex_item_release(uint16_t port_id, ret = ops->flex_item_release (dev, handle, error);return flow_err (port_id, ret, error); } + +int +rte_flow_info_get (uint16_t port_id, +struct rte_flow_port_attr *port_attr, +struct rte_flow_error *error) +{ +struct rte_eth_dev *dev = &rte_eth_devices[port_id]; +const struct rte_flow_ops *ops =rte_flow_ops_get (port_id, error); + +if (unlikely (!ops)) +return -rte_errno; +if (likely (!!ops->info_get)) { +return flow_err (port_id, + ops->info_get (dev, port_attr, error), + error); + } +return rte_flow_error_set (error,ENOTSUP , +RTE_FLOW_ERROR_TYPE_UNSPECIFIED , +NULL ,rte_strerror (ENOTSUP )); +} + +int +rte_flow_configure (uint16_t port_id, +const struct rte_flow_port_attr *port_attr, +struct rte_flow_error *error) +{ +struct rte_eth_dev *dev = &rte_eth_devices[port_id]; +const struct rte_flow_ops *ops =rte_flow_ops_get (port_id, error); + +if (unlikely (!ops)) +return -rte_errno; +if (likely (!!ops->configure)) { +return flow_err (port_id, + ops->configure (dev, port_attr, error), + error); + } +return rte_flow_error_set (error,ENOTSUP , +RTE_FLOW_ERROR_TYPE_UNSPECIFIED , +NULL ,rte_strerror (ENOTSUP )); +}lib/ethdev/rte_flow.h +0
-0@@ -4853,6 +4853,88 @@ rte_flow_flex_item_release(uint16_t port_id,const struct rte_flow_item_flex_handle *handle, struct rte_flow_error *error);
Quoted 15 lines
lib/ethdev/rte_flow.h rte_flow_flex_item_release(uint16_t port_id, · line 4868
Quoted 13 lines
lib/ethdev/rte_flow.h +13
-0+/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Resource pre-allocation settings. +* The zero value means on demand resource allocations only. +* +*/ +struct rte_flow_port_attr { +/** +* Version of the struct layout, should be 0. +*/ +uint32_t version;IMO, it is not concluded to use the version in the public API.
Yes, there is ongoing discussion on how to properly address versioning right now. But I would like to proceed with this API without having to wait the final decision on that. My API is experimental and it is possible to switch to any versioning model after.
Quoted 21 lines
Quoted 21 lines
lib/ethdev/rte_flow.h +20
-0+/** +* Number of counter actions pre-configured. +* @see RTE_FLOW_ACTION_TYPE_COUNT +*/ +uint32_t nb_counters; +/** +* Number of aging flows actions pre-configured. +* @see RTE_FLOW_ACTION_TYPE_AGE +*/ +uint32_t nb_aging_flows; +/** +* Number of traffic metering actions pre-configured. +* @see RTE_FLOW_ACTION_TYPE_METER +*/ +uint32_t nb_meters; +}; + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice.
Quoted 8 lines
lib/ethdev/rte_flow.h rte_flow_flex_item_release(uint16_t port_id, · line 4894
Quoted 6 lines
lib/ethdev/rte_flow.h +6
-0+* +* Retrieve configuration attributes supported by the port. +* +* @param port_id +* Port identifier of Ethernet device. +* @param[in] port_attr By default all parameters are "in", no need for additional "in" for just input.
"in" or "out" is a part of description of every pointer parameter throughout rte_flow.h
Quoted 13 lines
Quoted 13 lines
lib/ethdev/rte_flow.h +13
-0+* Port configuration attributes. +* @param[out] error +* Perform verbose error reporting if not NULL. +* PMDs initialize this structure in case of error only. +* +* @return +* 0 on success, a negative errno value otherwise and rte_errno is set. +*/ +__rte_experimental +int +rte_flow_info_get (uint16_t port_id, +struct rte_flow_port_attr *port_attr, +struct rte_flow_error *error);
Quoted 8 lines
lib/ethdev/rte_flow.h rte_flow_flex_item_release(uint16_t port_id, · line 4913
Quoted 6 lines
lib/ethdev/rte_flow.h +6
-0+ +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Pre-configure the port's flow API engine. IMO, s/ Pre-configure/Configure/
No problem.
Quoted 12 lines
lib/ethdev/rte_flow.h rte_flow_flex_item_release(uint16_t port_id, · line 4924
Quoted 11 lines
lib/ethdev/rte_flow.h +11
-0+* +* This API can only be invoked before the application +* starts using the rest of the flow library functions. +* +* The API can be invoked multiple times to change the +* settings. The port, however, may reject the changes. +* +* @param port_id +* Port identifier of Ethernet device. +* @param[in] port_attr +* Port configuration attributes.
Quoted 4 lines
IMO, we need to have comments, the values should be <= the values got it from
rte_flow_info_get().Also 0 representations the default value.
Will add these comments, thank you.
Quoted 58 lines
Quoted 58 lines
lib/ethdev/rte_flow.h +13
-0+* @param[out] error +* Perform verbose error reporting if not NULL. +* PMDs initialize this structure in case of error only. +* +* @return +* 0 on success, a negative errno value otherwise and rte_errno is set. +*/ +__rte_experimental +int +rte_flow_configure (uint16_t port_id, +const struct rte_flow_port_attr *port_attr, +struct rte_flow_error *error); +#ifdef
__cplusplus
}
#endiflib/ethdev/rte_flow_driver.h +10
-0@@ -152,6 +152,16 @@ struct rte_flow_ops { (struct rte_eth_dev *dev, const struct rte_flow_item_flex_handle *handle, struct rte_flow_error *error); +/** See rte_flow_info_get() */ +int (*info_get) + (struct rte_eth_dev *dev, +struct rte_flow_port_attr *port_attr, +struct rte_flow_error *err); +/** See rte_flow_configure() */ +int (*configure) + (struct rte_eth_dev *dev, +const struct rte_flow_port_attr *port_attr, +struct rte_flow_error *err); };/** lib/ethdev/version.map +4
-1@@ -256,6 +256,10 @@ EXPERIMENTAL { rte_flow_flex_item_create; rte_flow_flex_item_release; rte_flow_pick_transfer_proxy; + + # added in 22.03 + rte_flow_info_get; + rte_flow_configure; }; INTERNAL { --2.18.2
Re: [PATCH v3 01/10] ethdev: introduce flow pre-configuration hints
Quoted 64 lines · Alexander Kozyrev
Quoted 49 lines · On Monday, February 7, 2022 9:52 Jerin Jacob <[email protected]> wrote:
Quoted 27 lines · Alexander Kozyrev
The flow rules creation/destruction at a large scale incurs a performance penalty and may negatively impact the packet processing when used as part of the datapath logic. This is mainly because software/hardware resources are allocated and prepared during the flow rule creation.
In order to optimize the insertion rate, PMD may use some hints provided by the application at the initialization phase. The
rte_flow_configure()function allows to pre-allocate all the needed resources beforehand. These resources can be used at a later stage without costly allocations. Every PMD may use only the subset of hints and ignore unused ones or fail in case the requested configuration is not supported.The
rte_flow_info_get()is available to retrieve the information about supported pre-configurable resources. Both these functions must be called before any other usage of the flow API engine.Signed-off-by Alexander Kozyrev <[email protected]>--- doc/guides/prog_guide/rte_flow.rst | 37 ++++++++++++ doc/guides/rel_notes/release_22_03.rst | 4 ++ lib/ethdev/rte_flow.c | 40 +++++++++++++ lib/ethdev/rte_flow.h | 82 ++++++++++++++++++++++++++ lib/ethdev/rte_flow_driver.h | 10 ++++ lib/ethdev/version.map | 4 ++ 6 files changed, 177 insertions(+)Review
Quoted 1 line
(quoted diff) +0
-0
b/doc/guides/prog_guide/rte_flow.rstQuoted 4 lines
index
b4aa9c47c2..5b4c5dd609100644doc/guides/prog_guide/rte_flow.rst Return values: · line 3598
Quoted 10 lines
doc/guides/prog_guide/rte_flow.rst +7
-0@@ -3589,6 +3589,43 @@ Return values: - 0 on success, a negative errno value otherwise and ``rte_errno`` is set. +Flow engine configuration +------------------------- + +Configure flow API management. + +An application may provide some hints at the initialization phase about +rules engine configuration and/or expected flow rules characteristics.IMO, We can explicitly remove _hint_ in the documentation. When we add new paramers to configure, it may not be hit.
Quoted 4 lines
doc/guides/prog_guide/rte_flow.rst Return values: · line 3599
Quoted 1 line
doc/guides/prog_guide/rte_flow.rst +1
-0+These hints may be used by PMD to pre-allocate resources and configureNIC.
hints->parametersSounds good, let's call them parameters and PDM will decide to use them or not anyway.
Quoted 7 lines
Quoted 6 lines
doc/guides/prog_guide/rte_flow.rst +6
-0+ */ +struct rte_flow_port_attr { + /** + * Version of the struct layout, should be 0. + */ + uint32_t version;
Quoted 5 lines
Quoted 1 line
IMO, it is not concluded to use the version in the public API.
Yes, there is ongoing discussion on how to properly address versioning right now. But I would like to proceed with this API without having to wait the final decision on that. My API is experimental and it is possible to switch to any versioning model after.
+ @Richardson, Bruce
On the same note, since it is experimental, we can add the version when we needed.
I think, the primary pushback is application should not be aware of version, instead,
implementation probe the version and adjust accordingly.
IMO, In order to make forward progress, I suggest having the next version of the patch with without
version and we can introduce this topic to TB for a final decision one way or another.
Quoted 31 lines
Quoted 22 lines
Quoted 22 lines
doc/guides/prog_guide/rte_flow.rst +20
-0+ /** + * Number of counter actions pre-configured. + * @see RTE_FLOW_ACTION_TYPE_COUNT + */ + uint32_t nb_counters; + /** + * Number of aging flows actions pre-configured. + * @see RTE_FLOW_ACTION_TYPE_AGE + */ + uint32_t nb_aging_flows; + /** + * Number of traffic metering actions pre-configured. + * @see RTE_FLOW_ACTION_TYPE_METER + */ + uint32_t nb_meters; +}; + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice.Quoted 8 lines
doc/guides/prog_guide/rte_flow.rst Return values: · line 3631
Quoted 6 lines
doc/guides/prog_guide/rte_flow.rst +6
-0+ * + * Retrieve configuration attributes supported by the port. + * + * @param port_id + * Port identifier of Ethernet device. + * @param[in] port_attrBy default all parameters are "in", no need for additional "in" for just input.
Quoted 1 line
"in" or "out" is a part of description of every pointer parameter throughout
rte_flow.h
Ack.
PATCH v3 2/10 ethdev: add flow item/action templates
In reply to Alexander KozyrevTreating every single flow rule as a completely independent and separate entity negatively impacts the flow rules insertion rate. Oftentimes in an application, many flow rules share a common structure (the same item mask and/or action list) so they can be grouped and classified together. This knowledge may be used as a source of optimization by a PMD/HW.
The pattern template defines common matching fields (the item mask) without values. The actions template holds a list of action types that will be used together in the same rule. The specific values for items and actions will be given only during the rule creation.
A table combines pattern and actions templates along with shared flow rule attributes (group ID, priority and traffic direction). This way a PMD/HW can prepare all the resources needed for efficient flow rules creation in the datapath. To avoid any hiccups due to memory reallocation, the maximum number of flow rules is defined at the table creation time.
The flow rule creation is done by selecting a table, a pattern template and an actions template (which are bound to the table), and setting unique values for the items and actions.
--- doc/guides/prog_guide/rte_flow.rst | 124 +++++++++++ doc/guides/rel_notes/release_22_03.rst | 8 + lib/ethdev/rte_flow.c | 141 +++++++++++++ lib/ethdev/rte_flow.h | 274 +++++++++++++++++++++++++ lib/ethdev/rte_flow_driver.h | 37 ++++ lib/ethdev/version.map | 6 + 6 files changed, 590 insertions(+)
doc/guides/prog_guide/rte_flow.rst +124 -0
@@ -3626,6 +3626,130 @@ of pre-configurable resources for a given port on a system. struct rte_flow_port_attr *port_attr, struct rte_flow_error *error); +Flow templates +~~~~~~~~~~~~~~ + +Oftentimes in an application, many flow rules share a common structure +(the same pattern and/or action list) so they can be grouped and classified +together. This knowledge may be used as a source of optimization by a PMD/HW. +The flow rule creation is done by selecting a table, a pattern template +and an actions template (which are bound to the table), and setting unique +values for the items and actions. This API is not thread-safe. + +Pattern templates +^^^^^^^^^^^^^^^^^ + +The pattern template defines a common pattern (the item mask) without values. +The mask value is used to select a field to match on, spec/last are ignored. +The pattern template may be used by multiple tables and must not be destroyed +until all these tables are destroyed first. + +.. code-block:: c + + struct rte_flow_pattern_template * + rte_flow_pattern_template_create(uint16_t port_id, + const struct rte_flow_pattern_template_attr *template_attr, + const struct rte_flow_item pattern[], + struct rte_flow_error *error); + +For example, to create a pattern template to match on the destination MAC: + +.. code-block:: c + + struct rte_flow_item pattern[2] = {{0}}; + struct rte_flow_item_eth eth_m = {0}; + pattern[0].type = RTE_FLOW_ITEM_TYPE_ETH; + eth_m.dst.addr_bytes = "\xff\xff\xff\xff\xff\xff"; + pattern[0].mask = ð_m; + pattern[1].type = RTE_FLOW_ITEM_TYPE_END; + + struct rte_flow_pattern_template *pattern_template = + rte_flow_pattern_template_create(port, &itr, &pattern, &error); + +The concrete value to match on will be provided at the rule creation. + +Actions templates +^^^^^^^^^^^^^^^^^ + +The actions template holds a list of action types to be used in flow rules. +The mask parameter allows specifying a shared constant value for every rule. +The actions template may be used by multiple tables and must not be destroyed +until all these tables are destroyed first. + +.. code-block:: c + + struct rte_flow_actions_template * + rte_flow_actions_template_create(uint16_t port_id, + const struct rte_flow_actions_template_attr *template_attr, + const struct rte_flow_action actions[], + const struct rte_flow_action masks[], + struct rte_flow_error *error); + +For example, to create an actions template with the same Mark ID +but different Queue Index for every rule: + +.. code-block:: c + + struct rte_flow_action actions[] = { + /* Mark ID is constant (4) for every rule, Queue Index is unique */ + [0] = {.type = RTE_FLOW_ACTION_TYPE_MARK, + .conf = &(struct rte_flow_action_mark){.id = 4}}, + [1] = {.type = RTE_FLOW_ACTION_TYPE_QUEUE}, + [2] = {.type = RTE_FLOW_ACTION_TYPE_END,}, + }; + struct rte_flow_action masks[] = { + /* Assign to MARK mask any non-zero value to make it constant */ + [0] = {.type = RTE_FLOW_ACTION_TYPE_MARK, + .conf = &(struct rte_flow_action_mark){.id = 1}}, + [1] = {.type = RTE_FLOW_ACTION_TYPE_QUEUE}, + [2] = {.type = RTE_FLOW_ACTION_TYPE_END,}, + }; + + struct rte_flow_actions_template *at = + rte_flow_actions_template_create(port, &atr, &actions, &masks, &error); + +The concrete value for Queue Index will be provided at the rule creation. + +Flow table +^^^^^^^^^^ + +A table combines a number of pattern and actions templates along with shared flow +rule attributes (group ID, priority and traffic direction). This way a PMD/HW +can prepare all the resources needed for efficient flow rules creation in +the datapath. To avoid any hiccups due to memory reallocation, the maximum +number of flow rules is defined at table creation time. Any flow rule +creation beyond the maximum table size is rejected. Application may create +another table to accommodate more rules in this case. + +.. code-block:: c + + struct rte_flow_table * + rte_flow_table_create(uint16_t port_id, + const struct rte_flow_table_attr *table_attr, + struct rte_flow_pattern_template *pattern_templates[], + uint8_t nb_pattern_templates, + struct rte_flow_actions_template *actions_templates[], + uint8_t nb_actions_templates, + struct rte_flow_error *error); + +A table can be created only after the Flow Rules management is configured +and pattern and actions templates are created. + +.. code-block:: c + + rte_flow_configure(port, *port_attr, *error); + + struct rte_flow_pattern_template *pattern_templates[0] = + rte_flow_pattern_template_create(port, &itr, &pattern, &error); + struct rte_flow_actions_template *actions_templates[0] = + rte_flow_actions_template_create(port, &atr, &actions, &masks, &error); + + struct rte_flow_table *table = + rte_flow_table_create(port, *table_attr, + *pattern_templates, nb_pattern_templates, + *actions_templates, nb_actions_templates, + *error); + .. _flow_isolated_mode: Flow isolated mode
doc/guides/rel_notes/release_22_03.rst +8 -0
@@ -59,6 +59,14 @@ New Features engine, allowing to pre-allocate some resources for better performance. Added ``rte_flow_info_get`` API to retrieve pre-configurable resources. +* ethdev: Added ``rte_flow_table_create`` API to group flow rules with + the same flow attributes and common matching patterns and actions + defined by ``rte_flow_pattern_template_create`` and + ``rte_flow_actions_template_create`` respectively. + Corresponding functions to destroy these entities are: + ``rte_flow_table_destroy``, ``rte_flow_pattern_template_destroy`` + and ``rte_flow_actions_template_destroy``. + * **Updated AF_XDP PMD** * Added support for libxdp >=v1.2.2.
lib/ethdev/rte_flow.c +141 -0
144 lines not on this page · raw message
lib/ethdev/rte_flow.h +274 -0
280 lines not on this page · raw message
lib/ethdev/rte_flow_driver.h +37 -0
@@ -162,6 +162,43 @@ struct rte_flow_ops { (struct rte_eth_dev *dev, const struct rte_flow_port_attr *port_attr, struct rte_flow_error *err); +/** See rte_flow_pattern_template_create() */ +struct rte_flow_pattern_template *(*pattern_template_create) + (struct rte_eth_dev *dev, +const struct rte_flow_pattern_template_attr *template_attr, +const struct rte_flow_item pattern[], +struct rte_flow_error *err); +/** See rte_flow_pattern_template_destroy() */ +int (*pattern_template_destroy) + (struct rte_eth_dev *dev, +struct rte_flow_pattern_template *pattern_template, +struct rte_flow_error *err); +/** See rte_flow_actions_template_create() */ +struct rte_flow_actions_template *(*actions_template_create) + (struct rte_eth_dev *dev, +const struct rte_flow_actions_template_attr *template_attr, +const struct rte_flow_action actions[], +const struct rte_flow_action masks[], +struct rte_flow_error *err); +/** See rte_flow_actions_template_destroy() */ +int (*actions_template_destroy) + (struct rte_eth_dev *dev, +struct rte_flow_actions_template *actions_template, +struct rte_flow_error *err); +/** See rte_flow_table_create() */ +struct rte_flow_table *(*table_create) + (struct rte_eth_dev *dev, +const struct rte_flow_table_attr *table_attr, +struct rte_flow_pattern_template *pattern_templates[], +uint8_t nb_pattern_templates, +struct rte_flow_actions_template *actions_templates[], +uint8_t nb_actions_templates, +struct rte_flow_error *err); +/** See rte_flow_table_destroy() */ +int (*table_destroy) + (struct rte_eth_dev *dev, +struct rte_flow_table *table, +struct rte_flow_error *err); };/**
lib/ethdev/version.map +6 -0
@@ -260,6 +260,12 @@ EXPERIMENTAL { # added in 22.03 rte_flow_info_get; rte_flow_configure; + rte_flow_pattern_template_create; + rte_flow_pattern_template_destroy; + rte_flow_actions_template_create; + rte_flow_actions_template_destroy; + rte_flow_table_create; + rte_flow_table_destroy; }; INTERNAL {
Signature · 1 line
2.18.2
RE: [PATCH v3 02/10] ethdev: add flow item/action templates
Hi Alexander,
Quoted 22 lines
-----Original Message-----
From: Alexander Kozyrev <[email protected]>
Sent: Sunday, February 6, 2022 5:25 AM
Subject: [PATCH v3 02/10] ethdev: add flow item/action templatesTreating every single flow rule as a completely independent and separate entity negatively impacts the flow rules insertion rate. Oftentimes in an application, many flow rules share a common structure (the same item mask and/or action list) so they can be grouped and classified together. This knowledge may be used as a source of optimization by a PMD/HW.
The pattern template defines common matching fields (the item mask) without values. The actions template holds a list of action types that will be used together in the same rule. The specific values for items and actions will be given only during the rule creation.
A table combines pattern and actions templates along with shared flow rule attributes (group ID, priority and traffic direction). This way a PMD/HW can prepare all the resources needed for efficient flow rules creation in the datapath. To avoid any hiccups due to memory reallocation, the maximum number of flow rules is defined at the table creation time.
Quoted 6 lines
The flow rule creation is done by selecting a table, a pattern template and an actions template (which are bound to the table), and setting unique values for the items and actions.
Signed-off-by Alexander Kozyrev <[email protected]>---
Best,
Ori
PATCH v3 3/10 ethdev: bring in async queue-based flow rules operations
In reply to Alexander KozyrevA new, faster, queue-based flow rules management mechanism is needed for applications offloading rules inside the datapath. This asynchronous and lockless mechanism frees the CPU for further packet processing and reduces the performance impact of the flow rules creation/destruction on the datapath. Note that queues are not thread-safe and the queue should be accessed from the same thread for all queue operations. It is the responsibility of the app to sync the queue functions in case of multi-threaded access to the same queue.
The rte_flow_q_flow_create() function enqueues a flow creation to the requested queue. It benefits from already configured resources and sets unique values on top of item and action templates. A flow rule is enqueued on the specified flow queue and offloaded asynchronously to the hardware. The function returns immediately to spare CPU for further packet processing. The application must invoke the rte_flow_q_pull() function to complete the flow rule operation offloading, to clear the queue, and to receive the operation status. The rte_flow_q_flow_destroy() function enqueues a flow destruction to the requested queue.
--- doc/guides/prog_guide/img/rte_flow_q_init.svg | 71 ++++ .../prog_guide/img/rte_flow_q_usage.svg | 60 +++ doc/guides/prog_guide/rte_flow.rst | 159 +++++++- doc/guides/rel_notes/release_22_03.rst | 8 + lib/ethdev/rte_flow.c | 173 ++++++++- lib/ethdev/rte_flow.h | 342 ++++++++++++++++++ lib/ethdev/rte_flow_driver.h | 55 +++ lib/ethdev/version.map | 7 + 8 files changed, 873 insertions(+), 2 deletions(-) create mode 100644 doc/guides/prog_guide/img/rte_flow_q_init.svg create mode 100644 doc/guides/prog_guide/img/rte_flow_q_usage.svg
doc/guides/prog_guide/img/rte_flow_q_init.svg new file +71 -0
@@ -0,0 +1,71 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- SPDX-License-Identifier: BSD-3-Clause --> +<!-- Copyright(c) 2022 NVIDIA Corporation & Affiliates --> + +<svg + width="485" height="535" + xmlns="http://www.w3.org/2000/svg" + xmlns:xlink="http://www.w3.org/1999/xlink" + overflow="hidden"> + <defs> + <clipPath id="clip0"> + <rect x="0" y="0" width="485" height="535"/> + </clipPath> + </defs> + <g clip-path="url(#clip0)"> + <rect x="0" y="0" width="485" height="535" fill="#FFFFFF"/> + <rect x="0.500053" y="79.5001" width="482" height="59" + stroke="#000000" stroke-width="1.33333" stroke-miterlimit="8" + fill="#A6A6A6"/> + <text font-family="Calibri,Calibri_MSFontService,sans-serif" + font-weight="400" font-size="24" transform="translate(121.6 116)"> + rte_eth_dev_configure + <tspan font-size="24" x="224.007" y="0">()</tspan> + </text> + <rect x="0.500053" y="158.5" width="482" height="59" stroke="#000000" + stroke-width="1.33333" stroke-miterlimit="8" fill="#FFFFFF"/> + <text font-family="Calibri,Calibri_MSFontService,sans-serif" + font-weight="400" font-size="24" transform="translate(140.273 195)"> + rte_flow_configure() + </text> + <rect x="0.500053" y="236.5" width="482" height="60" stroke="#000000" + stroke-width="1.33333" stroke-miterlimit="8" fill="#FFFFFF"/> + <text font-family="Calibri,Calibri_MSFontService,sans-serif" + font-weight="400" font-size="24" transform="translate(77.4259 274)"> + rte_flow_pattern_template_create() + </text> + <rect x="0.500053" y="316.5" width="482" height="59" stroke="#000000" + stroke-width="1.33333" stroke-miterlimit="8" fill="#FFFFFF"/> + <text font-family="Calibri,Calibri_MSFontService,sans-serif" + font-weight="400" font-size="24" transform="translate(69.3792 353)"> + rte_flow_actions_template_create + <tspan font-size="24" x="328.447" y="0">(</tspan>) + </text> + <rect x="0.500053" y="0.500053" width="482" height="60" stroke="#000000" + stroke-width="1.33333" stroke-miterlimit="8" fill="#A6A6A6"/> + <text font-family="Calibri,Calibri_MSFontService,sans-serif" + font-weight="400" font-size="24" transform="translate(177.233 37)"> + rte_eal_init + <tspan font-size="24" x="112.74" y="0">()</tspan> + </text> + <path d="M2-1.09108e-05 2.00005 9.2445-1.99995 9.24452-2 1.09108e-05ZM6.00004 7.24448 0.000104987 19.2445-5.99996 7.24455Z" transform="matrix(-1 0 0 1 241 60)"/> + <path d="M2-1.08133e-05 2.00005 9.41805-1.99995 9.41807-2 1.08133e-05ZM6.00004 7.41802 0.000104987 19.4181-5.99996 7.41809Z" transform="matrix(-1 0 0 1 241 138)"/> + <path d="M2-1.09108e-05 2.00005 9.2445-1.99995 9.24452-2 1.09108e-05ZM6.00004 7.24448 0.000104987 19.2445-5.99996 7.24455Z" transform="matrix(-1 0 0 1 241 217)"/> + <rect x="0.500053" y="395.5" width="482" height="59" stroke="#000000" + stroke-width="1.33333" stroke-miterlimit="8" fill="#FFFFFF"/> + <text font-family="Calibri,Calibri_MSFontService,sans-serif" + font-weight="400" font-size="24" transform="translate(124.989 432)"> + rte_flow_table_create + <tspan font-size="24" x="217.227" y="0">(</tspan> + <tspan font-size="24" x="224.56" y="0">)</tspan> + </text> + <path d="M2-1.05859e-05 2.00005 9.83526-1.99995 9.83529-2 1.05859e-05ZM6.00004 7.83524 0.000104987 19.8353-5.99996 7.83531Z" transform="matrix(-1 0 0 1 241 296)"/> + <path d="M243 375 243 384.191 239 384.191 239 375ZM247 382.191 241 394.191 235 382.191Z"/> + <rect x="0.500053" y="473.5" width="482" height="60" stroke="#000000" + stroke-width="1.33333" stroke-miterlimit="8" fill="#A6A6A6"/> + <text font-family="Calibri,Calibri_MSFontService,sans-serif" + font-weight="400" font-size="24" transform="translate(145.303 511)"> + rte_eth_dev_start()</text> + <path d="M245 454 245 463.191 241 463.191 241 454ZM249 461.191 243 473.191 237 461.191Z"/> + </g> +</svg>
doc/guides/prog_guide/img/rte_flow_q_usage.svg new file +60 -0
61 lines not on this page · raw message
doc/guides/prog_guide/rte_flow.rst +158 -1
183 lines not on this page · raw message
doc/guides/rel_notes/release_22_03.rst +8 -0
@@ -67,6 +67,14 @@ New Features ``rte_flow_table_destroy``, ``rte_flow_pattern_template_destroy`` and ``rte_flow_actions_template_destroy``. +* ethdev: Added ``rte_flow_q_flow_create`` and ``rte_flow_q_flow_destroy`` API + to enqueue flow creaion/destruction operations asynchronously as well as + ``rte_flow_q_pull`` to poll and retrieve results of these operations and + ``rte_flow_q_push`` to push all the in-flight operations to the NIC. + Introduced asynchronous API for indirect actions management as well: + ``rte_flow_q_action_handle_create``, ``rte_flow_q_action_handle_destroy`` and + ``rte_flow_q_action_handle_update``. + * **Updated AF_XDP PMD** * Added support for libxdp >=v1.2.2.
lib/ethdev/rte_flow.c +172 -1
188 lines not on this page · raw message
lib/ethdev/rte_flow.h +342 -0
366 lines not on this page · raw message
lib/ethdev/rte_flow_driver.h +55 -0
67 lines not on this page · raw message
lib/ethdev/version.map +7 -0
@@ -266,6 +266,13 @@ EXPERIMENTAL { rte_flow_actions_template_destroy; rte_flow_table_create; rte_flow_table_destroy; + rte_flow_q_flow_create; + rte_flow_q_flow_destroy; + rte_flow_q_action_handle_create; + rte_flow_q_action_handle_destroy; + rte_flow_q_action_handle_update; + rte_flow_q_push; + rte_flow_q_pull; }; INTERNAL {
Signature · 1 line
2.18.2
RE: [PATCH v3 03/10] ethdev: bring in async queue-based flow rules operations
HI Alexander,
Quoted 29 lines
-----Original Message-----
From: Alexander Kozyrev <[email protected]>
Sent: Sunday, February 6, 2022 5:25 AM
To: [email protected]
Cc: Ori Kam <[email protected]>; NBU-Contact-Thomas Monjalon (EXTERNAL) <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH v3 03/10] ethdev: bring in async queue-based flow rules operationsA new, faster, queue-based flow rules management mechanism is needed for applications offloading rules inside the datapath. This asynchronous and lockless mechanism frees the CPU for further packet processing and reduces the performance impact of the flow rules creation/destruction on the datapath. Note that queues are not thread-safe and the queue should be accessed from the same thread for all queue operations. It is the responsibility of the app to sync the queue functions in case of multi-threaded access to the same queue.
The
rte_flow_q_flow_create()function enqueues a flow creation to the requested queue. It benefits from already configured resources and sets unique values on top of item and action templates. A flow rule is enqueued on the specified flow queue and offloaded asynchronously to the hardware. The function returns immediately to spare CPU for further packet processing. The application must invoke therte_flow_q_pull()function to complete the flow rule operation offloading, to clear the queue, and to receive the operation status. Therte_flow_q_flow_destroy()function enqueues a flow destruction to the requested queue.
Quoted 2 lines
Signed-off-by Alexander Kozyrev <[email protected]>---
Best,
Ori
Re: [PATCH v3 03/10] ethdev: bring in async queue-based flow rules operations
In reply to Alexander KozyrevQuoted 10 lines · Alexander Kozyrev
A new, faster, queue-based flow rules management mechanism is needed for applications offloading rules inside the datapath. This asynchronous and lockless mechanism frees the CPU for further packet processing and reduces the performance impact of the flow rules creation/destruction on the datapath. Note that queues are not thread-safe and the queue should be accessed from the same thread for all queue operations. It is the responsibility of the app to sync the queue functions in case of multi-threaded access to the same queue.
Quoted 9 lines
The
rte_flow_q_flow_create()function enqueues a flow creation to the requested queue. It benefits from already configured resources and sets unique values on top of item and action templates. A flow rule is enqueued on the specified flow queue and offloaded asynchronously to the hardware. The function returns immediately to spare CPU for further packet processing. The application must invoke therte_flow_q_pull()function to complete the flow rule operation offloading, to clear the queue, and to receive the operation status. Therte_flow_q_flow_destroy()function enqueues a flow destruction to the requested queue.
It is good to see the implementation, specifically to understand,
1)
I understand, We are creating queues to make multiple producers to enqueue multiple jobs in parallel.
On the consumer side, Is it HW or some other cores to consume the job? Can we operate in consumer in parallel?
2) Is Queue part of HW or just SW primitive to submit the work as a channel.
doc/guides/prog_guide/img/rte_flow_q_init.svg
Quoted 18 lines
Signed-off-by Alexander Kozyrev <[email protected]>--- doc/guides/prog_guide/img/rte_flow_q_init.svg | 71 ++++ .../prog_guide/img/rte_flow_q_usage.svg | 60 +++ doc/guides/prog_guide/rte_flow.rst | 159 +++++++- doc/guides/rel_notes/release_22_03.rst | 8 + lib/ethdev/rte_flow.c | 173 ++++++++- lib/ethdev/rte_flow.h | 342 ++++++++++++++++++ lib/ethdev/rte_flow_driver.h | 55 +++ lib/ethdev/version.map | 7 + 8 files changed, 873 insertions(+), 2 deletions(-) create mode 100644 doc/guides/prog_guide/img/rte_flow_q_init.svg create mode 100644 doc/guides/prog_guide/img/rte_flow_q_usage.svgdoc/guides/prog_guide/img/rte_flow_q_init.svg new file +0
-0
Some comments on the diagrams:
# rte_flow_q_create_flow and rte_flow_q_destroy_flow used instead of rte_flow_q_flow_create/destroy # rte_flow_q_pull's brackets(i.e ()) not aligned
Quoted 9 lines
+</svg>
\ No newline at end of filedoc/guides/prog_guide/rte_flow.rst +0
-0@@ -3607,12 +3607,16 @@ Hints about the expected number of counters or meters in an application, for example, allow PMD to prepare and optimize NIC memory layout in advance. ``rte_flow_configure()`` must be called before any flow rule is created,
doc/guides/prog_guide/rte_flow.rst Hints about the expected number of counters or meters in an application, · line 3618
Quoted 10 lines
doc/guides/prog_guide/rte_flow.rst +3
-0but after an Ethernet device is configured. +It also creates flow queues for asynchronous flow rules operations via +queue-based API, see `Asynchronous operations`_ section. .. code-block:: c int rte_flow_configure(uint16_t port_id, const struct rte_flow_port_attr *port_attr, + uint16_t nb_queue,
# rte_flow_info_get() don't have number of queues, why not adding number queues in rte_flow_port_attr.
# And additional APIs for queue_setup() like ethdev.
Quoted 23 lines
doc/guides/prog_guide/rte_flow.rst +8
-1+ const struct rte_flow_queue_attr *queue_attr[], struct rte_flow_error *error); Information about resources that can benefit from pre-allocation can be@@ -3737,7 +3741,7 @@ and pattern and actions templates are created. .. code-block:: c - rte_flow_configure(port, *port_attr, *error); + rte_flow_configure(port, *port_attr, nb_queue, *queue_attr, *error); struct rte_flow_pattern_template *pattern_templates[0] = rte_flow_pattern_template_create(port, &itr, &pattern, &error);@@ -3750,6 +3754,159 @@ and pattern and actions templates are created. *actions_templates, nb_actions_templates, *error); +Asynchronous operations +----------------------- + +Flow rules management can be done via special lockless flow management queues. +- Queue operations are asynchronous and not thread-safe. +- Operations can thus be invoked by the app's datapath,
doc/guides/prog_guide/rte_flow.rst and pattern and actions templates are created. · line 3772
Quoted 10 lines
doc/guides/prog_guide/rte_flow.rst +10
-0+packet processing can continue while queue operations are processed by NIC. +- The queue number is configured at initialization stage. +- Available operation types: rule creation, rule destruction, +indirect rule creation, indirect rule destruction, indirect rule update. +- Operations may be reordered within a queue. +- Operations can be postponed and pushed to NIC in batches. +- Results pulling must be done on time to avoid queue overflows. +- User data is returned as part of the result to identify an operation. +- Flow handle is valid once the creation operation is enqueued and must be +destroyed even if the operation is not successful and the rule is not inserted.
You need CR between lines as rendered text does comes as new line in between the items.
Quoted 4 lines
doc/guides/prog_guide/rte_flow.rst +4
-0+ +The asynchronous flow rule insertion logic can be broken into two phases. + +1. Initialization stage as shown here:
doc/guides/prog_guide/rte_flow.rst and pattern and actions templates are created. · line 3786
Quoted 10 lines
doc/guides/prog_guide/rte_flow.rst +10
-0+ +.. _figure_rte_flow_q_init: + +.. figure:: img/rte_flow_q_init.* + +2. Main loop as presented on a datapath application example: + +.. _figure_rte_flow_q_usage: + +.. figure:: img/rte_flow_q_usage.*
it is better to add sequence operations as text to understand the flow.
doc/guides/prog_guide/rte_flow.rst and pattern and actions templates are created. · line 3791
Quoted 5 lines
doc/guides/prog_guide/rte_flow.rst +5
-0+ +Enqueue creation operation +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Enqueueing a flow rule creation operation is similar to simple creation.
If it is enqueue operation, why not call it ad rte_flow_q_flow_enqueue()
doc/guides/prog_guide/rte_flow.rst and pattern and actions templates are created. · line 3802
Quoted 11 lines
doc/guides/prog_guide/rte_flow.rst +11
-0+ +.. code-block:: c + + struct rte_flow * + rte_flow_q_flow_create(uint16_t port_id, + uint32_t queue_id, + const struct rte_flow_q_ops_attr *q_ops_attr, + struct rte_flow_table *table, + const struct rte_flow_item pattern[], + uint8_t pattern_template_index, + const struct rte_flow_action actions[],
If I understand correctly, table is the pre-configured object that has N number of patterns and N number of actions.
Why giving items[] and actions[] again?
doc/guides/prog_guide/rte_flow.rst and pattern and actions templates are created. · line 3810
Quoted 8 lines
doc/guides/prog_guide/rte_flow.rst +8
-0+ uint8_t actions_template_index, + struct rte_flow_error *error); + +A valid handle in case of success is returned. It must be destroyed later +by calling ``rte_flow_q_flow_destroy()`` even if the rule is rejected by HW. + +Enqueue destruction operation +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Queue destruction operation.
Quoted 51 lines
doc/guides/prog_guide/rte_flow.rst +51
-0+ +Enqueueing a flow rule destruction operation is similar to simple destruction. + +.. code-block:: c + + int + rte_flow_q_flow_destroy(uint16_t port_id, + uint32_t queue_id, + const struct rte_flow_q_ops_attr *q_ops_attr, + struct rte_flow *flow, + struct rte_flow_error *error); + +Push enqueued operations +~~~~~~~~~~~~~~~~~~~~~~~~ + +Pushing all internally stored rules from a queue to the NIC. + +.. code-block:: c + + int + rte_flow_q_push(uint16_t port_id, + uint32_t queue_id, + struct rte_flow_error *error); + +There is the postpone attribute in the queue operation attributes. +When it is set, multiple operations can be bulked together and not sent to HW +right away to save SW/HW interactions and prioritize throughput over latency. +The application must invoke this function to actually push all outstanding +operations to HW in this case. + +Pull enqueued operations +~~~~~~~~~~~~~~~~~~~~~~~~ + +Pulling asynchronous operations results. + +The application must invoke this function in order to complete asynchronous +flow rule operations and to receive flow rule operations statuses. + +.. code-block:: c + + int + rte_flow_q_pull(uint16_t port_id, + uint32_t queue_id, + struct rte_flow_q_op_res res[], + uint16_t n_res, + struct rte_flow_error *error); + +Multiple outstanding operation results can be pulled simultaneously. +User data may be provided during a flow creation/destruction in order +to distinguish between multiple operations. User data is returned as part +of the result to provide a method to detect which operation is completed.
doc/guides/prog_guide/rte_flow.rst and pattern and actions templates are created. · line 3871
Quoted 10 lines
doc/guides/prog_guide/rte_flow.rst +10
-0+ +Enqueue indirect action creation operation +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Asynchronous version of indirect action creation API. + +.. code-block:: c + + struct rte_flow_action_handle * + rte_flow_q_action_handle_create(uint16_t port_id,
What is the use case for this?
How application needs to use this. We already creating flow_table. Is that not sufficient?
Quoted 57 lines
doc/guides/prog_guide/rte_flow.rst +38
-0+ uint32_t queue_id, + const struct rte_flow_q_ops_attr *q_ops_attr, + const struct rte_flow_indir_action_conf *indir_action_conf, + const struct rte_flow_action *action, + struct rte_flow_error *error); + +A valid handle in case of success is returned. It must be destroyed later by +calling ``rte_flow_q_action_handle_destroy()`` even if the rule is rejected. + +Enqueue indirect action destruction operation +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Asynchronous version of indirect action destruction API. + +.. code-block:: c + + int + rte_flow_q_action_handle_destroy(uint16_t port_id, + uint32_t queue_id, + const struct rte_flow_q_ops_attr *q_ops_attr, + struct rte_flow_action_handle *action_handle, + struct rte_flow_error *error); + +Enqueue indirect action update operation +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Asynchronous version of indirect action update API. + +.. code-block:: c + + int + rte_flow_q_action_handle_update(uint16_t port_id, + uint32_t queue_id, + const struct rte_flow_q_ops_attr *q_ops_attr, + struct rte_flow_action_handle *action_handle, + const void *update, + struct rte_flow_error *error); + .. _flow_isolated_mode: Flow isolated modedoc/guides/rel_notes/release_22_03.rst +8
-0@@ -67,6 +67,14 @@ New Features ``rte_flow_table_destroy``, ``rte_flow_pattern_template_destroy`` and ``rte_flow_actions_template_destroy``. +* ethdev: Added ``rte_flow_q_flow_create`` and ``rte_flow_q_flow_destroy`` API + to enqueue flow creaion/destruction operations asynchronously as well as + ``rte_flow_q_pull`` to poll and retrieve results of these operations and + ``rte_flow_q_push`` to push all the in-flight operations to the NIC. + Introduced asynchronous API for indirect actions management as well: + ``rte_flow_q_action_handle_create``, ``rte_flow_q_action_handle_destroy`` and + ``rte_flow_q_action_handle_update``. +
RE: [PATCH v3 03/10] ethdev: bring in async queue-based flow rules operations
Quoted 3 lines · On Tuesday, February 8, 2022 5:57 Jerin Jacob <[email protected]> wrote:
On Sun, Feb 6, 2022 at 8:57 AM Alexander Kozyrev <[email protected]> wrote:
Hi Jerin, thanks you for reviewing my patch. I appreciate your input. I'm planning to send v4 today with addressed comments today to be on time for RC1. I hope that my answers are satisfactory for the rest of questions raised by you.
Quoted 15 lines
Quoted 2 lines
A new, faster, queue-based flow rules management mechanism is needed
for
Quoted 8 lines
applications offloading rules inside the datapath. This asynchronous and lockless mechanism frees the CPU for further packet processing and reduces the performance impact of the flow rules creation/destruction on the datapath. Note that queues are not thread-safe and the queue should be accessed from the same thread for all queue operations. It is the responsibility of the app to sync the queue functions in case of multi-threaded access to the same queue.
Quoted 4 lines
The
rte_flow_q_flow_create()function enqueues a flow creation to the requested queue. It benefits from already configured resources and sets unique values on top of item and action templates. A flow rule is enqueued on the specified flow queue and offloaded asynchronously to the
Quoted 8 lines
hardware.
Quoted 5 lines
The function returns immediately to spare CPU for further packet processing. The application must invoke the
rte_flow_q_pull()function to complete the flow rule operation offloading, to clear the queue, and to receive the operation status. Therte_flow_q_flow_destroy()function enqueues a flow destruction to the requested queue.It is good to see the implementation, specifically to understand,
We will send PMD implementation in the next few days.
Quoted 4 lines
1)
I understand, We are creating queues to make multiple producers to enqueue multiple jobs in parallel.
On the consumer side, Is it HW or some other cores to consume the job?
From API point of view there is no restriction on the type of consumer. It could be hardware or software implementation, but in most cases (and in our driver) it will be the NIC to handle the requests.
Quoted 1 line
Can we operate in consumer in parallel?
Yes, we can have separate multiple hardware queues to handle operations in parallel independently and without any locking mechanism needed.
Quoted 1 line
2) Is Queue part of HW or just SW primitive to submit the work as a channel.
The queue is a software primitive.
Quoted 23 lines
Quoted 16 lines
Signed-off-by Alexander Kozyrev <[email protected]>--- doc/guides/prog_guide/img/rte_flow_q_init.svg | 71 ++++ .../prog_guide/img/rte_flow_q_usage.svg | 60 +++ doc/guides/prog_guide/rte_flow.rst | 159 +++++++- doc/guides/rel_notes/release_22_03.rst | 8 + lib/ethdev/rte_flow.c | 173 ++++++++- lib/ethdev/rte_flow.h | 342 ++++++++++++++++++ lib/ethdev/rte_flow_driver.h | 55 +++ lib/ethdev/version.map | 7 + 8 files changed, 873 insertions(+), 2 deletions(-) create mode 100644 doc/guides/prog_guide/img/rte_flow_q_init.svg create mode 100644 doc/guides/prog_guide/img/rte_flow_q_usage.svgReview
Quoted 1 line
(quoted diff) +0
-0b/doc/guides/prog_guide/img/rte_flow_q_init.svg
Quoted 2 lines
new file mode 100644
index 0000000000..2080bf4c04
Quoted 4 lines
Some comments on the diagrams:
# rte_flow_q_create_flow and rte_flow_q_destroy_flow used instead of rte_flow_q_flow_create/destroy # rte_flow_q_pull's brackets(i.e ()) not aligned
Will fix this, thanks for noticing.
Quoted 19 lines
Review
Quoted 4 lines
+</svg>
\ No newline at end of file(quoted diff) +0
-0
b/doc/guides/prog_guide/rte_flow.rstdoc/guides/prog_guide/rte_flow.rst Hints about the expected number of counters
Quoted 4 lines
index
b7799c5abe..734294e65d100644doc/guides/prog_guide/rte_flow.rst +0
-0@@ -3607,12 +3607,16 @@ Hints about the expected number of countersor meters in an application,
doc/guides/prog_guide/rte_flow.rst Hints about the expected number of counters · line 3607
Quoted 1 line
doc/guides/prog_guide/rte_flow.rst +0
-0for example, allow PMD to prepare and optimize NIC memory layout inadvance.
Quoted 7 lines
doc/guides/prog_guide/rte_flow.rst +2
-0``rte_flow_configure()`` must be called before any flow rule is created, but after an Ethernet device is configured. +It also creates flow queues for asynchronous flow rules operations via +queue-based API, see `Asynchronous operations`_ section. .. code-block:: c
Quoted 7 lines
doc/guides/prog_guide/rte_flow.rst Hints about the expected number of counters or meters in an application, · line 3618
Quoted 4 lines
doc/guides/prog_guide/rte_flow.rst +1
-0int rte_flow_configure(uint16_t port_id, const struct rte_flow_port_attr *port_attr, + uint16_t nb_queue,#
rte_flow_info_get()don't have number of queues, why not adding number queues inrte_flow_port_attr.
Good suggestion, I'll add it to the capabilities structure.
Quoted 1 line
# And additional APIs for
queue_setup()like ethdev.
ethdev has the start function which tells the PMD when all configurations are done. In our case there is no such function and device is ready to create a flows as soon as we exit the rte_flow_configure(). In addition, the number of queues may affect the resource allocation it is best to process all the requested resources at the same time.
Quoted 36 lines
doc/guides/prog_guide/rte_flow.rst and pattern and actions templates are created. · line 3744
Quoted 11 lines
doc/guides/prog_guide/rte_flow.rst +2
-1+ const struct rte_flow_queue_attr *queue_attr[], struct rte_flow_error *error); Information about resources that can benefit from pre-allocation can be@@ -3737,7 +3741,7 @@ and pattern and actions templates are created. .. code-block:: c - rte_flow_configure(port, *port_attr, *error); + rte_flow_configure(port, *port_attr, nb_queue, *queue_attr,*error);
doc/guides/prog_guide/rte_flow.rst and pattern and actions templates are created. · line 3760
Quoted 11 lines
doc/guides/prog_guide/rte_flow.rst +4
-0struct rte_flow_pattern_template *pattern_templates[0] = rte_flow_pattern_template_create(port, &itr, &pattern, &error);@@ -3750,6 +3754,159 @@ and pattern and actions templates are created. *actions_templates, nb_actions_templates, *error); +Asynchronous operations +----------------------- + +Flow rules management can be done via special lockless flowmanagement queues.
doc/guides/prog_guide/rte_flow.rst and pattern and actions templates are created.
Quoted 3 lines
doc/guides/prog_guide/rte_flow.rst +3
-0+- Queue operations are asynchronous and not thread-safe. +- Operations can thus be invoked by the app's datapath, +packet processing can continue while queue operations are processed byNIC.
doc/guides/prog_guide/rte_flow.rst and pattern and actions templates are created.
Quoted 8 lines
doc/guides/prog_guide/rte_flow.rst +8
-0+- The queue number is configured at initialization stage. +- Available operation types: rule creation, rule destruction, +indirect rule creation, indirect rule destruction, indirect rule update. +- Operations may be reordered within a queue. +- Operations can be postponed and pushed to NIC in batches. +- Results pulling must be done on time to avoid queue overflows. +- User data is returned as part of the result to identify an operation. +- Flow handle is valid once the creation operation is enqueued and must
Quoted 6 lines
be
doc/guides/prog_guide/rte_flow.rst and pattern and actions templates are created. · line 3772
Quoted 1 line
doc/guides/prog_guide/rte_flow.rst +1
-0+destroyed even if the operation is not successful and the rule is notinserted.
You need CR between lines as rendered text does comes as new line in between the items.
OK.
Quoted 17 lines
Quoted 5 lines
doc/guides/prog_guide/rte_flow.rst +4
-0+ +The asynchronous flow rule insertion logic can be broken into two phases. + +1. Initialization stage as shown here:doc/guides/prog_guide/rte_flow.rst and pattern and actions templates are created. · line 3786
Quoted 10 lines
doc/guides/prog_guide/rte_flow.rst +10
-0+ +.. _figure_rte_flow_q_init: + +.. figure:: img/rte_flow_q_init.* + +2. Main loop as presented on a datapath application example: + +.. _figure_rte_flow_q_usage: + +.. figure:: img/rte_flow_q_usage.*it is better to add sequence operations as text to understand the flow.
I prefer keeping the diagram here, it looks more clean and concise. Block of text gives no new information and harder to follow, imho.
Quoted 9 lines
doc/guides/prog_guide/rte_flow.rst and pattern and actions templates are created. · line 3791
Quoted 6 lines
doc/guides/prog_guide/rte_flow.rst +5
-0+ +Enqueue creation operation +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Enqueueing a flow rule creation operation is similar to simple creation.If it is enqueue operation, why not call it ad
rte_flow_q_flow_enqueue()
Quoted 15 lines
doc/guides/prog_guide/rte_flow.rst and pattern and actions templates are created. · line 3802
Quoted 11 lines
doc/guides/prog_guide/rte_flow.rst +11
-0+ +.. code-block:: c + + struct rte_flow * + rte_flow_q_flow_create(uint16_t port_id, + uint32_t queue_id, + const struct rte_flow_q_ops_attr *q_ops_attr, + struct rte_flow_table *table, + const struct rte_flow_item pattern[], + uint8_t pattern_template_index, + const struct rte_flow_action actions[],If I understand correctly, table is the pre-configured object that has N number of patterns and N number of actions.
Why giving items[] and actions[] again?
Table only contains templates for pattern and actions.
We still need to provide the values for those templates when we create a flow. Thus we specify patterns and action here.
Quoted 11 lines
doc/guides/prog_guide/rte_flow.rst and pattern and actions templates are created.
Quoted 5 lines
doc/guides/prog_guide/rte_flow.rst +5
-0+ uint8_t actions_template_index, + struct rte_flow_error *error); + +A valid handle in case of success is returned. It must be destroyed later +by calling ``rte_flow_q_flow_destroy()`` even if the rule is rejected byHW.
doc/guides/prog_guide/rte_flow.rst and pattern and actions templates are created. · line 3810
Quoted 3 lines
doc/guides/prog_guide/rte_flow.rst +3
-0+ +Enqueue destruction operation +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Queue destruction operation.
We are not destroying queue, we are enqueuing the flow destruction operation.
Quoted 60 lines
doc/guides/prog_guide/rte_flow.rst and pattern and actions templates are created. · line 3812
Quoted 3 lines
doc/guides/prog_guide/rte_flow.rst +2
-0+ +Enqueueing a flow rule destruction operation is similar to simpledestruction.
Quoted 14 lines
doc/guides/prog_guide/rte_flow.rst +14
-0+ +.. code-block:: c + + int + rte_flow_q_flow_destroy(uint16_t port_id, + uint32_t queue_id, + const struct rte_flow_q_ops_attr *q_ops_attr, + struct rte_flow *flow, + struct rte_flow_error *error); + +Push enqueued operations +~~~~~~~~~~~~~~~~~~~~~~~~ + +Pushing all internally stored rules from a queue to the NIC.doc/guides/prog_guide/rte_flow.rst and pattern and actions templates are created.
Quoted 10 lines
doc/guides/prog_guide/rte_flow.rst +10
-0+ +.. code-block:: c + + int + rte_flow_q_push(uint16_t port_id, + uint32_t queue_id, + struct rte_flow_error *error); + +There is the postpone attribute in the queue operation attributes. +When it is set, multiple operations can be bulked together and not sent toHW
doc/guides/prog_guide/rte_flow.rst and pattern and actions templates are created. · line 3837
Quoted 1 line
doc/guides/prog_guide/rte_flow.rst +1
-0+right away to save SW/HW interactions and prioritize throughput overlatency.
doc/guides/prog_guide/rte_flow.rst and pattern and actions templates are created.
Quoted 9 lines
doc/guides/prog_guide/rte_flow.rst +9
-0+The application must invoke this function to actually push all outstanding +operations to HW in this case. + +Pull enqueued operations +~~~~~~~~~~~~~~~~~~~~~~~~ + +Pulling asynchronous operations results. + +The application must invoke this function in order to completeasynchronous
Quoted 19 lines
doc/guides/prog_guide/rte_flow.rst +19
-0+flow rule operations and to receive flow rule operations statuses. + +.. code-block:: c + + int + rte_flow_q_pull(uint16_t port_id, + uint32_t queue_id, + struct rte_flow_q_op_res res[], + uint16_t n_res, + struct rte_flow_error *error); + +Multiple outstanding operation results can be pulled simultaneously. +User data may be provided during a flow creation/destruction in order +to distinguish between multiple operations. User data is returned as part +of the result to provide a method to detect which operation is completed. + +Enqueue indirect action creation operation +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +
Quoted 8 lines
doc/guides/prog_guide/rte_flow.rst and pattern and actions templates are created. · line 3871
Quoted 6 lines
doc/guides/prog_guide/rte_flow.rst +6
-0+Asynchronous version of indirect action creation API. + +.. code-block:: c + + struct rte_flow_action_handle * + rte_flow_q_action_handle_create(uint16_t port_id,What is the use case for this?
Indirect action creation may take time, it may depend on hardware resources allocation. So we add the asynchronous way of creating it the same way.
Quoted 2 lines
How application needs to use this. We already creating
flow_table. Is that not sufficient?
The indirect action object is used in flow rules via its handle. This is an extension to the already existing API in order to speed up the creation of these objects.
Quoted 63 lines
doc/guides/prog_guide/rte_flow.rst and pattern and actions templates are created.
Quoted 9 lines
doc/guides/prog_guide/rte_flow.rst +8
-0+ uint32_t queue_id, + const struct rte_flow_q_ops_attr *q_ops_attr, + const struct rte_flow_indir_action_conf *indir_action_conf, + const struct rte_flow_action *action, + struct rte_flow_error *error); + +A valid handle in case of success is returned. It must be destroyed later by +calling ``rte_flow_q_action_handle_destroy()`` even if the rule isrejected.
Review
Quoted 34 lines
doc/guides/prog_guide/rte_flow.rst +30
-0+ +Enqueue indirect action destruction operation +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Asynchronous version of indirect action destruction API. + +.. code-block:: c + + int + rte_flow_q_action_handle_destroy(uint16_t port_id, + uint32_t queue_id, + const struct rte_flow_q_ops_attr *q_ops_attr, + struct rte_flow_action_handle *action_handle, + struct rte_flow_error *error); + +Enqueue indirect action update operation +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Asynchronous version of indirect action update API. + +.. code-block:: c + + int + rte_flow_q_action_handle_update(uint16_t port_id, + uint32_t queue_id, + const struct rte_flow_q_ops_attr *q_ops_attr, + struct rte_flow_action_handle *action_handle, + const void *update, + struct rte_flow_error *error); + .. _flow_isolated_mode: Flow isolated mode(quoted diff) +0
-0
b/doc/guides/rel_notes/release_22_03.rstdoc/guides/rel_notes/release_22_03.rst New Features · line 70
Quoted 8 lines
index
d23d1591df..80a85124e6100644doc/guides/rel_notes/release_22_03.rst +1
-0@@ -67,6 +67,14 @@ New Features ``rte_flow_table_destroy``, ``rte_flow_pattern_template_destroy`` and ``rte_flow_actions_template_destroy``. +* ethdev: Added ``rte_flow_q_flow_create`` and``rte_flow_q_flow_destroy`` API
doc/guides/rel_notes/release_22_03.rst New Features · line 71
Quoted 1 line
doc/guides/rel_notes/release_22_03.rst +1
-0+ to enqueue flow creaion/destruction operations asynchronously as wellas
doc/guides/rel_notes/release_22_03.rst New Features
Quoted 4 lines
doc/guides/rel_notes/release_22_03.rst +4
-0+ ``rte_flow_q_pull`` to poll and retrieve results of these operations and + ``rte_flow_q_push`` to push all the in-flight operations to the NIC. + Introduced asynchronous API for indirect actions management as well: + ``rte_flow_q_action_handle_create``,``rte_flow_q_action_handle_destroy`` and
Quoted 2 lines
doc/guides/rel_notes/release_22_03.rst +2
-0+ ``rte_flow_q_action_handle_update``. +
RE: [PATCH v3 03/10] ethdev: bring in async queue-based flow rules operations
Hi,
PSB
Quoted 209 lines · Alexander Kozyrev
Quoted 3 lines · On Tuesday, February 8, 2022 5:57 Jerin Jacob <[email protected]> wrote:
On Sun, Feb 6, 2022 at 8:57 AM Alexander Kozyrev <[email protected]> wrote:
Hi Jerin, thanks you for reviewing my patch. I appreciate your input. I'm planning to send v4 today with addressed comments today to be on time for RC1. I hope that my answers are satisfactory for the rest of questions raised by you.
Quoted 15 lines
Quoted 2 lines
A new, faster, queue-based flow rules management mechanism is needed
for
Quoted 8 lines
applications offloading rules inside the datapath. This asynchronous and lockless mechanism frees the CPU for further packet processing and reduces the performance impact of the flow rules creation/destruction on the datapath. Note that queues are not thread-safe and the queue should be accessed from the same thread for all queue operations. It is the responsibility of the app to sync the queue functions in case of multi-threaded access to the same queue.
Quoted 4 lines
The
rte_flow_q_flow_create()function enqueues a flow creation to the requested queue. It benefits from already configured resources and sets unique values on top of item and action templates. A flow rule is enqueued on the specified flow queue and offloaded asynchronously to theQuoted 8 lines
hardware.
Quoted 5 lines
The function returns immediately to spare CPU for further packet processing. The application must invoke the
rte_flow_q_pull()function to complete the flow rule operation offloading, to clear the queue, and to receive the operation status. Therte_flow_q_flow_destroy()function enqueues a flow destruction to the requested queue.It is good to see the implementation, specifically to understand,
We will send PMD implementation in the next few days.
Quoted 4 lines
1)
I understand, We are creating queues to make multiple producers to enqueue multiple jobs in parallel.
On the consumer side, Is it HW or some other cores to consume the job?From API point of view there is no restriction on the type of consumer. It could be hardware or software implementation, but in most cases (and in our driver) it will be the NIC to handle the requests.
Quoted 1 line
Can we operate in consumer in parallel?
Yes, we can have separate multiple hardware queues to handle operations in parallel independently and without any locking mechanism needed.
Quoted 1 line
2) Is Queue part of HW or just SW primitive to submit the work as a channel.
The queue is a software primitive.
Quoted 23 lines
Quoted 16 lines
Signed-off-by Alexander Kozyrev <[email protected]>--- doc/guides/prog_guide/img/rte_flow_q_init.svg | 71 ++++ .../prog_guide/img/rte_flow_q_usage.svg | 60 +++ doc/guides/prog_guide/rte_flow.rst | 159 +++++++- doc/guides/rel_notes/release_22_03.rst | 8 + lib/ethdev/rte_flow.c | 173 ++++++++- lib/ethdev/rte_flow.h | 342 ++++++++++++++++++ lib/ethdev/rte_flow_driver.h | 55 +++ lib/ethdev/version.map | 7 + 8 files changed, 873 insertions(+), 2 deletions(-) create mode 100644 doc/guides/prog_guide/img/rte_flow_q_init.svg create mode 100644 doc/guides/prog_guide/img/rte_flow_q_usage.svgReview
Quoted 1 line
(quoted diff) +0
-0b/doc/guides/prog_guide/img/rte_flow_q_init.svg
Quoted 2 lines
new file mode 100644
index 0000000000..2080bf4c04Quoted 4 lines
Some comments on the diagrams:
# rte_flow_q_create_flow and rte_flow_q_destroy_flow used instead of rte_flow_q_flow_create/destroy # rte_flow_q_pull's brackets(i.e ()) not alignedWill fix this, thanks for noticing.
Quoted 19 lines
Review
Quoted 4 lines
+</svg>
\ No newline at end of file(quoted diff) +0
-0
b/doc/guides/prog_guide/rte_flow.rstdoc/guides/prog_guide/rte_flow.rst Hints about the expected number of counters
Quoted 4 lines
index
b7799c5abe..734294e65d100644doc/guides/prog_guide/rte_flow.rst +0
-0@@ -3607,12 +3607,16 @@ Hints about the expected number of countersor meters in an application,
doc/guides/prog_guide/rte_flow.rst Hints about the expected number of counters · line 3607
Quoted 1 line
doc/guides/prog_guide/rte_flow.rst +0
-0for example, allow PMD to prepare and optimize NIC memory layout inadvance.
Quoted 7 lines
doc/guides/prog_guide/rte_flow.rst +2
-0``rte_flow_configure()`` must be called before any flow rule is created, but after an Ethernet device is configured. +It also creates flow queues for asynchronous flow rules operations via +queue-based API, see `Asynchronous operations`_ section. .. code-block:: cQuoted 7 lines
doc/guides/prog_guide/rte_flow.rst Hints about the expected number of counters or meters in an application, · line 3618
Quoted 4 lines
doc/guides/prog_guide/rte_flow.rst +1
-0int rte_flow_configure(uint16_t port_id, const struct rte_flow_port_attr *port_attr, + uint16_t nb_queue,#
rte_flow_info_get()don't have number of queues, why not adding number queues inrte_flow_port_attr.Good suggestion, I'll add it to the capabilities structure.
Quoted 1 line
# And additional APIs for
queue_setup()like ethdev.ethdev has the start function which tells the PMD when all configurations are done. In our case there is no such function and device is ready to create a flows as soon as we exit the
rte_flow_configure(). In addition, the number of queues may affect the resource allocation it is best to process all the requested resources at the same time.Quoted 36 lines
doc/guides/prog_guide/rte_flow.rst and pattern and actions templates are created. · line 3744
Quoted 11 lines
doc/guides/prog_guide/rte_flow.rst +2
-1+ const struct rte_flow_queue_attr *queue_attr[], struct rte_flow_error *error); Information about resources that can benefit from pre-allocation can be@@ -3737,7 +3741,7 @@ and pattern and actions templates are created. .. code-block:: c - rte_flow_configure(port, *port_attr, *error); + rte_flow_configure(port, *port_attr, nb_queue, *queue_attr,*error);
doc/guides/prog_guide/rte_flow.rst and pattern and actions templates are created. · line 3760
Quoted 11 lines
doc/guides/prog_guide/rte_flow.rst +4
-0struct rte_flow_pattern_template *pattern_templates[0] = rte_flow_pattern_template_create(port, &itr, &pattern, &error);@@ -3750,6 +3754,159 @@ and pattern and actions templates are created. *actions_templates, nb_actions_templates, *error); +Asynchronous operations +----------------------- + +Flow rules management can be done via special lockless flowmanagement queues.
doc/guides/prog_guide/rte_flow.rst and pattern and actions templates are created.
Quoted 3 lines
doc/guides/prog_guide/rte_flow.rst +3
-0+- Queue operations are asynchronous and not thread-safe. +- Operations can thus be invoked by the app's datapath, +packet processing can continue while queue operations are processed byNIC.
doc/guides/prog_guide/rte_flow.rst and pattern and actions templates are created.
Quoted 8 lines
doc/guides/prog_guide/rte_flow.rst +8
-0+- The queue number is configured at initialization stage. +- Available operation types: rule creation, rule destruction, +indirect rule creation, indirect rule destruction, indirect rule update. +- Operations may be reordered within a queue. +- Operations can be postponed and pushed to NIC in batches. +- Results pulling must be done on time to avoid queue overflows. +- User data is returned as part of the result to identify an operation. +- Flow handle is valid once the creation operation is enqueued and mustQuoted 6 lines
be
doc/guides/prog_guide/rte_flow.rst and pattern and actions templates are created. · line 3772
Quoted 1 line
doc/guides/prog_guide/rte_flow.rst +1
-0+destroyed even if the operation is not successful and the rule is notinserted.
You need CR between lines as rendered text does comes as new line in between the items.
OK.
Quoted 17 lines
Quoted 5 lines
doc/guides/prog_guide/rte_flow.rst +4
-0+ +The asynchronous flow rule insertion logic can be broken into two phases. + +1. Initialization stage as shown here:doc/guides/prog_guide/rte_flow.rst and pattern and actions templates are created. · line 3786
Quoted 10 lines
doc/guides/prog_guide/rte_flow.rst +10
-0+ +.. _figure_rte_flow_q_init: + +.. figure:: img/rte_flow_q_init.* + +2. Main loop as presented on a datapath application example: + +.. _figure_rte_flow_q_usage: + +.. figure:: img/rte_flow_q_usage.*it is better to add sequence operations as text to understand the flow.
I prefer keeping the diagram here, it looks more clean and concise. Block of text gives no new information and harder to follow, imho.
Quoted 9 lines
doc/guides/prog_guide/rte_flow.rst and pattern and actions templates are created. · line 3791
Quoted 6 lines
doc/guides/prog_guide/rte_flow.rst +5
-0+ +Enqueue creation operation +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Enqueueing a flow rule creation operation is similar to simple creation.If it is enqueue operation, why not call it ad
rte_flow_q_flow_enqueue()Quoted 15 lines
doc/guides/prog_guide/rte_flow.rst and pattern and actions templates are created. · line 3802
Quoted 11 lines
doc/guides/prog_guide/rte_flow.rst +11
-0+ +.. code-block:: c + + struct rte_flow * + rte_flow_q_flow_create(uint16_t port_id, + uint32_t queue_id, + const struct rte_flow_q_ops_attr *q_ops_attr, + struct rte_flow_table *table, + const struct rte_flow_item pattern[], + uint8_t pattern_template_index, + const struct rte_flow_action actions[],If I understand correctly, table is the pre-configured object that has N number of patterns and N number of actions.
Why giving items[] and actions[] again?
Quoted 1 line
Table only contains templates for pattern and actions.
Then why not reflect it in the argument name? Perhaps, "template_table"? Or even in the struct name: "struct rte_flow_template_table". Chances are that readers will misread "rte_flow_table"
as "flow entry table" in the OpenFlow sense.
Quoted 2 lines
We still need to provide the values for those templates when we create a flow. Thus we specify patterns and action here.
All of that is clear in terms of this review cycle, but please consider improving the argument names to help future readers.
Quoted 158 lines
Quoted 7 lines
doc/guides/prog_guide/rte_flow.rst and pattern and actions templates are created.
Quoted 6 lines
doc/guides/prog_guide/rte_flow.rst +5
-0+ uint8_t actions_template_index, + struct rte_flow_error *error); + +A valid handle in case of success is returned. It must be destroyed later +by calling ``rte_flow_q_flow_destroy()`` even if the rule is rejected byHW.
Quoted 5 lines
doc/guides/prog_guide/rte_flow.rst and pattern and actions templates are created. · line 3810
Quoted 3 lines
doc/guides/prog_guide/rte_flow.rst +3
-0+ +Enqueue destruction operation +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Queue destruction operation.
We are not destroying queue, we are enqueuing the flow destruction operation.
Quoted 60 lines
doc/guides/prog_guide/rte_flow.rst and pattern and actions templates are created. · line 3812
Quoted 3 lines
doc/guides/prog_guide/rte_flow.rst +2
-0+ +Enqueueing a flow rule destruction operation is similar to simpledestruction.
Quoted 14 lines
doc/guides/prog_guide/rte_flow.rst +14
-0+ +.. code-block:: c + + int + rte_flow_q_flow_destroy(uint16_t port_id, + uint32_t queue_id, + const struct rte_flow_q_ops_attr *q_ops_attr, + struct rte_flow *flow, + struct rte_flow_error *error); + +Push enqueued operations +~~~~~~~~~~~~~~~~~~~~~~~~ + +Pushing all internally stored rules from a queue to the NIC.doc/guides/prog_guide/rte_flow.rst and pattern and actions templates are created.
Quoted 10 lines
doc/guides/prog_guide/rte_flow.rst +10
-0+ +.. code-block:: c + + int + rte_flow_q_push(uint16_t port_id, + uint32_t queue_id, + struct rte_flow_error *error); + +There is the postpone attribute in the queue operation attributes. +When it is set, multiple operations can be bulked together and not sent toHW
doc/guides/prog_guide/rte_flow.rst and pattern and actions templates are created. · line 3837
Quoted 1 line
doc/guides/prog_guide/rte_flow.rst +1
-0+right away to save SW/HW interactions and prioritize throughput overlatency.
doc/guides/prog_guide/rte_flow.rst and pattern and actions templates are created.
Quoted 9 lines
doc/guides/prog_guide/rte_flow.rst +9
-0+The application must invoke this function to actually push all outstanding +operations to HW in this case. + +Pull enqueued operations +~~~~~~~~~~~~~~~~~~~~~~~~ + +Pulling asynchronous operations results. + +The application must invoke this function in order to completeasynchronous
Quoted 19 lines
doc/guides/prog_guide/rte_flow.rst +19
-0+flow rule operations and to receive flow rule operations statuses. + +.. code-block:: c + + int + rte_flow_q_pull(uint16_t port_id, + uint32_t queue_id, + struct rte_flow_q_op_res res[], + uint16_t n_res, + struct rte_flow_error *error); + +Multiple outstanding operation results can be pulled simultaneously. +User data may be provided during a flow creation/destruction in order +to distinguish between multiple operations. User data is returned as part +of the result to provide a method to detect which operation is completed. + +Enqueue indirect action creation operation +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Quoted 8 lines
doc/guides/prog_guide/rte_flow.rst and pattern and actions templates are created. · line 3871
Quoted 6 lines
doc/guides/prog_guide/rte_flow.rst +6
-0+Asynchronous version of indirect action creation API. + +.. code-block:: c + + struct rte_flow_action_handle * + rte_flow_q_action_handle_create(uint16_t port_id,What is the use case for this?
Indirect action creation may take time, it may depend on hardware resources allocation. So we add the asynchronous way of creating it the same way.
Quoted 2 lines
How application needs to use this. We already creating
flow_table. Is that not sufficient?The indirect action object is used in flow rules via its handle. This is an extension to the already existing API in order to speed up the creation of these objects.
Quoted 63 lines
doc/guides/prog_guide/rte_flow.rst and pattern and actions templates are created.
Quoted 9 lines
doc/guides/prog_guide/rte_flow.rst +8
-0+ uint32_t queue_id, + const struct rte_flow_q_ops_attr *q_ops_attr, + const struct rte_flow_indir_action_conf *indir_action_conf, + const struct rte_flow_action *action, + struct rte_flow_error *error); + +A valid handle in case of success is returned. It must be destroyed later by +calling ``rte_flow_q_action_handle_destroy()`` even if the rule isrejected.
Review
Quoted 34 lines
doc/guides/prog_guide/rte_flow.rst +30
-0+ +Enqueue indirect action destruction operation +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Asynchronous version of indirect action destruction API. + +.. code-block:: c + + int + rte_flow_q_action_handle_destroy(uint16_t port_id, + uint32_t queue_id, + const struct rte_flow_q_ops_attr *q_ops_attr, + struct rte_flow_action_handle *action_handle, + struct rte_flow_error *error); + +Enqueue indirect action update operation +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Asynchronous version of indirect action update API. + +.. code-block:: c + + int + rte_flow_q_action_handle_update(uint16_t port_id, + uint32_t queue_id, + const struct rte_flow_q_ops_attr *q_ops_attr, + struct rte_flow_action_handle *action_handle, + const void *update, + struct rte_flow_error *error); + .. _flow_isolated_mode: Flow isolated mode(quoted diff) +0
-0
b/doc/guides/rel_notes/release_22_03.rstdoc/guides/rel_notes/release_22_03.rst New Features · line 70
Quoted 8 lines
index
d23d1591df..80a85124e6100644doc/guides/rel_notes/release_22_03.rst +1
-0@@ -67,6 +67,14 @@ New Features ``rte_flow_table_destroy``, ``rte_flow_pattern_template_destroy`` and ``rte_flow_actions_template_destroy``. +* ethdev: Added ``rte_flow_q_flow_create`` and``rte_flow_q_flow_destroy`` API
doc/guides/rel_notes/release_22_03.rst New Features · line 71
Quoted 1 line
doc/guides/rel_notes/release_22_03.rst +1
-0+ to enqueue flow creaion/destruction operations asynchronously as wellas
doc/guides/rel_notes/release_22_03.rst New Features
Quoted 4 lines
doc/guides/rel_notes/release_22_03.rst +4
-0+ ``rte_flow_q_pull`` to poll and retrieve results of these operations and + ``rte_flow_q_push`` to push all the in-flight operations to the NIC. + Introduced asynchronous API for indirect actions management as well: + ``rte_flow_q_action_handle_create``,``rte_flow_q_action_handle_destroy`` and
Quoted 2 lines
doc/guides/rel_notes/release_22_03.rst +2
-0+ ``rte_flow_q_action_handle_update``. +
RE: [PATCH v3 03/10] ethdev: bring in async queue-based flow rules operations
Quoted 32 lines · On Tuesday, February 8, 2022 10:24 Ivan Malov <[email protected]> wrote:
Quoted 25 lines · Alexander Kozyrev
Quoted 9 lines
doc/guides/prog_guide/rte_flow.rst and pattern and actions templates are created. · line 3791
Quoted 6 lines
doc/guides/prog_guide/rte_flow.rst +5
-0+ +Enqueue creation operation +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Enqueueing a flow rule creation operation is similar to simple creation.If it is enqueue operation, why not call it ad
rte_flow_q_flow_enqueue()Quoted 15 lines
doc/guides/prog_guide/rte_flow.rst and pattern and actions templates are created. · line 3802
Quoted 11 lines
doc/guides/prog_guide/rte_flow.rst +11
-0+ +.. code-block:: c + + struct rte_flow * + rte_flow_q_flow_create(uint16_t port_id, + uint32_t queue_id, + const struct rte_flow_q_ops_attr *q_ops_attr, + struct rte_flow_table *table, + const struct rte_flow_item pattern[], + uint8_t pattern_template_index, + const struct rte_flow_action actions[],If I understand correctly, table is the pre-configured object that has N number of patterns and N number of actions.
Why giving items[] and actions[] again?Quoted 1 line
Table only contains templates for pattern and actions.
Then why not reflect it in the argument name? Perhaps, "
template_table"? Or even in the struct name: "structrte_flow_template_table". Chances are that readers will misread "rte_flow_table"
as "flow entry table" in the OpenFlow sense.
Quoted 6 lines
Quoted 1 line
We still need to provide the values for those templates when we create a
flow.
Quoted 1 line
Thus we specify patterns and action here.
All of that is clear in terms of this review cycle, but please consider improving the argument names to help future readers.
Agree, it is a good idea to rename it to template_table, thanks.
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
doc/guides/prog_guide/rte_flow.rst and pattern and actions templates are created.
Quoted 6 lines
doc/guides/prog_guide/rte_flow.rst +5
-0+ uint8_t actions_template_index, + struct rte_flow_error *error); + +A valid handle in case of success is returned. It must be destroyed later +by calling ``rte_flow_q_flow_destroy()`` even if the rule is rejected byHW.
Quoted 8 lines
Quoted 7 lines
Quoted 5 lines
doc/guides/prog_guide/rte_flow.rst and pattern and actions templates are created. · line 3810
Quoted 3 lines
doc/guides/prog_guide/rte_flow.rst +3
-0+ +Enqueue destruction operation +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Queue destruction operation.
We are not destroying queue, we are enqueuing the flow destruction
operation.
7
Re: [PATCH v3 03/10] ethdev: bring in async queue-based flow rules operations
In reply to Alexander KozyrevQuoted 6 lines · Alexander Kozyrev
Quoted 4 lines · On Tuesday, February 8, 2022 5:57 Jerin Jacob <[email protected]> wrote:
On Sun, Feb 6, 2022 at 8:57 AM Alexander Kozyrev <[email protected]> wrote:
Hi Jerin, thanks you for reviewing my patch. I appreciate your input.
Hi Alex,
Quoted 2 lines
I'm planning to send v4 today with addressed comments today to be on time for RC1. I hope that my answers are satisfactory for the rest of questions raised by you.
Comments looks good to me. Please remove version field in the next patch.
Quoted 362 lines
Quoted 16 lines
Quoted 3 lines
A new, faster, queue-based flow rules management mechanism is needed
for
Quoted 8 lines
applications offloading rules inside the datapath. This asynchronous and lockless mechanism frees the CPU for further packet processing and reduces the performance impact of the flow rules creation/destruction on the datapath. Note that queues are not thread-safe and the queue should be accessed from the same thread for all queue operations. It is the responsibility of the app to sync the queue functions in case of multi-threaded access to the same queue.
Quoted 4 lines
The
rte_flow_q_flow_create()function enqueues a flow creation to the requested queue. It benefits from already configured resources and sets unique values on top of item and action templates. A flow rule is enqueued on the specified flow queue and offloaded asynchronously to theQuoted 8 lines
hardware.
Quoted 5 lines
The function returns immediately to spare CPU for further packet processing. The application must invoke the
rte_flow_q_pull()function to complete the flow rule operation offloading, to clear the queue, and to receive the operation status. Therte_flow_q_flow_destroy()function enqueues a flow destruction to the requested queue.It is good to see the implementation, specifically to understand,
We will send PMD implementation in the next few days.
Quoted 4 lines
1)
I understand, We are creating queues to make multiple producers to enqueue multiple jobs in parallel.
On the consumer side, Is it HW or some other cores to consume the job?From API point of view there is no restriction on the type of consumer. It could be hardware or software implementation, but in most cases (and in our driver) it will be the NIC to handle the requests.
Quoted 1 line
Can we operate in consumer in parallel?
Yes, we can have separate multiple hardware queues to handle operations in parallel independently and without any locking mechanism needed.
Quoted 1 line
2) Is Queue part of HW or just SW primitive to submit the work as a channel.
The queue is a software primitive.
Quoted 23 lines
Quoted 16 lines
Signed-off-by Alexander Kozyrev <[email protected]>--- doc/guides/prog_guide/img/rte_flow_q_init.svg | 71 ++++ .../prog_guide/img/rte_flow_q_usage.svg | 60 +++ doc/guides/prog_guide/rte_flow.rst | 159 +++++++- doc/guides/rel_notes/release_22_03.rst | 8 + lib/ethdev/rte_flow.c | 173 ++++++++- lib/ethdev/rte_flow.h | 342 ++++++++++++++++++ lib/ethdev/rte_flow_driver.h | 55 +++ lib/ethdev/version.map | 7 + 8 files changed, 873 insertions(+), 2 deletions(-) create mode 100644 doc/guides/prog_guide/img/rte_flow_q_init.svg create mode 100644 doc/guides/prog_guide/img/rte_flow_q_usage.svgReview
Quoted 1 line
(quoted diff) +0
-0b/doc/guides/prog_guide/img/rte_flow_q_init.svg
Quoted 2 lines
new file mode 100644
index 0000000000..2080bf4c04Quoted 4 lines
Some comments on the diagrams:
# rte_flow_q_create_flow and rte_flow_q_destroy_flow used instead of rte_flow_q_flow_create/destroy # rte_flow_q_pull's brackets(i.e ()) not alignedWill fix this, thanks for noticing.
Quoted 19 lines
Review
Quoted 4 lines
+</svg>
\ No newline at end of file(quoted diff) +0
-0
b/doc/guides/prog_guide/rte_flow.rstdoc/guides/prog_guide/rte_flow.rst Hints about the expected number of counters
Quoted 4 lines
index
b7799c5abe..734294e65d100644doc/guides/prog_guide/rte_flow.rst +0
-0@@ -3607,12 +3607,16 @@ Hints about the expected number of countersor meters in an application,
doc/guides/prog_guide/rte_flow.rst Hints about the expected number of counters · line 3607
Quoted 1 line
doc/guides/prog_guide/rte_flow.rst +0
-0for example, allow PMD to prepare and optimize NIC memory layout inadvance.
Quoted 7 lines
doc/guides/prog_guide/rte_flow.rst +2
-0``rte_flow_configure()`` must be called before any flow rule is created, but after an Ethernet device is configured. +It also creates flow queues for asynchronous flow rules operations via +queue-based API, see `Asynchronous operations`_ section. .. code-block:: cQuoted 7 lines
doc/guides/prog_guide/rte_flow.rst Hints about the expected number of counters or meters in an application, · line 3618
Quoted 4 lines
doc/guides/prog_guide/rte_flow.rst +1
-0int rte_flow_configure(uint16_t port_id, const struct rte_flow_port_attr *port_attr, + uint16_t nb_queue,#
rte_flow_info_get()don't have number of queues, why not adding number queues inrte_flow_port_attr.Good suggestion, I'll add it to the capabilities structure.
Quoted 1 line
# And additional APIs for
queue_setup()like ethdev.ethdev has the start function which tells the PMD when all configurations are done. In our case there is no such function and device is ready to create a flows as soon as we exit the
rte_flow_configure(). In addition, the number of queues may affect the resource allocation it is best to process all the requested resources at the same time.Quoted 36 lines
doc/guides/prog_guide/rte_flow.rst and pattern and actions templates are created. · line 3744
Quoted 11 lines
doc/guides/prog_guide/rte_flow.rst +2
-1+ const struct rte_flow_queue_attr *queue_attr[], struct rte_flow_error *error); Information about resources that can benefit from pre-allocation can be@@ -3737,7 +3741,7 @@ and pattern and actions templates are created. .. code-block:: c - rte_flow_configure(port, *port_attr, *error); + rte_flow_configure(port, *port_attr, nb_queue, *queue_attr,*error);
doc/guides/prog_guide/rte_flow.rst and pattern and actions templates are created. · line 3760
Quoted 11 lines
doc/guides/prog_guide/rte_flow.rst +4
-0struct rte_flow_pattern_template *pattern_templates[0] = rte_flow_pattern_template_create(port, &itr, &pattern, &error);@@ -3750,6 +3754,159 @@ and pattern and actions templates are created. *actions_templates, nb_actions_templates, *error); +Asynchronous operations +----------------------- + +Flow rules management can be done via special lockless flowmanagement queues.
doc/guides/prog_guide/rte_flow.rst and pattern and actions templates are created.
Quoted 3 lines
doc/guides/prog_guide/rte_flow.rst +3
-0+- Queue operations are asynchronous and not thread-safe. +- Operations can thus be invoked by the app's datapath, +packet processing can continue while queue operations are processed byNIC.
doc/guides/prog_guide/rte_flow.rst and pattern and actions templates are created.
Quoted 8 lines
doc/guides/prog_guide/rte_flow.rst +8
-0+- The queue number is configured at initialization stage. +- Available operation types: rule creation, rule destruction, +indirect rule creation, indirect rule destruction, indirect rule update. +- Operations may be reordered within a queue. +- Operations can be postponed and pushed to NIC in batches. +- Results pulling must be done on time to avoid queue overflows. +- User data is returned as part of the result to identify an operation. +- Flow handle is valid once the creation operation is enqueued and mustQuoted 6 lines
be
doc/guides/prog_guide/rte_flow.rst and pattern and actions templates are created. · line 3772
Quoted 1 line
doc/guides/prog_guide/rte_flow.rst +1
-0+destroyed even if the operation is not successful and the rule is notinserted.
You need CR between lines as rendered text does comes as new line in between the items.
OK.
Quoted 17 lines
Quoted 5 lines
doc/guides/prog_guide/rte_flow.rst +4
-0+ +The asynchronous flow rule insertion logic can be broken into two phases. + +1. Initialization stage as shown here:doc/guides/prog_guide/rte_flow.rst and pattern and actions templates are created. · line 3786
Quoted 10 lines
doc/guides/prog_guide/rte_flow.rst +10
-0+ +.. _figure_rte_flow_q_init: + +.. figure:: img/rte_flow_q_init.* + +2. Main loop as presented on a datapath application example: + +.. _figure_rte_flow_q_usage: + +.. figure:: img/rte_flow_q_usage.*it is better to add sequence operations as text to understand the flow.
I prefer keeping the diagram here, it looks more clean and concise. Block of text gives no new information and harder to follow, imho.
Quoted 9 lines
doc/guides/prog_guide/rte_flow.rst and pattern and actions templates are created. · line 3791
Quoted 6 lines
doc/guides/prog_guide/rte_flow.rst +5
-0+ +Enqueue creation operation +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Enqueueing a flow rule creation operation is similar to simple creation.If it is enqueue operation, why not call it ad
rte_flow_q_flow_enqueue()Quoted 15 lines
doc/guides/prog_guide/rte_flow.rst and pattern and actions templates are created. · line 3802
Quoted 11 lines
doc/guides/prog_guide/rte_flow.rst +11
-0+ +.. code-block:: c + + struct rte_flow * + rte_flow_q_flow_create(uint16_t port_id, + uint32_t queue_id, + const struct rte_flow_q_ops_attr *q_ops_attr, + struct rte_flow_table *table, + const struct rte_flow_item pattern[], + uint8_t pattern_template_index, + const struct rte_flow_action actions[],If I understand correctly, table is the pre-configured object that has N number of patterns and N number of actions.
Why giving items[] and actions[] again?Table only contains templates for pattern and actions.
We still need to provide the values for those templates when we create a flow. Thus we specify patterns and action here.Quoted 11 lines
doc/guides/prog_guide/rte_flow.rst and pattern and actions templates are created.
Quoted 5 lines
doc/guides/prog_guide/rte_flow.rst +5
-0+ uint8_t actions_template_index, + struct rte_flow_error *error); + +A valid handle in case of success is returned. It must be destroyed later +by calling ``rte_flow_q_flow_destroy()`` even if the rule is rejected byHW.
doc/guides/prog_guide/rte_flow.rst and pattern and actions templates are created. · line 3810
Quoted 3 lines
doc/guides/prog_guide/rte_flow.rst +3
-0+ +Enqueue destruction operation +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Queue destruction operation.
We are not destroying queue, we are enqueuing the flow destruction operation.
Quoted 60 lines
doc/guides/prog_guide/rte_flow.rst and pattern and actions templates are created. · line 3812
Quoted 3 lines
doc/guides/prog_guide/rte_flow.rst +2
-0+ +Enqueueing a flow rule destruction operation is similar to simpledestruction.
Quoted 14 lines
doc/guides/prog_guide/rte_flow.rst +14
-0+ +.. code-block:: c + + int + rte_flow_q_flow_destroy(uint16_t port_id, + uint32_t queue_id, + const struct rte_flow_q_ops_attr *q_ops_attr, + struct rte_flow *flow, + struct rte_flow_error *error); + +Push enqueued operations +~~~~~~~~~~~~~~~~~~~~~~~~ + +Pushing all internally stored rules from a queue to the NIC.doc/guides/prog_guide/rte_flow.rst and pattern and actions templates are created.
Quoted 10 lines
doc/guides/prog_guide/rte_flow.rst +10
-0+ +.. code-block:: c + + int + rte_flow_q_push(uint16_t port_id, + uint32_t queue_id, + struct rte_flow_error *error); + +There is the postpone attribute in the queue operation attributes. +When it is set, multiple operations can be bulked together and not sent toHW
doc/guides/prog_guide/rte_flow.rst and pattern and actions templates are created. · line 3837
Quoted 1 line
doc/guides/prog_guide/rte_flow.rst +1
-0+right away to save SW/HW interactions and prioritize throughput overlatency.
doc/guides/prog_guide/rte_flow.rst and pattern and actions templates are created.
Quoted 9 lines
doc/guides/prog_guide/rte_flow.rst +9
-0+The application must invoke this function to actually push all outstanding +operations to HW in this case. + +Pull enqueued operations +~~~~~~~~~~~~~~~~~~~~~~~~ + +Pulling asynchronous operations results. + +The application must invoke this function in order to completeasynchronous
Quoted 19 lines
doc/guides/prog_guide/rte_flow.rst +19
-0+flow rule operations and to receive flow rule operations statuses. + +.. code-block:: c + + int + rte_flow_q_pull(uint16_t port_id, + uint32_t queue_id, + struct rte_flow_q_op_res res[], + uint16_t n_res, + struct rte_flow_error *error); + +Multiple outstanding operation results can be pulled simultaneously. +User data may be provided during a flow creation/destruction in order +to distinguish between multiple operations. User data is returned as part +of the result to provide a method to detect which operation is completed. + +Enqueue indirect action creation operation +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Quoted 8 lines
doc/guides/prog_guide/rte_flow.rst and pattern and actions templates are created. · line 3871
Quoted 6 lines
doc/guides/prog_guide/rte_flow.rst +6
-0+Asynchronous version of indirect action creation API. + +.. code-block:: c + + struct rte_flow_action_handle * + rte_flow_q_action_handle_create(uint16_t port_id,What is the use case for this?
Indirect action creation may take time, it may depend on hardware resources allocation. So we add the asynchronous way of creating it the same way.
Quoted 2 lines
How application needs to use this. We already creating
flow_table. Is that not sufficient?The indirect action object is used in flow rules via its handle. This is an extension to the already existing API in order to speed up the creation of these objects.
Quoted 63 lines
doc/guides/prog_guide/rte_flow.rst and pattern and actions templates are created.
Quoted 9 lines
doc/guides/prog_guide/rte_flow.rst +8
-0+ uint32_t queue_id, + const struct rte_flow_q_ops_attr *q_ops_attr, + const struct rte_flow_indir_action_conf *indir_action_conf, + const struct rte_flow_action *action, + struct rte_flow_error *error); + +A valid handle in case of success is returned. It must be destroyed later by +calling ``rte_flow_q_action_handle_destroy()`` even if the rule isrejected.
Review
Quoted 34 lines
doc/guides/prog_guide/rte_flow.rst +30
-0+ +Enqueue indirect action destruction operation +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Asynchronous version of indirect action destruction API. + +.. code-block:: c + + int + rte_flow_q_action_handle_destroy(uint16_t port_id, + uint32_t queue_id, + const struct rte_flow_q_ops_attr *q_ops_attr, + struct rte_flow_action_handle *action_handle, + struct rte_flow_error *error); + +Enqueue indirect action update operation +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Asynchronous version of indirect action update API. + +.. code-block:: c + + int + rte_flow_q_action_handle_update(uint16_t port_id, + uint32_t queue_id, + const struct rte_flow_q_ops_attr *q_ops_attr, + struct rte_flow_action_handle *action_handle, + const void *update, + struct rte_flow_error *error); + .. _flow_isolated_mode: Flow isolated mode(quoted diff) +0
-0
b/doc/guides/rel_notes/release_22_03.rstdoc/guides/rel_notes/release_22_03.rst New Features · line 70
Quoted 8 lines
index
d23d1591df..80a85124e6100644doc/guides/rel_notes/release_22_03.rst +1
-0@@ -67,6 +67,14 @@ New Features ``rte_flow_table_destroy``, ``rte_flow_pattern_template_destroy`` and ``rte_flow_actions_template_destroy``. +* ethdev: Added ``rte_flow_q_flow_create`` and``rte_flow_q_flow_destroy`` API
doc/guides/rel_notes/release_22_03.rst New Features · line 71
Quoted 1 line
doc/guides/rel_notes/release_22_03.rst +1
-0+ to enqueue flow creaion/destruction operations asynchronously as wellas
doc/guides/rel_notes/release_22_03.rst New Features
Quoted 4 lines
doc/guides/rel_notes/release_22_03.rst +4
-0+ ``rte_flow_q_pull`` to poll and retrieve results of these operations and + ``rte_flow_q_push`` to push all the in-flight operations to the NIC. + Introduced asynchronous API for indirect actions management as well: + ``rte_flow_q_action_handle_create``,``rte_flow_q_action_handle_destroy`` and
Quoted 2 lines
doc/guides/rel_notes/release_22_03.rst +2
-0+ ``rte_flow_q_action_handle_update``. +
Re: [PATCH v3 03/10] ethdev: bring in async queue-based flow rules operations
In reply to Alexander KozyrevQuoted 22 lines · Alexander Kozyrev
Quoted 6 lines · On Tuesday, February 8, 2022 5:57 Jerin Jacob <[email protected]> wrote:
On Sun, Feb 6, 2022 at 8:57 AM Alexander Kozyrev <[email protected]> wrote:
Quoted 15 lines
doc/guides/prog_guide/rte_flow.rst and pattern and actions templates are created. · line 3786
Quoted 13 lines
doc/guides/prog_guide/rte_flow.rst +13
-0+The asynchronous flow rule insertion logic can be broken into two phases. + +1. Initialization stage as shown here: + +.. _figure_rte_flow_q_init: + +.. figure:: img/rte_flow_q_init.* + +2. Main loop as presented on a datapath application example: + +.. _figure_rte_flow_q_usage: + +.. figure:: img/rte_flow_q_usage.*it is better to add sequence operations as text to understand the flow.
Quoted 2 lines
I prefer keeping the diagram here, it looks more clean and concise. Block of text gives no new information and harder to follow, IMHO.
I forgot to reply yesterday on this specific item.
IMO, The diagram is good. The request is, In the diagram, you can add items like
[1] [2] etc and corresponding text can be added either in image or as text See example https://doc.dpdk.org/guides/prog_guide/event_crypto_adapter.html
Fig. 49.2.
PATCH v3 4/10 app/testpmd: implement rte flow configuration
In reply to Alexander KozyrevAdd testpmd support for the rte_flow_configure API. Provide the command line interface for the Flow management. Usage example: flow configure 0 queues_number 8 queues_size 256
Implement rte_flow_info_get API to get available resources:
Usage example: flow info 0
--- app/test-pmd/cmdline_flow.c | 126 +++++++++++++++++++- app/test-pmd/config.c | 53 ++++++++ app/test-pmd/testpmd.h | 7 ++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 59 ++++++++- 4 files changed, 242 insertions(+), 3 deletions(-)
app/test-pmd/cmdline_flow.c +125 -1
@@ -72,6 +72,8 @@ enum index {/* Top-level command. */ FLOW ,/* Sub-level commands. */ +INFO , +CONFIGURE ,INDIRECT_ACTION ,VALIDATE , CREATE,
@@ -122,6 +124,13 @@ enum index {DUMP_ALL ,DUMP_ONE , +/* Configure arguments */ +CONFIG_QUEUES_NUMBER , +CONFIG_QUEUES_SIZE , +CONFIG_COUNTERS_NUMBER , +CONFIG_AGING_COUNTERS_NUMBER , +CONFIG_METERS_NUMBER , +/* Indirect action arguments */ INDIRECT_ACTION_CREATE , INDIRECT_ACTION_UPDATE,
@@ -846,6 +855,11 @@ struct buffer {enum index command;/**< Flow command. */ portid_t port;/**< Affected port ID. */ union { +struct { +struct rte_flow_port_attr port_attr; +uint32_t nb_queue; +struct rte_flow_queue_attr queue_attr; + } configure;/**< Configuration arguments. */ struct {uint32_t *action_id;uint32_t action_id_n;
@@ -927,6 +941,16 @@ static const enum index next_flex_item[] = { ZERO, }; +static const enum index next_config_attr[] = { +CONFIG_QUEUES_NUMBER , +CONFIG_QUEUES_SIZE , +CONFIG_COUNTERS_NUMBER , +CONFIG_AGING_COUNTERS_NUMBER , +CONFIG_METERS_NUMBER , +END , +ZERO , +}; +static const enum index next_ia_create_attr[] = {INDIRECT_ACTION_CREATE_ID ,INDIRECT_ACTION_INGRESS ,
@@ -1962,6 +1986,9 @@ static int parse_aged(struct context *, const struct token *,static int parse_isolate (struct context *,const struct token *,const char *,unsigned int ,void *,unsigned int ); +static int parse_configure (struct context *,const struct token *, +const char *,unsigned int , +void *,unsigned int );static int parse_tunnel (struct context *,const struct token *,const char *,unsigned int ,void *,unsigned int );
@@ -2187,7 +2214,9 @@ static const struct token token_list[] = { .type = "{command} {port_id} [{arg} [...]]", .help = "manage ingress/egress flow rules", .next = NEXT(NEXT_ENTRY - (INDIRECT_ACTION, + (INFO, + CONFIGURE, + INDIRECT_ACTION, VALIDATE, CREATE, DESTROY,
@@ -2202,6 +2231,65 @@ static const struct token token_list[] = { .call = parse_init, },/* Top-level command. */ + [INFO] = { + .name = "info", + .help = "get information about flow engine", + .next =NEXT (NEXT_ENTRY (END ), + NEXT_ENTRY(COMMON_PORT_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, port)), + .call = parse_configure, + }, +/* Top-level command. */ + [CONFIGURE] = { + .name = "configure", + .help = "configure flow engine", + .next =NEXT (next_config_attr, + NEXT_ENTRY(COMMON_PORT_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, port)), + .call = parse_configure, + }, +/* Configure arguments. */ + [CONFIG_QUEUES_NUMBER] = { + .name = "queues_number", + .help = "number of queues", + .next =NEXT (next_config_attr, + NEXT_ENTRY(COMMON_UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct buffer, + args.configure.nb_queue)), + }, + [CONFIG_QUEUES_SIZE] = { + .name = "queues_size", + .help = "number of elements in queues", + .next =NEXT (next_config_attr, + NEXT_ENTRY(COMMON_UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct buffer, + args.configure.queue_attr.size)), + }, + [CONFIG_COUNTERS_NUMBER] = { + .name = "counters_number", + .help = "number of counters", + .next =NEXT (next_config_attr, + NEXT_ENTRY(COMMON_UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct buffer, + args.configure.port_attr.nb_counters)), + }, + [CONFIG_AGING_COUNTERS_NUMBER] = { + .name = "aging_counters_number", + .help = "number of aging flows", + .next =NEXT (next_config_attr, + NEXT_ENTRY(COMMON_UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct buffer, + args.configure.port_attr.nb_aging_flows)), + }, + [CONFIG_METERS_NUMBER] = { + .name = "meters_number", + .help = "number of meters", + .next =NEXT (next_config_attr, + NEXT_ENTRY(COMMON_UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct buffer, + args.configure.port_attr.nb_meters)), + }, +/* Top-level command. */ [INDIRECT_ACTION] = { .name = "indirect_action", .type = "{command} {port_id} [{arg} [...]]",
@@ -7465,6 +7553,33 @@ parse_isolate(struct context *ctx, const struct token *token,return len; } +/** Parse tokens for info/configure command. */ +static int +parse_configure (struct context *ctx,const struct token *token, +const char *str,unsigned int len, +void *buf,unsigned int size) +{ +struct buffer *out = buf; + +/* Token name must match. */ +if (parse_default (ctx, token, str, len,NULL ,0 ) <0 ) +return -1 ; +/* Nothing else to do if there is no buffer. */ +if (!out) +return len; +if (!out->command) { +if (ctx->curr !=INFO && ctx->curr !=CONFIGURE ) +return -1 ; +if (sizeof (*out) > size) +return -1 ; + out->command = ctx->curr; + ctx->objdata =0 ; + ctx->object = out; + ctx->objmask =NULL ; + } +return len; +} + static int parse_flex(struct context *ctx, const struct token *token, const char *str, unsigned int len,
@@ -8693,6 +8808,15 @@ static void cmd_flow_parsed(const struct buffer *in) {switch (in->command) { +case INFO : +port_flow_get_info (in->port); +break ; +case CONFIGURE : +port_flow_configure (in->port, + &in->args.configure.port_attr, + in->args.configure.nb_queue, + &in->args.configure.queue_attr); +break ;case INDIRECT_ACTION_CREATE : port_action_handle_create( in->port, in->args.vc.attr.group,
app/test-pmd/config.c +53 -0
59 lines not on this page · raw message
app/test-pmd/testpmd.h +7 -0
@@ -243,6 +243,8 @@ struct rte_port {struct rte_eth_txconf tx_conf[RTE_MAX_QUEUES_PER_PORT +1 ];/**< per queue tx configuration */ struct rte_ether_addr *mc_addr_pool;/**< pool of multicast addrs */ uint32_t mc_addr_nb;/**< nb. of addr. in mc_addr_pool */ +queueid_t queue_nb;/**< nb. of queues for flow rules */ +uint32_t queue_sz;/**< size of a queue for flow rules */ uint8_t slave_flag;/**< bonding slave port */ struct port_flow *flow_list;/**< Associated flows. */ struct port_indirect_action *actions_list;
@@ -885,6 +887,11 @@ struct rte_flow_action_handle *port_action_handle_get_by_id(portid_t port_id, uint32_t id);int port_action_handle_update (portid_t port_id,uint32_t id,const struct rte_flow_action *action); +int port_flow_get_info (portid_t port_id); +int port_flow_configure (portid_t port_id, +const struct rte_flow_port_attr *port_attr, +uint16_t nb_queue, +const struct rte_flow_queue_attr *queue_attr); int port_flow_validate(portid_t port_id, const struct rte_flow_attr *attr, const struct rte_flow_item *pattern,
doc/guides/testpmd_app_ug/testpmd_funcs.rst +57 -2
77 lines not on this page · raw message
Signature · 1 line
2.18.2
RE: [PATCH v3 04/10] app/testpmd: implement rte flow configuration
Hi Alexander,
Quoted 9 lines
-----Original Message-----
From: Alexander Kozyrev <[email protected]>
Sent: Sunday, February 6, 2022 5:25 AM
Subject: [PATCH v3 04/10] app/testpmd: implement rte flow configurationAdd testpmd support for the
rte_flow_configureAPI. Provide the command line interface for the Flow management. Usage example: flow configure 0queues_number8queues_size256
Quoted 5 lines
Implement
rte_flow_info_getAPI to get available resources:
Usage example: flow info 0Signed-off-by Alexander Kozyrev <[email protected]>---
Best,
Ori
PATCH v3 5/10 app/testpmd: implement rte flow template management
In reply to Alexander KozyrevAdd testpmd support for the rte_flow_pattern_template and rte_flow_actions_template APIs. Provide the command line interface for the template creation/destruction. Usage example:
testpmd> flow pattern_template 0 create pattern_template_id 2
template eth dst is 00:16:3e:31:15:c3 / end
testpmd> flow actions_template 0 create actions_template_id 4
template drop / end mask drop / end
testpmd> flow actions_template 0 destroy actions_template 4 testpmd> flow pattern_template 0 destroy pattern_template 2
--- app/test-pmd/cmdline_flow.c | 376 +++++++++++++++++++- app/test-pmd/config.c | 204 +++++++++++ app/test-pmd/testpmd.h | 23 ++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 97 +++++ 4 files changed, 698 insertions(+), 2 deletions(-)
app/test-pmd/cmdline_flow.c +374 -2
@@ -56,6 +56,8 @@ enum index {COMMON_POLICY_ID ,COMMON_FLEX_HANDLE ,COMMON_FLEX_TOKEN , +COMMON_PATTERN_TEMPLATE_ID , +COMMON_ACTIONS_TEMPLATE_ID ,/* TOP-level command. */ ADD,
@@ -74,6 +76,8 @@ enum index {/* Sub-level commands. */ INFO ,CONFIGURE , +PATTERN_TEMPLATE , +ACTIONS_TEMPLATE ,INDIRECT_ACTION ,VALIDATE , CREATE,
@@ -92,6 +96,22 @@ enum index {FLEX_ITEM_CREATE ,FLEX_ITEM_DESTROY , +/* Pattern template arguments. */ +PATTERN_TEMPLATE_CREATE , +PATTERN_TEMPLATE_DESTROY , +PATTERN_TEMPLATE_CREATE_ID , +PATTERN_TEMPLATE_DESTROY_ID , +PATTERN_TEMPLATE_RELAXED_MATCHING , +PATTERN_TEMPLATE_SPEC , + +/* Actions template arguments. */ +ACTIONS_TEMPLATE_CREATE , +ACTIONS_TEMPLATE_DESTROY , +ACTIONS_TEMPLATE_CREATE_ID , +ACTIONS_TEMPLATE_DESTROY_ID , +ACTIONS_TEMPLATE_SPEC , +ACTIONS_TEMPLATE_MASK , +/* Tunnel arguments. */ TUNNEL_CREATE , TUNNEL_CREATE_TYPE,
@@ -860,6 +880,10 @@ struct buffer {uint32_t nb_queue;struct rte_flow_queue_attr queue_attr; } configure;/**< Configuration arguments. */ +struct { +uint32_t *template_id; +uint32_t template_id_n; + } templ_destroy;/**< Template destroy arguments. */ struct {uint32_t *action_id;uint32_t action_id_n;
@@ -868,10 +892,13 @@ struct buffer {uint32_t action_id; } ia;/* Indirect action query arguments */ struct { +uint32_t pat_templ_id; +uint32_t act_templ_id;struct rte_flow_attr attr;struct tunnel_ops tunnel_ops;struct rte_flow_item *pattern;struct rte_flow_action *actions; +struct rte_flow_action *masks;uint32_t pattern_n;uint32_t actions_n;uint8_t *data;
@@ -951,6 +978,43 @@ static const enum index next_config_attr[] = { ZERO, }; +static const enum index next_pt_subcmd[] = { +PATTERN_TEMPLATE_CREATE , +PATTERN_TEMPLATE_DESTROY , +ZERO , +}; + +static const enum index next_pt_attr[] = { +PATTERN_TEMPLATE_CREATE_ID , +PATTERN_TEMPLATE_RELAXED_MATCHING , +PATTERN_TEMPLATE_SPEC , +ZERO , +}; + +static const enum index next_pt_destroy_attr[] = { +PATTERN_TEMPLATE_DESTROY_ID , +END , +ZERO , +}; + +static const enum index next_at_subcmd[] = { +ACTIONS_TEMPLATE_CREATE , +ACTIONS_TEMPLATE_DESTROY , +ZERO , +}; + +static const enum index next_at_attr[] = { +ACTIONS_TEMPLATE_CREATE_ID , +ACTIONS_TEMPLATE_SPEC , +ZERO , +}; + +static const enum index next_at_destroy_attr[] = { +ACTIONS_TEMPLATE_DESTROY_ID , +END , +ZERO , +}; +static const enum index next_ia_create_attr[] = {INDIRECT_ACTION_CREATE_ID ,INDIRECT_ACTION_INGRESS ,
@@ -1989,6 +2053,12 @@ static int parse_isolate(struct context *, const struct token *,static int parse_configure (struct context *,const struct token *,const char *,unsigned int ,void *,unsigned int ); +static int parse_template (struct context *,const struct token *, +const char *,unsigned int , +void *,unsigned int ); +static int parse_template_destroy (struct context *,const struct token *, +const char *,unsigned int , +void *,unsigned int );static int parse_tunnel (struct context *,const struct token *,const char *,unsigned int ,void *,unsigned int );
@@ -2058,6 +2128,10 @@ static int comp_set_modify_field_op(struct context *, const struct token *, unsigned int, char *, unsigned int);static int comp_set_modify_field_id (struct context *,const struct token *,unsigned int ,char *,unsigned int ); +static int comp_pattern_template_id (struct context *,const struct token *, +unsigned int ,char *,unsigned int ); +static int comp_actions_template_id (struct context *,const struct token *, +unsigned int ,char *,unsigned int );/** Token definitions. */ static const struct token token_list[] = {
@@ -2208,6 +2282,20 @@ static const struct token token_list[] = { .call = parse_flex_handle, .comp = comp_none, }, + [COMMON_PATTERN_TEMPLATE_ID] = { + .name = "{pattern_template_id}", + .type = "PATTERN_TEMPLATE_ID", + .help = "pattern template id", + .call = parse_int, + .comp = comp_pattern_template_id, + }, + [COMMON_ACTIONS_TEMPLATE_ID] = { + .name = "{actions_template_id}", + .type = "ACTIONS_TEMPLATE_ID", + .help = "actions template id", + .call = parse_int, + .comp = comp_actions_template_id, + },/* Top-level command. */ [FLOW] = { .name = "flow",
@@ -2216,6 +2304,8 @@ static const struct token token_list[] = { .next = NEXT(NEXT_ENTRY (INFO, CONFIGURE, + PATTERN_TEMPLATE, + ACTIONS_TEMPLATE, INDIRECT_ACTION, VALIDATE, CREATE,
@@ -2290,6 +2380,112 @@ static const struct token token_list[] = { args.configure.port_attr.nb_meters)), },/* Top-level command. */ + [PATTERN_TEMPLATE] = { + .name = "pattern_template", + .type = "{command} {port_id} [{arg} [...]]", + .help = "manage pattern templates", + .next = NEXT(next_pt_subcmd, NEXT_ENTRY(COMMON_PORT_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, port)), + .call = parse_template, + }, +/* Sub-level commands. */ + [PATTERN_TEMPLATE_CREATE] = { + .name = "create", + .help = "create pattern template", + .next = NEXT(next_pt_attr), + .call = parse_template, + }, + [PATTERN_TEMPLATE_DESTROY] = { + .name = "destroy", + .help = "destroy pattern template", + .next = NEXT(NEXT_ENTRY(PATTERN_TEMPLATE_DESTROY_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, port)), + .call = parse_template_destroy, + }, +/* Pattern template arguments. */ + [PATTERN_TEMPLATE_CREATE_ID] = { + .name = "pattern_template_id", + .help = "specify a pattern template id to create", + .next =NEXT (next_pt_attr, + NEXT_ENTRY(COMMON_PATTERN_TEMPLATE_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.pat_templ_id)), + }, + [PATTERN_TEMPLATE_DESTROY_ID] = { + .name = "pattern_template", + .help = "specify a pattern template id to destroy", + .next =NEXT (next_pt_destroy_attr, + NEXT_ENTRY(COMMON_PATTERN_TEMPLATE_ID)), + .args = ARGS(ARGS_ENTRY_PTR(struct buffer, + args.templ_destroy.template_id)), + .call = parse_template_destroy, + }, + [PATTERN_TEMPLATE_RELAXED_MATCHING] = { + .name = "relaxed", + .help = "is matching relaxed", + .next =NEXT (next_pt_attr, + NEXT_ENTRY(COMMON_BOOLEAN)), + .args = ARGS(ARGS_ENTRY_BF(struct buffer, + args.vc.attr.reserved, 1)), + }, + [PATTERN_TEMPLATE_SPEC] = { + .name = "template", + .help = "specify item to create pattern template", + .next = NEXT(next_item), + }, +/* Top-level command. */ + [ACTIONS_TEMPLATE] = { + .name = "actions_template", + .type = "{command} {port_id} [{arg} [...]]", + .help = "manage actions templates", + .next = NEXT(next_at_subcmd, NEXT_ENTRY(COMMON_PORT_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, port)), + .call = parse_template, + }, +/* Sub-level commands. */ + [ACTIONS_TEMPLATE_CREATE] = { + .name = "create", + .help = "create actions template", + .next = NEXT(next_at_attr), + .call = parse_template, + }, + [ACTIONS_TEMPLATE_DESTROY] = { + .name = "destroy", + .help = "destroy actions template", + .next = NEXT(NEXT_ENTRY(ACTIONS_TEMPLATE_DESTROY_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, port)), + .call = parse_template_destroy, + }, +/* Actions template arguments. */ + [ACTIONS_TEMPLATE_CREATE_ID] = { + .name = "actions_template_id", + .help = "specify an actions template id to create", + .next =NEXT (NEXT_ENTRY (ACTIONS_TEMPLATE_MASK ), +NEXT_ENTRY (ACTIONS_TEMPLATE_SPEC ), + NEXT_ENTRY(COMMON_ACTIONS_TEMPLATE_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.act_templ_id)), + }, + [ACTIONS_TEMPLATE_DESTROY_ID] = { + .name = "actions_template", + .help = "specify an actions template id to destroy", + .next =NEXT (next_at_destroy_attr, + NEXT_ENTRY(COMMON_ACTIONS_TEMPLATE_ID)), + .args = ARGS(ARGS_ENTRY_PTR(struct buffer, + args.templ_destroy.template_id)), + .call = parse_template_destroy, + }, + [ACTIONS_TEMPLATE_SPEC] = { + .name = "template", + .help = "specify action to create actions template", + .next = NEXT(next_action), + .call = parse_template, + }, + [ACTIONS_TEMPLATE_MASK] = { + .name = "mask", + .help = "specify action mask to create actions template", + .next = NEXT(next_action), + .call = parse_template, + }, +/* Top-level command. */ [INDIRECT_ACTION] = { .name = "indirect_action", .type = "{command} {port_id} [{arg} [...]]",
@@ -2612,7 +2808,7 @@ static const struct token token_list[] = { .name = "end", .help = "end list of pattern items", .priv = PRIV_ITEM(END, 0), - .next = NEXT(NEXT_ENTRY(ACTIONS)), + .next = NEXT(NEXT_ENTRY(ACTIONS, END)), .call = parse_vc, }, [ITEM_VOID] = {
@@ -5716,7 +5912,9 @@ parse_vc(struct context *ctx, const struct token *token,if (!out)return len;if (!out->command) { -if (ctx->curr !=VALIDATE && ctx->curr !=CREATE ) +if (ctx->curr !=VALIDATE && ctx->curr !=CREATE && + ctx->curr !=PATTERN_TEMPLATE_CREATE && + ctx->curr !=ACTIONS_TEMPLATE_CREATE )return -1 ;if (sizeof (*out) > size)return -1 ;
@@ -7580,6 +7778,114 @@ parse_configure(struct context *ctx, const struct token *token,return len; } +/** Parse tokens for template create command. */ +static int +parse_template (struct context *ctx,const struct token *token, +const char *str,unsigned int len, +void *buf,unsigned int size) +{ +struct buffer *out = buf; + +/* Token name must match. */ +if (parse_default (ctx, token, str, len,NULL ,0 ) <0 ) +return -1 ; +/* Nothing else to do if there is no buffer. */ +if (!out) +return len; +if (!out->command) { +if (ctx->curr !=PATTERN_TEMPLATE && + ctx->curr !=ACTIONS_TEMPLATE ) +return -1 ; +if (sizeof (*out) > size) +return -1 ; + out->command = ctx->curr; + ctx->objdata =0 ; + ctx->object = out; + ctx->objmask =NULL ; + out->args.vc.data = (uint8_t *)out + size; +return len; + } +switch (ctx->curr) { +case PATTERN_TEMPLATE_CREATE : + out->args.vc.pattern = + (void *)RTE_ALIGN_CEIL ((uintptr_t )(out +1 ), +sizeof (double )); + out->args.vc.pat_templ_id =UINT32_MAX ; + out->command = ctx->curr; + ctx->objdata =0 ; + ctx->object = out; + ctx->objmask =NULL ; +return len; +case ACTIONS_TEMPLATE_CREATE : + out->args.vc.act_templ_id =UINT32_MAX ; + out->command = ctx->curr; + ctx->objdata =0 ; + ctx->object = out; + ctx->objmask =NULL ; +return len; +case ACTIONS_TEMPLATE_SPEC : + out->args.vc.actions = + (void *)RTE_ALIGN_CEIL ((uintptr_t )(out +1 ), +sizeof (double )); + ctx->object = out->args.vc.actions; + ctx->objmask =NULL ; +return len; +case ACTIONS_TEMPLATE_MASK : + out->args.vc.masks = + (void *)RTE_ALIGN_CEIL ((uintptr_t ) + (out->args.vc.actions + + out->args.vc.actions_n), +sizeof (double )); + ctx->object = out->args.vc.masks; + ctx->objmask =NULL ; +return len; +default : +return -1 ; + } +} + +/** Parse tokens for template destroy command. */ +static int +parse_template_destroy (struct context *ctx,const struct token *token, +const char *str,unsigned int len, +void *buf,unsigned int size) +{ +struct buffer *out = buf; +uint32_t *template_id; + +/* Token name must match. */ +if (parse_default (ctx, token, str, len,NULL ,0 ) <0 ) +return -1 ; +/* Nothing else to do if there is no buffer. */ +if (!out) +return len; +if (!out->command || + out->command ==PATTERN_TEMPLATE || + out->command ==ACTIONS_TEMPLATE ) { +if (ctx->curr !=PATTERN_TEMPLATE_DESTROY && + ctx->curr !=ACTIONS_TEMPLATE_DESTROY ) +return -1 ; +if (sizeof (*out) > size) +return -1 ; + out->command = ctx->curr; + ctx->objdata =0 ; + ctx->object = out; + ctx->objmask =NULL ; + out->args.templ_destroy.template_id = + (void *)RTE_ALIGN_CEIL ((uintptr_t )(out +1 ), +sizeof (double )); +return len; + } + template_id = out->args.templ_destroy.template_id + + out->args.templ_destroy.template_id_n++; +if ((uint8_t *)template_id > (uint8_t *)out + size) +return -1 ; + ctx->objdata =0 ; + ctx->object = template_id; + ctx->objmask =NULL ; +return len; +} + static int parse_flex(struct context *ctx, const struct token *token, const char *str, unsigned int len,
@@ -8549,6 +8855,54 @@ comp_set_modify_field_id(struct context *ctx, const struct token *token,return -1 ; } +/** Complete available pattern template IDs. */ +static int +comp_pattern_template_id (struct context *ctx,const struct token *token, +unsigned int ent,char *buf,unsigned int size) +{ +unsigned int i =0 ; +struct rte_port *port; +struct port_template *pt; + + (void )token; +if (port_id_is_invalid (ctx->port,DISABLED_WARN ) || + ctx->port == (portid_t )RTE_PORT_ALL ) +return -1 ; + port = &ports[ctx->port]; +for (pt = port->pattern_templ_list; pt !=NULL ; pt = pt->next) { +if (buf && i == ent) +return snprintf (buf, size,"%u" , pt->id); + ++i; + } +if (buf) +return -1 ; +return i; +} + +/** Complete available actions template IDs. */ +static int +comp_actions_template_id (struct context *ctx,const struct token *token, +unsigned int ent,char *buf,unsigned int size) +{ +unsigned int i =0 ; +struct rte_port *port; +struct port_template *pt; + + (void )token; +if (port_id_is_invalid (ctx->port,DISABLED_WARN ) || + ctx->port == (portid_t )RTE_PORT_ALL ) +return -1 ; + port = &ports[ctx->port]; +for (pt = port->actions_templ_list; pt !=NULL ; pt = pt->next) { +if (buf && i == ent) +return snprintf (buf, size,"%u" , pt->id); + ++i; + } +if (buf) +return -1 ; +return i; +} +/** Internal context. */ static struct context cmd_flow_context;
@@ -8817,6 +9171,24 @@ cmd_flow_parsed(const struct buffer *in) in->args.configure.nb_queue, &in->args.configure.queue_attr);break ; +case PATTERN_TEMPLATE_CREATE : +port_flow_pattern_template_create (in->port, in->args.vc.pat_templ_id, + in->args.vc.attr.reserved, in->args.vc.pattern); +break ; +case PATTERN_TEMPLATE_DESTROY : +port_flow_pattern_template_destroy (in->port, + in->args.templ_destroy.template_id_n, + in->args.templ_destroy.template_id); +break ; +case ACTIONS_TEMPLATE_CREATE : +port_flow_actions_template_create (in->port, in->args.vc.act_templ_id, + in->args.vc.actions, in->args.vc.masks); +break ; +case ACTIONS_TEMPLATE_DESTROY : +port_flow_actions_template_destroy (in->port, + in->args.templ_destroy.template_id_n, + in->args.templ_destroy.template_id); +break ;case INDIRECT_ACTION_CREATE : port_action_handle_create( in->port, in->args.vc.attr.group,
app/test-pmd/config.c +204 -0
216 lines not on this page · raw message
app/test-pmd/testpmd.h +23 -0
@@ -166,6 +166,17 @@ enum age_action_context_type { ACTION_AGE_CONTEXT_TYPE_INDIRECT_ACTION, }; +/** Descriptor for a template. */ +struct port_template { +struct port_template *next;/**< Next template in list. */ +struct port_template *tmp;/**< Temporary linking. */ +uint32_t id;/**< Template ID. */ +union { +struct rte_flow_pattern_template *pattern_template; +struct rte_flow_actions_template *actions_template; + } template;/**< PMD opaque template object */ +}; +/** Descriptor for a single flow. */ struct port_flow {struct port_flow *next;/**< Next flow in list. */
@@ -246,6 +257,8 @@ struct rte_port {queueid_t queue_nb;/**< nb. of queues for flow rules */ uint32_t queue_sz;/**< size of a queue for flow rules */ uint8_t slave_flag;/**< bonding slave port */ +struct port_template *pattern_templ_list;/**< Pattern templates. */ +struct port_template *actions_templ_list;/**< Actions templates. */ struct port_flow *flow_list;/**< Associated flows. */ struct port_indirect_action *actions_list;/**< Associated indirect actions. */
@@ -892,6 +905,16 @@ int port_flow_configure(portid_t port_id,const struct rte_flow_port_attr *port_attr, uint16_t nb_queue, const struct rte_flow_queue_attr *queue_attr); +int port_flow_pattern_template_create (portid_t port_id,uint32_t id, +bool relaxed, +const struct rte_flow_item *pattern); +int port_flow_pattern_template_destroy (portid_t port_id,uint32_t n, +const uint32_t *template); +int port_flow_actions_template_create (portid_t port_id,uint32_t id, +const struct rte_flow_action *actions, +const struct rte_flow_action *masks); +int port_flow_actions_template_destroy (portid_t port_id,uint32_t n, +const uint32_t *template); int port_flow_validate(portid_t port_id, const struct rte_flow_attr *attr, const struct rte_flow_item *pattern,
doc/guides/testpmd_app_ug/testpmd_funcs.rst +97 -0
109 lines not on this page · raw message
Signature · 1 line
2.18.2
RE: [PATCH v3 05/10] app/testpmd: implement rte flow template management
Hi Alexander,
Quoted 10 lines
-----Original Message-----
From: Alexander Kozyrev <[email protected]>
Sent: Sunday, February 6, 2022 5:25 AM
To: [email protected]
Subject: [PATCH v3 05/10] app/testpmd: implement rte flow template managementAdd testpmd support for the
rte_flow_pattern_templateandrte_flow_actions_templateAPIs. Provide the command line interface for the template creation/destruction. Usage example:
testpmd> flowpattern_template0 createpattern_template_id2
Quoted 8 lines
template eth dst is 00:16:3e:31:15:c3 / endtestpmd> flow
actions_template0 createactions_template_id4
template drop / end mask drop / end
testpmd> flowactions_template0 destroyactions_template4 testpmd> flowpattern_template0 destroypattern_template2Signed-off-by Alexander Kozyrev <[email protected]>---
Best,
Ori
PATCH v3 6/10 app/testpmd: implement rte flow table management
In reply to Alexander KozyrevAdd testpmd support for the rte_flow_table API. Provide the command line interface for the flow table creation/destruction. Usage example:
testpmd> flow table 0 create table_id 6
group 9 priority 4 ingress mode 1 rules_number 64 pattern_template 2 actions_template 4
testpmd> flow table 0 destroy table 6
--- app/test-pmd/cmdline_flow.c | 315 ++++++++++++++++++++ app/test-pmd/config.c | 170 +++++++++++ app/test-pmd/testpmd.h | 17 ++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 53 ++++ 4 files changed, 555 insertions(+)
app/test-pmd/cmdline_flow.c +315 -0
@@ -58,6 +58,7 @@ enum index {COMMON_FLEX_TOKEN ,COMMON_PATTERN_TEMPLATE_ID ,COMMON_ACTIONS_TEMPLATE_ID , +COMMON_TABLE_ID ,/* TOP-level command. */ ADD,
@@ -78,6 +79,7 @@ enum index {CONFIGURE ,PATTERN_TEMPLATE ,ACTIONS_TEMPLATE , +TABLE ,INDIRECT_ACTION ,VALIDATE , CREATE,
@@ -112,6 +114,20 @@ enum index {ACTIONS_TEMPLATE_SPEC ,ACTIONS_TEMPLATE_MASK , +/* Table arguments. */ +TABLE_CREATE , +TABLE_DESTROY , +TABLE_CREATE_ID , +TABLE_DESTROY_ID , +TABLE_GROUP , +TABLE_PRIORITY , +TABLE_INGRESS , +TABLE_EGRESS , +TABLE_TRANSFER , +TABLE_RULES_NUMBER , +TABLE_PATTERN_TEMPLATE , +TABLE_ACTIONS_TEMPLATE , +/* Tunnel arguments. */ TUNNEL_CREATE , TUNNEL_CREATE_TYPE,
@@ -884,6 +900,18 @@ struct buffer {uint32_t *template_id;uint32_t template_id_n; } templ_destroy;/**< Template destroy arguments. */ +struct { +uint32_t id; +struct rte_flow_table_attr attr; +uint32_t *pat_templ_id; +uint32_t pat_templ_id_n; +uint32_t *act_templ_id; +uint32_t act_templ_id_n; + } table;/**< Table arguments. */ +struct { +uint32_t *table_id; +uint32_t table_id_n; + } table_destroy;/**< Template destroy arguments. */ struct {uint32_t *action_id;uint32_t action_id_n;
@@ -1015,6 +1043,32 @@ static const enum index next_at_destroy_attr[] = { ZERO, }; +static const enum index next_table_subcmd[] = { +TABLE_CREATE , +TABLE_DESTROY , +ZERO , +}; + +static const enum index next_table_attr[] = { +TABLE_CREATE_ID , +TABLE_GROUP , +TABLE_PRIORITY , +TABLE_INGRESS , +TABLE_EGRESS , +TABLE_TRANSFER , +TABLE_RULES_NUMBER , +TABLE_PATTERN_TEMPLATE , +TABLE_ACTIONS_TEMPLATE , +END , +ZERO , +}; + +static const enum index next_table_destroy_attr[] = { +TABLE_DESTROY_ID , +END , +ZERO , +}; +static const enum index next_ia_create_attr[] = {INDIRECT_ACTION_CREATE_ID ,INDIRECT_ACTION_INGRESS ,
@@ -2059,6 +2113,11 @@ static int parse_template(struct context *, const struct token *,static int parse_template_destroy (struct context *,const struct token *,const char *,unsigned int ,void *,unsigned int ); +static int parse_table (struct context *,const struct token *, +const char *,unsigned int ,void *,unsigned int ); +static int parse_table_destroy (struct context *,const struct token *, +const char *,unsigned int , +void *,unsigned int );static int parse_tunnel (struct context *,const struct token *,const char *,unsigned int ,void *,unsigned int );
@@ -2132,6 +2191,8 @@ static int comp_pattern_template_id(struct context *, const struct token *, unsigned int, char *, unsigned int);static int comp_actions_template_id (struct context *,const struct token *,unsigned int ,char *,unsigned int ); +static int comp_table_id (struct context *,const struct token *, +unsigned int ,char *,unsigned int );/** Token definitions. */ static const struct token token_list[] = {
@@ -2296,6 +2357,13 @@ static const struct token token_list[] = { .call = parse_int, .comp = comp_actions_template_id, }, + [COMMON_TABLE_ID] = { + .name = "{table_id}", + .type = "TABLE_ID", + .help = "table id", + .call = parse_int, + .comp = comp_table_id, + },/* Top-level command. */ [FLOW] = { .name = "flow",
@@ -2306,6 +2374,7 @@ static const struct token token_list[] = {CONFIGURE ,PATTERN_TEMPLATE ,ACTIONS_TEMPLATE , +TABLE ,INDIRECT_ACTION ,VALIDATE , CREATE,
@@ -2486,6 +2555,104 @@ static const struct token token_list[] = { .call = parse_template, },/* Top-level command. */ + [TABLE] = { + .name = "table", + .type = "{command} {port_id} [{arg} [...]]", + .help = "manage tables", + .next = NEXT(next_table_subcmd, NEXT_ENTRY(COMMON_PORT_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, port)), + .call = parse_table, + }, +/* Sub-level commands. */ + [TABLE_CREATE] = { + .name = "create", + .help = "create table", + .next = NEXT(next_table_attr), + .call = parse_table, + }, + [TABLE_DESTROY] = { + .name = "destroy", + .help = "destroy table", + .next = NEXT(NEXT_ENTRY(TABLE_DESTROY_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, port)), + .call = parse_table_destroy, + }, +/* Table arguments. */ + [TABLE_CREATE_ID] = { + .name = "table_id", + .help = "specify table id to create", + .next =NEXT (next_table_attr, + NEXT_ENTRY(COMMON_TABLE_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, args.table.id)), + }, + [TABLE_DESTROY_ID] = { + .name = "table", + .help = "specify table id to destroy", + .next =NEXT (next_table_destroy_attr, + NEXT_ENTRY(COMMON_TABLE_ID)), + .args = ARGS(ARGS_ENTRY_PTR(struct buffer, + args.table_destroy.table_id)), + .call = parse_table_destroy, + }, + [TABLE_GROUP] = { + .name = "group", + .help = "specify a group", + .next = NEXT(next_table_attr, NEXT_ENTRY(COMMON_GROUP_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, + args.table.attr.flow_attr.group)), + }, + [TABLE_PRIORITY] = { + .name = "priority", + .help = "specify a priority level", + .next = NEXT(next_table_attr, NEXT_ENTRY(COMMON_PRIORITY_LEVEL)), + .args = ARGS(ARGS_ENTRY(struct buffer, + args.table.attr.flow_attr.priority)), + }, + [TABLE_EGRESS] = { + .name = "egress", + .help = "affect rule to egress", + .next = NEXT(next_table_attr), + .call = parse_table, + }, + [TABLE_INGRESS] = { + .name = "ingress", + .help = "affect rule to ingress", + .next = NEXT(next_table_attr), + .call = parse_table, + }, + [TABLE_TRANSFER] = { + .name = "transfer", + .help = "affect rule to transfer", + .next = NEXT(next_table_attr), + .call = parse_table, + }, + [TABLE_RULES_NUMBER] = { + .name = "rules_number", + .help = "number of rules in table", + .next =NEXT (next_table_attr, + NEXT_ENTRY(COMMON_UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct buffer, + args.table.attr.nb_flows)), + }, + [TABLE_PATTERN_TEMPLATE] = { + .name = "pattern_template", + .help = "specify pattern template id", + .next =NEXT (next_table_attr, + NEXT_ENTRY(COMMON_PATTERN_TEMPLATE_ID)), + .args = ARGS(ARGS_ENTRY_PTR(struct buffer, + args.table.pat_templ_id)), + .call = parse_table, + }, + [TABLE_ACTIONS_TEMPLATE] = { + .name = "actions_template", + .help = "specify actions template id", + .next =NEXT (next_table_attr, + NEXT_ENTRY(COMMON_ACTIONS_TEMPLATE_ID)), + .args = ARGS(ARGS_ENTRY_PTR(struct buffer, + args.table.act_templ_id)), + .call = parse_table, + }, +/* Top-level command. */ [INDIRECT_ACTION] = { .name = "indirect_action", .type = "{command} {port_id} [{arg} [...]]",
@@ -7886,6 +8053,119 @@ parse_template_destroy(struct context *ctx, const struct token *token,return len; } +/** Parse tokens for table create command. */ +static int +parse_table (struct context *ctx,const struct token *token, +const char *str,unsigned int len, +void *buf,unsigned int size) +{ +struct buffer *out = buf; +uint32_t *template_id; + +/* Token name must match. */ +if (parse_default (ctx, token, str, len,NULL ,0 ) <0 ) +return -1 ; +/* Nothing else to do if there is no buffer. */ +if (!out) +return len; +if (!out->command) { +if (ctx->curr !=TABLE ) +return -1 ; +if (sizeof (*out) > size) +return -1 ; + out->command = ctx->curr; + ctx->objdata =0 ; + ctx->object = out; + ctx->objmask =NULL ; +return len; + } +switch (ctx->curr) { +case TABLE_CREATE : + out->command = ctx->curr; + ctx->objdata =0 ; + ctx->object = out; + ctx->objmask =NULL ; + out->args.table.id =UINT32_MAX ; +return len; +case TABLE_PATTERN_TEMPLATE : + out->args.table.pat_templ_id = + (void *)RTE_ALIGN_CEIL ((uintptr_t )(out +1 ), +sizeof (double )); + template_id = out->args.table.pat_templ_id + + out->args.table.pat_templ_id_n++; +if ((uint8_t *)template_id > (uint8_t *)out + size) +return -1 ; + ctx->objdata =0 ; + ctx->object = template_id; + ctx->objmask =NULL ; +return len; +case TABLE_ACTIONS_TEMPLATE : + out->args.table.act_templ_id = + (void *)RTE_ALIGN_CEIL ((uintptr_t ) + (out->args.table.pat_templ_id + + out->args.table.pat_templ_id_n), +sizeof (double )); + template_id = out->args.table.act_templ_id + + out->args.table.act_templ_id_n++; +if ((uint8_t *)template_id > (uint8_t *)out + size) +return -1 ; + ctx->objdata =0 ; + ctx->object = template_id; + ctx->objmask =NULL ; +return len; +case TABLE_INGRESS : + out->args.table.attr.flow_attr.ingress =1 ; +return len; +case TABLE_EGRESS : + out->args.table.attr.flow_attr.egress =1 ; +return len; +case TABLE_TRANSFER : + out->args.table.attr.flow_attr.transfer =1 ; +return len; +default : +return -1 ; + } +} + +/** Parse tokens for table destroy command. */ +static int +parse_table_destroy (struct context *ctx,const struct token *token, +const char *str,unsigned int len, +void *buf,unsigned int size) +{ +struct buffer *out = buf; +uint32_t *table_id; + +/* Token name must match. */ +if (parse_default (ctx, token, str, len,NULL ,0 ) <0 ) +return -1 ; +/* Nothing else to do if there is no buffer. */ +if (!out) +return len; +if (!out->command || out->command ==TABLE ) { +if (ctx->curr !=TABLE_DESTROY ) +return -1 ; +if (sizeof (*out) > size) +return -1 ; + out->command = ctx->curr; + ctx->objdata =0 ; + ctx->object = out; + ctx->objmask =NULL ; + out->args.table_destroy.table_id = + (void *)RTE_ALIGN_CEIL ((uintptr_t )(out +1 ), +sizeof (double )); +return len; + } + table_id = out->args.table_destroy.table_id + + out->args.table_destroy.table_id_n++; +if ((uint8_t *)table_id > (uint8_t *)out + size) +return -1 ; + ctx->objdata =0 ; + ctx->object = table_id; + ctx->objmask =NULL ; +return len; +} + static int parse_flex(struct context *ctx, const struct token *token, const char *str, unsigned int len,
@@ -8903,6 +9183,30 @@ comp_actions_template_id(struct context *ctx, const struct token *token,return i; } +/** Complete available table IDs. */ +static int +comp_table_id (struct context *ctx,const struct token *token, +unsigned int ent,char *buf,unsigned int size) +{ +unsigned int i =0 ; +struct rte_port *port; +struct port_table *pt; + + (void )token; +if (port_id_is_invalid (ctx->port,DISABLED_WARN ) || + ctx->port == (portid_t )RTE_PORT_ALL ) +return -1 ; + port = &ports[ctx->port]; +for (pt = port->table_list; pt !=NULL ; pt = pt->next) { +if (buf && i == ent) +return snprintf (buf, size,"%u" , pt->id); + ++i; + } +if (buf) +return -1 ; +return i; +} +/** Internal context. */ static struct context cmd_flow_context;
@@ -9189,6 +9493,17 @@ cmd_flow_parsed(const struct buffer *in) in->args.templ_destroy.template_id_n, in->args.templ_destroy.template_id);break ; +case TABLE_CREATE : +port_flow_table_create (in->port, in->args.table.id, + &in->args.table.attr, in->args.table.pat_templ_id_n, + in->args.table.pat_templ_id, in->args.table.act_templ_id_n, + in->args.table.act_templ_id); +break ; +case TABLE_DESTROY : +port_flow_table_destroy (in->port, + in->args.table_destroy.table_id_n, + in->args.table_destroy.table_id); +break ;case INDIRECT_ACTION_CREATE : port_action_handle_create( in->port, in->args.vc.attr.group,
app/test-pmd/config.c +170 -0
182 lines not on this page · raw message
app/test-pmd/testpmd.h +17 -0
@@ -177,6 +177,16 @@ struct port_template { } template;/**< PMD opaque template object */ }; +/** Descriptor for a flow table. */ +struct port_table { +struct port_table *next;/**< Next table in list. */ +struct port_table *tmp;/**< Temporary linking. */ +uint32_t id;/**< Table ID. */ +uint32_t nb_pattern_templates;/**< Number of pattern templates. */ +uint32_t nb_actions_templates;/**< Number of actions templates. */ +struct rte_flow_table *table;/**< PMD opaque template object */ +}; +/** Descriptor for a single flow. */ struct port_flow {struct port_flow *next;/**< Next flow in list. */
@@ -259,6 +269,7 @@ struct rte_port {uint8_t slave_flag;/**< bonding slave port */ struct port_template *pattern_templ_list;/**< Pattern templates. */ struct port_template *actions_templ_list;/**< Actions templates. */ +struct port_table *table_list;/**< Flow tables. */ struct port_flow *flow_list;/**< Associated flows. */ struct port_indirect_action *actions_list;/**< Associated indirect actions. */
@@ -915,6 +926,12 @@ int port_flow_actions_template_create(portid_t port_id, uint32_t id, const struct rte_flow_action *masks);int port_flow_actions_template_destroy (portid_t port_id,uint32_t n,const uint32_t *template); +int port_flow_table_create (portid_t port_id,uint32_t id, +const struct rte_flow_table_attr *table_attr, +uint32_t nb_pattern_templates,uint32_t *pattern_templates, +uint32_t nb_actions_templates,uint32_t *actions_templates); +int port_flow_table_destroy (portid_t port_id, +uint32_t n,const uint32_t *table); int port_flow_validate(portid_t port_id, const struct rte_flow_attr *attr, const struct rte_flow_item *pattern,
doc/guides/testpmd_app_ug/testpmd_funcs.rst +53 -0
65 lines not on this page · raw message
Signature · 1 line
2.18.2
RE: [PATCH v3 06/10] app/testpmd: implement rte flow table management
Hi Alexander,
Quoted 13 lines
-----Original Message-----
From: Alexander Kozyrev <[email protected]>
Sent: Sunday, February 6, 2022 5:25 AM
Subject: [PATCH v3 06/10] app/testpmd: implement rte flow table managementAdd testpmd support for the
rte_flow_tableAPI. Provide the command line interface for the flow table creation/destruction. Usage example:
testpmd> flow table 0 createtable_id6
group 9 priority 4 ingress mode 1rules_number64pattern_template2actions_template4
testpmd> flow table 0 destroy table 6
Quoted 2 lines
Signed-off-by Alexander Kozyrev <[email protected]>---
Best,
Ori
PATCH v3 7/10 app/testpmd: implement rte flow queue flow operations
In reply to Alexander KozyrevAdd testpmd support for the rte_flow_q_create/rte_flow_q_destroy API. Provide the command line interface for enqueueing flow creation/destruction operations. Usage example:
testpmd> flow queue 0 create 0 postpone no table 6
pattern_template 0 actions_template 0
pattern eth dst is 00:16:3e:31:15:c3 / end actions drop / end
testpmd> flow queue 0 destroy 0 postpone yes rule 0
--- app/test-pmd/cmdline_flow.c | 266 +++++++++++++++++++- app/test-pmd/config.c | 166 ++++++++++++ app/test-pmd/testpmd.h | 7 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 55 ++++ 4 files changed, 493 insertions(+), 1 deletion(-)
app/test-pmd/cmdline_flow.c +265 -1
@@ -59,6 +59,7 @@ enum index {COMMON_PATTERN_TEMPLATE_ID ,COMMON_ACTIONS_TEMPLATE_ID ,COMMON_TABLE_ID , +COMMON_QUEUE_ID ,/* TOP-level command. */ ADD,
@@ -92,6 +93,7 @@ enum index {ISOLATE ,TUNNEL ,FLEX , +QUEUE ,/* Flex arguments */ FLEX_ITEM_INIT,
@@ -114,6 +116,22 @@ enum index {ACTIONS_TEMPLATE_SPEC ,ACTIONS_TEMPLATE_MASK , +/* Queue arguments. */ +QUEUE_CREATE , +QUEUE_DESTROY , + +/* Queue create arguments. */ +QUEUE_CREATE_ID , +QUEUE_CREATE_POSTPONE , +QUEUE_TABLE , +QUEUE_PATTERN_TEMPLATE , +QUEUE_ACTIONS_TEMPLATE , +QUEUE_SPEC , + +/* Queue destroy arguments. */ +QUEUE_DESTROY_ID , +QUEUE_DESTROY_POSTPONE , +/* Table arguments. */ TABLE_CREATE , TABLE_DESTROY,
@@ -890,6 +908,8 @@ struct token { struct buffer { enum index command; /**< Flow command. */ portid_t port; /**< Affected port ID. */ + queueid_t queue; /** Async queue ID. */ + bool postpone; /** Postpone async operation */ union { struct { struct rte_flow_port_attr port_attr;
@@ -920,6 +940,7 @@ struct buffer {uint32_t action_id; } ia;/* Indirect action query arguments */ struct { +uint32_t table_id;uint32_t pat_templ_id;uint32_t act_templ_id;struct rte_flow_attr attr;
@@ -1069,6 +1090,18 @@ static const enum index next_table_destroy_attr[] = { ZERO, }; +static const enum index next_queue_subcmd[] = { +QUEUE_CREATE , +QUEUE_DESTROY , +ZERO , +}; + +static const enum index next_queue_destroy_attr[] = { +QUEUE_DESTROY_ID , +END , +ZERO , +}; +static const enum index next_ia_create_attr[] = {INDIRECT_ACTION_CREATE_ID ,INDIRECT_ACTION_INGRESS ,
@@ -2118,6 +2151,12 @@ static int parse_table(struct context *, const struct token *,static int parse_table_destroy (struct context *,const struct token *,const char *,unsigned int ,void *,unsigned int ); +static int parse_qo (struct context *,const struct token *, +const char *,unsigned int , +void *,unsigned int ); +static int parse_qo_destroy (struct context *,const struct token *, +const char *,unsigned int , +void *,unsigned int );static int parse_tunnel (struct context *,const struct token *,const char *,unsigned int ,void *,unsigned int );
@@ -2193,6 +2232,8 @@ static int comp_actions_template_id(struct context *, const struct token *, unsigned int, char *, unsigned int);static int comp_table_id (struct context *,const struct token *,unsigned int ,char *,unsigned int ); +static int comp_queue_id (struct context *,const struct token *, +unsigned int ,char *,unsigned int );/** Token definitions. */ static const struct token token_list[] = {
@@ -2364,6 +2405,13 @@ static const struct token token_list[] = { .call = parse_int, .comp = comp_table_id, }, + [COMMON_QUEUE_ID] = { + .name = "{queue_id}", + .type = "QUEUE_ID", + .help = "queue id", + .call = parse_int, + .comp = comp_queue_id, + },/* Top-level command. */ [FLOW] = { .name = "flow",
@@ -2386,7 +2434,8 @@ static const struct token token_list[] = { QUERY,ISOLATE ,TUNNEL , - FLEX)), +FLEX , + QUEUE)), .call = parse_init, },/* Top-level command. */
@@ -2653,6 +2702,83 @@ static const struct token token_list[] = { .call = parse_table, },/* Top-level command. */ + [QUEUE] = { + .name = "queue", + .help = "queue a flow rule operation", + .next = NEXT(next_queue_subcmd, NEXT_ENTRY(COMMON_PORT_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, port)), + .call = parse_qo, + }, +/* Sub-level commands. */ + [QUEUE_CREATE] = { + .name = "create", + .help = "create a flow rule", + .next = NEXT(NEXT_ENTRY(QUEUE_TABLE), NEXT_ENTRY(COMMON_QUEUE_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, queue)), + .call = parse_qo, + }, + [QUEUE_DESTROY] = { + .name = "destroy", + .help = "destroy a flow rule", + .next =NEXT (NEXT_ENTRY (QUEUE_DESTROY_ID ), + NEXT_ENTRY(COMMON_QUEUE_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, queue)), + .call = parse_qo_destroy, + }, +/* Queue arguments. */ + [QUEUE_TABLE] = { + .name = "table", + .help = "specify table id", + .next =NEXT (NEXT_ENTRY (QUEUE_PATTERN_TEMPLATE ), + NEXT_ENTRY(COMMON_TABLE_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, + args.vc.table_id)), + .call = parse_qo, + }, + [QUEUE_PATTERN_TEMPLATE] = { + .name = "pattern_template", + .help = "specify pattern template index", + .next =NEXT (NEXT_ENTRY (QUEUE_ACTIONS_TEMPLATE ), + NEXT_ENTRY(COMMON_UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct buffer, + args.vc.pat_templ_id)), + .call = parse_qo, + }, + [QUEUE_ACTIONS_TEMPLATE] = { + .name = "actions_template", + .help = "specify actions template index", + .next =NEXT (NEXT_ENTRY (QUEUE_CREATE_POSTPONE ), + NEXT_ENTRY(COMMON_UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct buffer, + args.vc.act_templ_id)), + .call = parse_qo, + }, + [QUEUE_CREATE_POSTPONE] = { + .name = "postpone", + .help = "postpone create operation", + .next =NEXT (NEXT_ENTRY (ITEM_PATTERN ), + NEXT_ENTRY(COMMON_BOOLEAN)), + .args = ARGS(ARGS_ENTRY(struct buffer, postpone)), + .call = parse_qo, + }, + [QUEUE_DESTROY_POSTPONE] = { + .name = "postpone", + .help = "postpone destroy operation", + .next =NEXT (NEXT_ENTRY (QUEUE_DESTROY_ID ), + NEXT_ENTRY(COMMON_BOOLEAN)), + .args = ARGS(ARGS_ENTRY(struct buffer, postpone)), + .call = parse_qo_destroy, + }, + [QUEUE_DESTROY_ID] = { + .name = "rule", + .help = "specify rule id to destroy", + .next =NEXT (next_queue_destroy_attr, + NEXT_ENTRY(COMMON_UNSIGNED)), + .args = ARGS(ARGS_ENTRY_PTR(struct buffer, + args.destroy.rule)), + .call = parse_qo_destroy, + }, +/* Top-level command. */ [INDIRECT_ACTION] = { .name = "indirect_action", .type = "{command} {port_id} [{arg} [...]]",
@@ -8166,6 +8292,111 @@ parse_table_destroy(struct context *ctx, const struct token *token,return len; } +/** Parse tokens for queue create commands. */ +static int +parse_qo (struct context *ctx,const struct token *token, +const char *str,unsigned int len, +void *buf,unsigned int size) +{ +struct buffer *out = buf; + +/* Token name must match. */ +if (parse_default (ctx, token, str, len,NULL ,0 ) <0 ) +return -1 ; +/* Nothing else to do if there is no buffer. */ +if (!out) +return len; +if (!out->command) { +if (ctx->curr !=QUEUE ) +return -1 ; +if (sizeof (*out) > size) +return -1 ; + out->command = ctx->curr; + ctx->objdata =0 ; + ctx->object = out; + ctx->objmask =NULL ; + out->args.vc.data = (uint8_t *)out + size; +return len; + } +switch (ctx->curr) { +case QUEUE_CREATE : + out->command = ctx->curr; + ctx->objdata =0 ; + ctx->object = out; + ctx->objmask =NULL ; +return len; +case QUEUE_TABLE : +case QUEUE_PATTERN_TEMPLATE : +case QUEUE_ACTIONS_TEMPLATE : +case QUEUE_CREATE_POSTPONE : +return len; +case ITEM_PATTERN : + out->args.vc.pattern = + (void *)RTE_ALIGN_CEIL ((uintptr_t )(out +1 ), +sizeof (double )); + ctx->object = out->args.vc.pattern; + ctx->objmask =NULL ; +return len; +case ACTIONS : + out->args.vc.actions = + (void *)RTE_ALIGN_CEIL ((uintptr_t ) + (out->args.vc.pattern + + out->args.vc.pattern_n), +sizeof (double )); + ctx->object = out->args.vc.actions; + ctx->objmask =NULL ; +return len; +default : +return -1 ; + } +} + +/** Parse tokens for queue destroy command. */ +static int +parse_qo_destroy (struct context *ctx,const struct token *token, +const char *str,unsigned int len, +void *buf,unsigned int size) +{ +struct buffer *out = buf; +uint32_t *flow_id; + +/* Token name must match. */ +if (parse_default (ctx, token, str, len,NULL ,0 ) <0 ) +return -1 ; +/* Nothing else to do if there is no buffer. */ +if (!out) +return len; +if (!out->command || out->command ==QUEUE ) { +if (ctx->curr !=QUEUE_DESTROY ) +return -1 ; +if (sizeof (*out) > size) +return -1 ; + out->command = ctx->curr; + ctx->objdata =0 ; + ctx->object = out; + ctx->objmask =NULL ; + out->args.destroy.rule = + (void *)RTE_ALIGN_CEIL ((uintptr_t )(out +1 ), +sizeof (double )); +return len; + } +switch (ctx->curr) { +case QUEUE_DESTROY_ID : + flow_id = out->args.destroy.rule + + out->args.destroy.rule_n++; +if ((uint8_t *)flow_id > (uint8_t *)out + size) +return -1 ; + ctx->objdata =0 ; + ctx->object = flow_id; + ctx->objmask =NULL ; +return len; +case QUEUE_DESTROY_POSTPONE : +return len; +default : +return -1 ; + } +} + static int parse_flex(struct context *ctx, const struct token *token, const char *str, unsigned int len,
@@ -9207,6 +9438,28 @@ comp_table_id(struct context *ctx, const struct token *token,return i; } +/** Complete available queue IDs. */ +static int +comp_queue_id (struct context *ctx,const struct token *token, +unsigned int ent,char *buf,unsigned int size) +{ +unsigned int i =0 ; +struct rte_port *port; + + (void )token; +if (port_id_is_invalid (ctx->port,DISABLED_WARN ) || + ctx->port == (portid_t )RTE_PORT_ALL ) +return -1 ; + port = &ports[ctx->port]; +for (i =0 ; i < port->queue_nb; i++) { +if (buf && i == ent) +return snprintf (buf, size,"%u" , i); + } +if (buf) +return -1 ; +return i; +} +/** Internal context. */ static struct context cmd_flow_context;
@@ -9504,6 +9757,17 @@ cmd_flow_parsed(const struct buffer *in) in->args.table_destroy.table_id_n, in->args.table_destroy.table_id);break ; +case QUEUE_CREATE : +port_queue_flow_create (in->port, in->queue, in->postpone, + in->args.vc.table_id, in->args.vc.pat_templ_id, + in->args.vc.act_templ_id, in->args.vc.pattern, + in->args.vc.actions); +break ; +case QUEUE_DESTROY : +port_queue_flow_destroy (in->port, in->queue, in->postpone, + in->args.destroy.rule_n, + in->args.destroy.rule); +break ;case INDIRECT_ACTION_CREATE : port_action_handle_create( in->port, in->args.vc.attr.group,
app/test-pmd/config.c +166 -0
172 lines not on this page · raw message
app/test-pmd/testpmd.h +7 -0
@@ -932,6 +932,13 @@ int port_flow_table_create(portid_t port_id, uint32_t id, uint32_t nb_actions_templates, uint32_t *actions_templates);int port_flow_table_destroy (portid_t port_id,uint32_t n,const uint32_t *table); +int port_queue_flow_create (portid_t port_id,queueid_t queue_id, +bool postpone,uint32_t table_id, +uint32_t pattern_idx,uint32_t actions_idx, +const struct rte_flow_item *pattern, +const struct rte_flow_action *actions); +int port_queue_flow_destroy (portid_t port_id,queueid_t queue_id, +bool postpone,uint32_t n,const uint32_t *rule); int port_flow_validate(portid_t port_id, const struct rte_flow_attr *attr, const struct rte_flow_item *pattern,
doc/guides/testpmd_app_ug/testpmd_funcs.rst +55 -0
73 lines not on this page · raw message
Signature · 1 line
2.18.2
RE: [PATCH v3 07/10] app/testpmd: implement rte flow queue flow operations
Hi Alexander,
Quoted 13 lines
-----Original Message-----
From: Alexander Kozyrev <[email protected]>
Sent: Sunday, February 6, 2022 5:25 AM
Subject: [PATCH v3 07/10] app/testpmd: implement rte flow queue flow operationsAdd testpmd support for the rte_flow_q_create/rte_flow_q_destroy API. Provide the command line interface for enqueueing flow creation/destruction operations. Usage example:
testpmd> flow queue 0 create 0 postpone no table 6
pattern_template0actions_template0
pattern eth dst is 00:16:3e:31:15:c3 / end actions drop / end
testpmd> flow queue 0 destroy 0 postpone yes rule 0
Quoted 2 lines
Signed-off-by Alexander Kozyrev <[email protected]>---
Best,
Ori
PATCH v3 8/10 app/testpmd: implement rte flow push operations
In reply to Alexander KozyrevAdd testpmd support for the rte_flow_q_push API. Provide the command line interface for pushing operations. Usage example: flow queue 0 push 0
--- app/test-pmd/cmdline_flow.c | 56 ++++++++++++++++++++- app/test-pmd/config.c | 28 +++++++++++ app/test-pmd/testpmd.h | 1 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 21 ++++++++ 4 files changed, 105 insertions(+), 1 deletion(-)
app/test-pmd/cmdline_flow.c +55 -1
@@ -94,6 +94,7 @@ enum index {TUNNEL ,FLEX ,QUEUE , +PUSH ,/* Flex arguments */ FLEX_ITEM_INIT,
@@ -132,6 +133,9 @@ enum index {QUEUE_DESTROY_ID ,QUEUE_DESTROY_POSTPONE , +/* Push arguments. */ +PUSH_QUEUE , +/* Table arguments. */ TABLE_CREATE , TABLE_DESTROY,
@@ -2157,6 +2161,9 @@ static int parse_qo(struct context *, const struct token *,static int parse_qo_destroy (struct context *,const struct token *,const char *,unsigned int ,void *,unsigned int ); +static int parse_push (struct context *,const struct token *, +const char *,unsigned int , +void *,unsigned int );static int parse_tunnel (struct context *,const struct token *,const char *,unsigned int ,void *,unsigned int );
@@ -2435,7 +2442,8 @@ static const struct token token_list[] = { ISOLATE,TUNNEL ,FLEX , - QUEUE)), +QUEUE , + PUSH)), .call = parse_init, },/* Top-level command. */
@@ -2779,6 +2787,21 @@ static const struct token token_list[] = { .call = parse_qo_destroy, },/* Top-level command. */ + [PUSH] = { + .name = "push", + .help = "push enqueued operations", + .next = NEXT(NEXT_ENTRY(PUSH_QUEUE), NEXT_ENTRY(COMMON_PORT_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, port)), + .call = parse_push, + }, +/* Sub-level commands. */ + [PUSH_QUEUE] = { + .name = "queue", + .help = "specify queue id", + .next = NEXT(NEXT_ENTRY(END), NEXT_ENTRY(COMMON_QUEUE_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, queue)), + }, +/* Top-level command. */ [INDIRECT_ACTION] = { .name = "indirect_action", .type = "{command} {port_id} [{arg} [...]]",
@@ -8397,6 +8420,34 @@ parse_qo_destroy(struct context *ctx, const struct token *token, } } +/** Parse tokens for push queue command. */ +static int +parse_push (struct context *ctx,const struct token *token, +const char *str,unsigned int len, +void *buf,unsigned int size) +{ +struct buffer *out = buf; + +/* Token name must match. */ +if (parse_default (ctx, token, str, len,NULL ,0 ) <0 ) +return -1 ; +/* Nothing else to do if there is no buffer. */ +if (!out) +return len; +if (!out->command) { +if (ctx->curr !=PUSH ) +return -1 ; +if (sizeof (*out) > size) +return -1 ; + out->command = ctx->curr; + ctx->objdata =0 ; + ctx->object = out; + ctx->objmask =NULL ; + out->args.vc.data = (uint8_t *)out + size; + } +return len; +} + static int parse_flex(struct context *ctx, const struct token *token, const char *str, unsigned int len,
@@ -9768,6 +9819,9 @@ cmd_flow_parsed(const struct buffer *in) in->args.destroy.rule_n, in->args.destroy.rule);break ; +case PUSH : +port_queue_flow_push (in->port, in->queue); +break ;case INDIRECT_ACTION_CREATE : port_action_handle_create( in->port, in->args.vc.attr.group,
app/test-pmd/config.c +28 -0
@@ -2603,6 +2603,34 @@ port_queue_flow_destroy(portid_t port_id, queueid_t queue_id,return ret; } +/** Push all the queue operations in the queue to the NIC. */ +int +port_queue_flow_push (portid_t port_id,queueid_t queue_id) +{ +struct rte_port *port; +struct rte_flow_error error; +int ret =0 ; + +if (port_id_is_invalid (port_id,ENABLED_WARN ) || + port_id == (portid_t )RTE_PORT_ALL ) +return -EINVAL ; + port = &ports[port_id]; + +if (queue_id >= port->queue_nb) { +printf ("Queue #%u is invalid\n" , queue_id); +return -EINVAL ; + } + +memset (&error,0x55 ,sizeof (error)); + ret =rte_flow_q_push (port_id, queue_id, &error); +if (ret <0 ) { +printf ("Failed to push operations in the queue\n" ); +return -EINVAL ; + } +printf ("Queue #%u operations pushed\n" , queue_id); +return ret; +} +/** Create flow rule. */ int port_flow_create(portid_t port_id,
app/test-pmd/testpmd.h +1 -0
@@ -939,6 +939,7 @@ int port_queue_flow_create(portid_t port_id, queueid_t queue_id, const struct rte_flow_action *actions);int port_queue_flow_destroy (portid_t port_id,queueid_t queue_id,bool postpone,uint32_t n,const uint32_t *rule); +int port_queue_flow_push (portid_t port_id,queueid_t queue_id); int port_flow_validate(portid_t port_id, const struct rte_flow_attr *attr, const struct rte_flow_item *pattern,
doc/guides/testpmd_app_ug/testpmd_funcs.rst +21 -0
@@ -3372,6 +3372,10 @@ following sections. flow queue {port_id} destroy {queue_id} [postpone {boolean}] rule {rule_id} [...] +- Push enqueued operations:: + + flow push {port_id} queue {queue_id} + - Create a flow rule:: flow create {port_id}
@@ -3586,6 +3590,23 @@ The usual error message is shown when a table cannot be destroyed:: Caught error type [...] ([...]): [...] +Pushing enqueued operations +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +``flow push`` pushes all the outstanding enqueued operations +to the underlying device immediately. +It is bound to ``rte_flow_q_push()``:: + + flow push {port_id} queue {queue_id} + +If successful, it will show:: + + Queue #[...] operations pushed + +The usual error message is shown when operations cannot be pushed:: + + Caught error type [...] ([...]): [...] + Creating a tunnel stub for offload ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Signature · 1 line
2.18.2
RE: [PATCH v3 08/10] app/testpmd: implement rte flow push operations
Hi Alexander,
Quoted 11 lines
-----Original Message-----
From: Alexander Kozyrev <[email protected]>
Sent: Sunday, February 6, 2022 5:25 AM
Subject: [PATCH v3 08/10] app/testpmd: implement rte flow push operationsAdd testpmd support for the
rte_flow_q_pushAPI. Provide the command line interface for pushing operations. Usage example: flow queue 0 push 0Signed-off-by Alexander Kozyrev <[email protected]>---
Best,
Ori
PATCH v3 9/10 app/testpmd: implement rte flow pull operations
In reply to Alexander KozyrevAdd testpmd support for the rte_flow_q_pull API. Provide the command line interface for pulling operations results. Usage example: flow pull 0 queue 0
--- app/test-pmd/cmdline_flow.c | 56 +++++++++++++++- app/test-pmd/config.c | 74 +++++++++++++-------- app/test-pmd/testpmd.h | 1 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 25 +++++++ 4 files changed, 127 insertions(+), 29 deletions(-)
app/test-pmd/cmdline_flow.c +55 -1
@@ -95,6 +95,7 @@ enum index {FLEX ,QUEUE ,PUSH , +PULL ,/* Flex arguments */ FLEX_ITEM_INIT,
@@ -136,6 +137,9 @@ enum index {/* Push arguments. */ PUSH_QUEUE , +/* Pull arguments. */ +PULL_QUEUE , +/* Table arguments. */ TABLE_CREATE , TABLE_DESTROY,
@@ -2164,6 +2168,9 @@ static int parse_qo_destroy(struct context *, const struct token *,static int parse_push (struct context *,const struct token *,const char *,unsigned int ,void *,unsigned int ); +static int parse_pull (struct context *,const struct token *, +const char *,unsigned int , +void *,unsigned int );static int parse_tunnel (struct context *,const struct token *,const char *,unsigned int ,void *,unsigned int );
@@ -2443,7 +2450,8 @@ static const struct token token_list[] = { TUNNEL,FLEX ,QUEUE , - PUSH)), +PUSH , + PULL)), .call = parse_init, },/* Top-level command. */
@@ -2802,6 +2810,21 @@ static const struct token token_list[] = { .args = ARGS(ARGS_ENTRY(struct buffer, queue)), },/* Top-level command. */ + [PULL] = { + .name = "pull", + .help = "pull flow operations results", + .next = NEXT(NEXT_ENTRY(PULL_QUEUE), NEXT_ENTRY(COMMON_PORT_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, port)), + .call = parse_pull, + }, +/* Sub-level commands. */ + [PULL_QUEUE] = { + .name = "queue", + .help = "specify queue id", + .next = NEXT(NEXT_ENTRY(END), NEXT_ENTRY(COMMON_QUEUE_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, queue)), + }, +/* Top-level command. */ [INDIRECT_ACTION] = { .name = "indirect_action", .type = "{command} {port_id} [{arg} [...]]",
@@ -8448,6 +8471,34 @@ parse_push(struct context *ctx, const struct token *token,return len; } +/** Parse tokens for pull command. */ +static int +parse_pull (struct context *ctx,const struct token *token, +const char *str,unsigned int len, +void *buf,unsigned int size) +{ +struct buffer *out = buf; + +/* Token name must match. */ +if (parse_default (ctx, token, str, len,NULL ,0 ) <0 ) +return -1 ; +/* Nothing else to do if there is no buffer. */ +if (!out) +return len; +if (!out->command) { +if (ctx->curr !=PULL ) +return -1 ; +if (sizeof (*out) > size) +return -1 ; + out->command = ctx->curr; + ctx->objdata =0 ; + ctx->object = out; + ctx->objmask =NULL ; + out->args.vc.data = (uint8_t *)out + size; + } +return len; +} + static int parse_flex(struct context *ctx, const struct token *token, const char *str, unsigned int len,
@@ -9822,6 +9873,9 @@ cmd_flow_parsed(const struct buffer *in)case PUSH :port_queue_flow_push (in->port, in->queue);break ; +case PULL : +port_queue_flow_pull (in->port, in->queue); +break ;case INDIRECT_ACTION_CREATE : port_action_handle_create( in->port, in->args.vc.attr.group,
app/test-pmd/config.c +46 -28
110 lines not on this page · raw message
app/test-pmd/testpmd.h +1 -0
@@ -940,6 +940,7 @@ int port_queue_flow_create(portid_t port_id, queueid_t queue_id,int port_queue_flow_destroy (portid_t port_id,queueid_t queue_id,bool postpone,uint32_t n,const uint32_t *rule);int port_queue_flow_push (portid_t port_id,queueid_t queue_id); +int port_queue_flow_pull (portid_t port_id,queueid_t queue_id); int port_flow_validate(portid_t port_id, const struct rte_flow_attr *attr, const struct rte_flow_item *pattern,
doc/guides/testpmd_app_ug/testpmd_funcs.rst +25 -0
@@ -3376,6 +3376,10 @@ following sections. flow push {port_id} queue {queue_id} +- Pull all operations results from a queue:: + + flow pull {port_id} queue {queue_id} + - Create a flow rule:: flow create {port_id}
@@ -3607,6 +3611,23 @@ The usual error message is shown when operations cannot be pushed:: Caught error type [...] ([...]): [...] +Pulling flow operations results +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +``flow pull`` asks the underlying device about flow queue operations +results and return all the processed (successfully or not) operations. +It is bound to ``rte_flow_q_pull()``:: + + flow pull {port_id} queue {queue_id} + +If successful, it will show:: + + Queue #[...] pulled #[...] operations (#[...] failed, #[...] succeeded) + +The usual error message is shown when operations results cannot be pulled:: + + Caught error type [...] ([...]): [...] + Creating a tunnel stub for offload ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -3736,6 +3757,8 @@ Otherwise it will show an error message of the form:: This command uses the same pattern items and actions as ``flow create``, their format is described in `Creating flow rules`_. +``flow queue pull`` must be called to retrieve the operation status. + Attributes ^^^^^^^^^^
@@ -4469,6 +4492,8 @@ message is shown when a rule cannot be destroyed:: Caught error type [...] ([...]): [...] +``flow queue pull`` must be called to retrieve the operation status. + Querying flow rules ~~~~~~~~~~~~~~~~~~~
Signature · 1 line
2.18.2