Skip to contentSkip to conversation

ethdev: sharing indirect actions between ports

RFC In review Viacheslav Ovsiienko 6 participants 46 messages Dec 28, 2022 – Feb 15, 2023 Network drivers

lore
Share & tools
lore
#0 lore raw

RFC 1/1 ethdev: sharing indirect actions between ports

The RTE Flow API implements the concept of shared objects, known as indirect actions (RTE_FLOW_ACTION_TYPE_INDIRECT). An application can create the indirect action of desired type and configuration with rte_flow_action_handle_create call and then specify the obtained action handle in multiple flows.

The initial concept supposes the action handle has strict attachment to the port it was created on and to be used exclusively in the flows being installed on the port.

Nowadays the multipath network topologies are quite common, packets belonging to the same connection might arrive and be sent over multiple ports, and there is the raising demand to handle these "spread" connections. To fulfil this demand it is proposed to extend indirect action sharing across the multiple ports. This kind of sharing would be extremely useful for the meters and counters, allowing to manage the single connection over the multiple ports.

This cross-port object sharing is hard to implement in generic way merely with software on the upper layers, but can be provided by the driver over the single hardware instance, where multiple ports reside on the same physical NIC and share the same hardware context.

To allow this action sharing application should specify the "host port" during flow configuring to claim the intention to share the indirect actions. All indirect actions reside within "host port" context and can be shared in flows being installed on the host port and on all the ports referencing this one.

If sharing between host and port being configured is not supported the configuration should be rejected with error. There might be multiple independent (mutual exclusive) sharing domains with dedicated host and referencing ports.

To manage the shared indirect action any port from sharing domain can be specified. To share or not the created action is up to application, no API change is needed.

---
 lib/ethdev/rte_flow.c |  6 ++++++
 lib/ethdev/rte_flow.h | 11 +++++++++++
 2 files changed, 17 insertions(+)
lib/ethdev/rte_flow.c +6 -0
index 7d0c24366c..692d37925a 100644
@@ -1476,6 +1476,12 @@ rte_flow_configure(uint16_t port_id,
 		RTE_FLOW_LOG(ERR, "Port %"PRIu16" queue info is NULL.\n", port_id);
 		return -EINVAL;
 	}
+	if ((port_attr->flags & RTE_FLOW_PORT_FLAG_SHARE_INDIRECT) &&
+	     !rte_eth_dev_is_valid_port(port_attr->host_port_id)) {
+		return rte_flow_error_set(error, ENODEV,
+					  RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
+					  NULL, rte_strerror(ENODEV));
+	}
 	if (likely(!!ops->configure)) {
 		ret = ops->configure(dev, port_attr, nb_queue, queue_attr, error);
 		if (ret == 0)
lib/ethdev/rte_flow.h +11 -0
index b60987db4b..c784f4ec30 100644
@@ -4903,6 +4903,13 @@ rte_flow_info_get(uint16_t port_id,
 		  struct rte_flow_queue_info *queue_info,
 		  struct rte_flow_error *error);
 
+/**
+ * Indicate all steering objects should be created on contexts
+ * of the host port, providing indirect object sharing beetween
+ * ports.
+ */
+#define RTE_FLOW_PORT_FLAG_SHARE_INDIRECT RTE_BIT32(0)
+
 /**
  * @warning
  * @b EXPERIMENTAL: this API may change without prior notice.
@@ -4932,6 +4939,10 @@ struct rte_flow_port_attr {
 	 * @see RTE_FLOW_ACTION_TYPE_CONNTRACK
 	 */
 	uint32_t nb_conn_tracks;
+	/**
+	 * Port to base shared objects on.
+	 */
+	uint16_t host_port_id;
 	/**
 	 * Port flags (RTE_FLOW_PORT_FLAG_*).
 	 */
Signature · 1 line
2.18.1
#1 lore raw

Hi Slava,

Looks good to me,
Best,
Ori

Quoted 102 lines

-----Original Message-----
From: Slava Ovsiienko <[email protected]>
Sent: Wednesday, 28 December 2022 18:55

The RTE Flow API implements the concept of shared objects, known as indirect actions (RTE_FLOW_ACTION_TYPE_INDIRECT). An application can create the indirect action of desired type and configuration with rte_flow_action_handle_create call and then specify the obtained action handle in multiple flows.

The initial concept supposes the action handle has strict attachment to the port it was created on and to be used exclusively in the flows being installed on the port.

Nowadays the multipath network topologies are quite common, packets belonging to the same connection might arrive and be sent over multiple ports, and there is the raising demand to handle these "spread" connections. To fulfil this demand it is proposed to extend indirect action sharing across the multiple ports. This kind of sharing would be extremely useful for the meters and counters, allowing to manage the single connection over the multiple ports.

This cross-port object sharing is hard to implement in generic way merely with software on the upper layers, but can be provided by the driver over the single hardware instance, where multiple ports reside on the same physical NIC and share the same hardware context.

To allow this action sharing application should specify the "host port" during flow configuring to claim the intention to share the indirect actions. All indirect actions reside within "host port" context and can be shared in flows being installed on the host port and on all the ports referencing this one.

If sharing between host and port being configured is not supported the configuration should be rejected with error. There might be multiple independent (mutual exclusive) sharing domains with dedicated host and referencing ports.

To manage the shared indirect action any port from sharing domain can be specified. To share or not the created action is up to application, no API change is needed.

---
 lib/ethdev/rte_flow.c |  6 ++++++
 lib/ethdev/rte_flow.h | 11 +++++++++++
 2 files changed, 17 insertions(+)
lib/ethdev/rte_flow.c +6 -0
index 7d0c24366c..692d37925a 100644
@@ -1476,6 +1476,12 @@ rte_flow_configure(uint16_t port_id,
 		RTE_FLOW_LOG(ERR, "Port %"PRIu16" queue info is
 NULL.\n", port_id);
 		return -EINVAL;
 	}
+	if ((port_attr->flags & RTE_FLOW_PORT_FLAG_SHARE_INDIRECT) &&
+	     !rte_eth_dev_is_valid_port(port_attr->host_port_id)) {
+		return rte_flow_error_set(error, ENODEV,
+
 RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
+					  NULL, rte_strerror(ENODEV));
+	}
 	if (likely(!!ops->configure)) {

ret = ops->configure(dev, port_attr, nb_queue, queue_attr,
error);

lib/ethdev/rte_flow.c +0 -0
 		if (ret == 0)
lib/ethdev/rte_flow.h +11 -1
index b60987db4b..c784f4ec30 100644
@@ -4903,6 +4903,13 @@ rte_flow_info_get(uint16_t port_id,
 		  struct rte_flow_queue_info *queue_info,
 		  struct rte_flow_error *error);
 
+/**
+ * Indicate all steering objects should be created on contexts
+ * of the host port, providing indirect object sharing beetween
+ * ports.
+ */
+#define RTE_FLOW_PORT_FLAG_SHARE_INDIRECT RTE_BIT32(0)
+
 /**
  * @warning
  * @b EXPERIMENTAL: this API may change without prior notice.
@@ -4932,6 +4939,10 @@ struct rte_flow_port_attr {
 	 * @see RTE_FLOW_ACTION_TYPE_CONNTRACK
 	 */
 	uint32_t nb_conn_tracks;
+	/**
+	 * Port to base shared objects on.
+	 */
+	uint16_t host_port_id;
 	/**
 	 * Port flags (RTE_FLOW_PORT_FLAG_*).
 	 */
--

2.18.1

#2 lore raw
In reply to Viacheslav Ovsiienko

28/12/2022 17:54, Viacheslav Ovsiienko:

Quoted 26 lines

The RTE Flow API implements the concept of shared objects, known as indirect actions (RTE_FLOW_ACTION_TYPE_INDIRECT). An application can create the indirect action of desired type and configuration with rte_flow_action_handle_create call and then specify the obtained action handle in multiple flows.

The initial concept supposes the action handle has strict attachment to the port it was created on and to be used exclusively in the flows being installed on the port.

Nowadays the multipath network topologies are quite common, packets belonging to the same connection might arrive and be sent over multiple ports, and there is the raising demand to handle these "spread" connections. To fulfil this demand it is proposed to extend indirect action sharing across the multiple ports. This kind of sharing would be extremely useful for the meters and counters, allowing to manage the single connection over the multiple ports.

This cross-port object sharing is hard to implement in generic way merely with software on the upper layers, but can be provided by the driver over the single hardware instance, where multiple ports reside on the same physical NIC and share the same hardware context.

Quoted 4 lines

To allow this action sharing application should specify the "host port" during flow configuring to claim the intention to share the indirect actions. All indirect actions reside within "host port" context and can be shared in flows being installed

I don't like the word "host" because it may refer to the host CPU. Also if I understand well, the application must choose one port between all ports of the NIC and keep using the same.
I guess we don't want to create a NIC id.
So I would suggest to rename to nic_ref_port or something like that.

Quoted 1 line

on the host port and on all the ports referencing this one.

Not "all the ports" but only on sibling ports (ports of the same NIC).

Quoted 8 lines

If sharing between host and port being configured is not supported the configuration should be rejected with error. There might be multiple independent (mutual exclusive) sharing domains with dedicated host and referencing ports.

To manage the shared indirect action any port from sharing domain can be specified. To share or not the created action is up to application, no API change is needed.

[...]

lib/ethdev/rte_flow.h struct rte_flow_port_attr { · line 4945

Quoted 4 lines
lib/ethdev/rte_flow.h +4 -0
+	/**
+	 * Port to base shared objects on.
+	 */
+	uint16_t host_port_id;

Is it a DPDK ethdev port ID?

You should add this feature to the release notes and in rte_flow guide.

PS: please Cc ethdev maintainers.

#3 lore raw

Hi

Quoted 36 lines

-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Wednesday, 18 January 2023 14:07

28/12/2022 17:54, Viacheslav Ovsiienko:

Quoted 26 lines

The RTE Flow API implements the concept of shared objects, known as indirect actions (RTE_FLOW_ACTION_TYPE_INDIRECT). An application can create the indirect action of desired type and configuration with rte_flow_action_handle_create call and then specify the obtained action handle in multiple flows.

The initial concept supposes the action handle has strict attachment to the port it was created on and to be used exclusively in the flows being installed on the port.

Nowadays the multipath network topologies are quite common, packets belonging to the same connection might arrive and be sent over multiple ports, and there is the raising demand to handle these "spread" connections. To fulfil this demand it is proposed to extend indirect action sharing across the multiple ports. This kind of sharing would be extremely useful for the meters and counters, allowing to manage the single connection over the multiple ports.

This cross-port object sharing is hard to implement in generic way merely with software on the upper layers, but can be provided by the driver over the single hardware instance, where multiple ports reside on the same physical NIC and share the same hardware context.

Quoted 4 lines

To allow this action sharing application should specify the "host port" during flow configuring to claim the intention to share the indirect actions. All indirect actions reside within "host port" context and can be shared in flows being installed

Quoted 6 lines

I don't like the word "host" because it may refer to the host CPU. Also if I understand well, the application must choose one port between all ports of the NIC and keep using the same.
I guess we don't want to create a NIC id.
So I would suggest to rename to nic_ref_port or something like that.

I think that host is the correct word since this port hosts all resources for other ports. (this is also why the host is used in case of CPU 😊)
I don't think it is correct to use bad wording due to the fact that some one else also uses this word.
in rte_flow we never talk about host CPU so I don't think this is confusing.

Quoted 24 lines
Quoted 1 line

on the host port and on all the ports referencing this one.

Not "all the ports" but only on sibling ports (ports of the same NIC).

Quoted 8 lines

If sharing between host and port being configured is not supported the configuration should be rejected with error. There might be multiple independent (mutual exclusive) sharing domains with dedicated host and referencing ports.

To manage the shared indirect action any port from sharing domain can be specified. To share or not the created action is up to application, no API change is needed.

[...]

lib/ethdev/rte_flow.h struct rte_flow_port_attr { · line 4945

Quoted 4 lines
lib/ethdev/rte_flow.h +4 -0
+	/**
+	 * Port to base shared objects on.
+	 */
+	uint16_t host_port_id;

Is it a DPDK ethdev port ID?

You should add this feature to the release notes and in rte_flow guide.

PS: please Cc ethdev maintainers.

#4 lore raw

18/01/2023 16:17, Ori Kam:

Quoted 40 lines

From: Thomas Monjalon <[email protected]>

Quoted 32 lines

28/12/2022 17:54, Viacheslav Ovsiienko:

Quoted 26 lines

The RTE Flow API implements the concept of shared objects, known as indirect actions (RTE_FLOW_ACTION_TYPE_INDIRECT). An application can create the indirect action of desired type and configuration with rte_flow_action_handle_create call and then specify the obtained action handle in multiple flows.

The initial concept supposes the action handle has strict attachment to the port it was created on and to be used exclusively in the flows being installed on the port.

Nowadays the multipath network topologies are quite common, packets belonging to the same connection might arrive and be sent over multiple ports, and there is the raising demand to handle these "spread" connections. To fulfil this demand it is proposed to extend indirect action sharing across the multiple ports. This kind of sharing would be extremely useful for the meters and counters, allowing to manage the single connection over the multiple ports.

This cross-port object sharing is hard to implement in generic way merely with software on the upper layers, but can be provided by the driver over the single hardware instance, where multiple ports reside on the same physical NIC and share the same hardware context.

Quoted 4 lines

To allow this action sharing application should specify the "host port" during flow configuring to claim the intention to share the indirect actions. All indirect actions reside within "host port" context and can be shared in flows being installed

Quoted 6 lines

I don't like the word "host" because it may refer to the host CPU. Also if I understand well, the application must choose one port between all ports of the NIC and keep using the same.
I guess we don't want to create a NIC id.
So I would suggest to rename to nic_ref_port or something like that.

Quoted 5 lines

I think that host is the correct word since this port hosts all resources for other ports. (this is also why the host is used in case of CPU 😊)
I don't think it is correct to use bad wording due to the fact that some one else also uses this word.
in rte_flow we never talk about host CPU so I don't think this is confusing.

The confusion is that we can think of a port on the host.

#5 lore raw
Quoted 52 lines

-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Wednesday, January 18, 2023 6:22 PM
To: Slava Ovsiienko <[email protected]>; Ori Kam <[email protected]>
Cc: [email protected]; Matan Azrad <[email protected]>; Raslan Darawsheh <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: Re: [RFC] ethdev: sharing indirect actions between ports

18/01/2023 16:17, Ori Kam:

Quoted 39 lines

From: Thomas Monjalon <[email protected]>

Quoted 37 lines

28/12/2022 17:54, Viacheslav Ovsiienko:

Quoted 25 lines

The RTE Flow API implements the concept of shared objects, known as indirect actions (RTE_FLOW_ACTION_TYPE_INDIRECT).
An application can create the indirect action of desired type and configuration with rte_flow_action_handle_create call and then specify the obtained action handle in multiple flows.

The initial concept supposes the action handle has strict attachment to the port it was created on and to be used exclusively in the flows being installed on the port.

Nowadays the multipath network topologies are quite common, packets belonging to the same connection might arrive and be sent over multiple ports, and there is the raising demand to handle these "spread" connections. To fulfil this demand it is proposed to extend indirect action sharing across the multiple ports. This kind of sharing would be extremely useful for the meters and counters, allowing to manage the single connection over the multiple ports.

This cross-port object sharing is hard to implement in generic way merely with software on the upper layers, but can be provided by the driver over the single hardware instance, where multiple ports reside on the same physical NIC and share the same hardware context.

Quoted 4 lines

To allow this action sharing application should specify the "host port" during flow configuring to claim the intention to share the indirect actions. All indirect actions reside within "host port" context and can be shared in flows being installed

I don't like the word "host" because it may refer to the host CPU. Also if I understand well, the application must choose one port between all ports of the NIC and keep using the same.
I guess we don't want to create a NIC id.
So I would suggest to rename to nic_ref_port or something like that.

Quoted 8 lines
Quoted 6 lines

I think that host is the correct word since this port hosts all resources for other ports. (this is also why the host is used in case of CPU 😊)
I don't think it is correct to use bad wording due to the fact that some one else also uses this word.
in rte_flow we never talk about host CPU so I don't think this is confusing.

The confusion is that we can think of a port on the host.

In my humble opinion, "_port_id" suffix explicitly specifies what field is and does not leave too much space for confusion.

"root_port_id"? "base_port_id"? "container_port_id" ? "mgmnt_port_id" ?
Looks worse as for me and does not reflect the exact meaning.
As Ori mentioned this is DPDK port ID that embraces all the shared actions. It plays a host role for them.

With best regards, Slava

Quoted 2 lines
#6 lore raw
Quoted 61 lines · Slava Ovsiienko
Quoted 52 lines

-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Wednesday, January 18, 2023 6:22 PM
To: Slava Ovsiienko <[email protected]>; Ori Kam <[email protected]>
Cc: [email protected]; Matan Azrad <[email protected]>; Raslan Darawsheh <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: Re: [RFC] ethdev: sharing indirect actions between ports

18/01/2023 16:17, Ori Kam:

Quoted 39 lines

From: Thomas Monjalon <[email protected]>

Quoted 37 lines

28/12/2022 17:54, Viacheslav Ovsiienko:

Quoted 25 lines

The RTE Flow API implements the concept of shared objects, known as indirect actions (RTE_FLOW_ACTION_TYPE_INDIRECT).
An application can create the indirect action of desired type and configuration with rte_flow_action_handle_create call and then specify the obtained action handle in multiple flows.

The initial concept supposes the action handle has strict attachment to the port it was created on and to be used exclusively in the flows being installed on the port.

Nowadays the multipath network topologies are quite common, packets belonging to the same connection might arrive and be sent over multiple ports, and there is the raising demand to handle these "spread" connections. To fulfil this demand it is proposed to extend indirect action sharing across the multiple ports. This kind of sharing would be extremely useful for the meters and counters, allowing to manage the single connection over the multiple ports.

This cross-port object sharing is hard to implement in generic way merely with software on the upper layers, but can be provided by the driver over the single hardware instance, where multiple ports reside on the same physical NIC and share the same hardware context.

Quoted 4 lines

To allow this action sharing application should specify the "host port" during flow configuring to claim the intention to share the indirect actions. All indirect actions reside within "host port" context and can be shared in flows being installed

I don't like the word "host" because it may refer to the host CPU. Also if I understand well, the application must choose one port between all ports of the NIC and keep using the same.
I guess we don't want to create a NIC id.
So I would suggest to rename to nic_ref_port or something like that.

Quoted 8 lines
Quoted 6 lines

I think that host is the correct word since this port hosts all resources for other ports. (this is also why the host is used in case of CPU 😊)
I don't think it is correct to use bad wording due to the fact that some one else also uses this word.
in rte_flow we never talk about host CPU so I don't think this is confusing.

The confusion is that we can think of a port on the host.

Quoted 7 lines

In my humble opinion, "_port_id" suffix explicitly specifies what field is and does not leave too much space for confusion.

"root_port_id"? "base_port_id"? "container_port_id" ? "mgmnt_port_id" ?
Looks worse as for me and does not reflect the exact meaning.
As Ori mentioned this is DPDK port ID that embraces all the shared actions. It plays a host role for them.

Maybe 'owner_port_id' or 'rsrc_port_id' ?

#7 lore raw
Quoted 74 lines

-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Friday, 20 January 2023 14:23

Quoted 8 lines · Slava Ovsiienko
Quoted 8 lines

-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Wednesday, January 18, 2023 6:22 PM
To: Slava Ovsiienko <[email protected]>; Ori Kam <[email protected]>
Cc: [email protected]; Matan Azrad <[email protected]>; Raslan

Darawsheh

Quoted 44 lines
Quoted 44 lines

<[email protected]>; [email protected]; [email protected]; [email protected]
Subject: Re: [RFC] ethdev: sharing indirect actions between ports

18/01/2023 16:17, Ori Kam:

Quoted 39 lines

From: Thomas Monjalon <[email protected]>

Quoted 37 lines

28/12/2022 17:54, Viacheslav Ovsiienko:

Quoted 25 lines

The RTE Flow API implements the concept of shared objects, known as indirect actions (RTE_FLOW_ACTION_TYPE_INDIRECT).
An application can create the indirect action of desired type and configuration with rte_flow_action_handle_create call and then specify the obtained action handle in multiple flows.

The initial concept supposes the action handle has strict attachment to the port it was created on and to be used exclusively in the flows being installed on the port.

Nowadays the multipath network topologies are quite common, packets belonging to the same connection might arrive and be sent over multiple ports, and there is the raising demand to handle these "spread" connections. To fulfil this demand it is proposed to extend indirect action sharing across the multiple ports. This kind of sharing would be extremely useful for the meters and counters, allowing to manage the single connection over the multiple ports.

This cross-port object sharing is hard to implement in generic way merely with software on the upper layers, but can be provided by the driver over the single hardware instance, where multiple ports reside on the same physical NIC and share the same hardware context.

Quoted 4 lines

To allow this action sharing application should specify the "host port" during flow configuring to claim the intention to share the indirect actions. All indirect actions reside within "host port" context and can be shared in flows being installed

I don't like the word "host" because it may refer to the host CPU. Also if I understand well, the application must choose one port between all ports of the NIC and keep using the same.
I guess we don't want to create a NIC id.
So I would suggest to rename to nic_ref_port or something like that.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

I think that host is the correct word since this port hosts all resources for other ports. (this is also why the host is used in case of CPU 😊)
I don't think it is correct to use bad wording due to the fact that some one else also uses this word.
in rte_flow we never talk about host CPU so I don't think this is

confusing.

Quoted 4 lines
Quoted 2 lines

The confusion is that we can think of a port on the host.

In my humble opinion, "_port_id" suffix explicitly specifies what field is and

does not leave

Quoted 2 lines

too much space for confusion.

Quoted 8 lines
Quoted 1 line

"root_port_id"? "base_port_id"? "container_port_id" ? "mgmnt_port_id"

?

Quoted 3 lines

Looks worse as for me and does not reflect the exact meaning.
As Ori mentioned this is DPDK port ID that embraces all the shared actions. It plays a host role for them.

Maybe 'owner_port_id' or 'rsrc_port_id' ?

Rsrc?
Owner_port looks O.K but I'm not sure what is the issue with the original suggestion.

Best,
Ori

#8 lore raw

PATCH 1/9 ethdev: sharing indirect actions between ports

In reply to Viacheslav Ovsiienko

The RTE Flow API implements the concept of shared objects, known as indirect actions (RTE_FLOW_ACTION_TYPE_INDIRECT). An application can create the indirect action of desired type and configuration with rte_flow_action_handle_create call and then specify the obtained action handle in multiple flows.

The initial concept supposes the action handle has strict attachment to the port it was created on and to be used exclusively in the flows being installed on the port.

Nowadays the multipath network topologies are quite common, packets belonging to the same connection might arrive and be sent over multiple ports, and there is the raising demand to handle these "spread" connections. To fulfil this demand it is proposed to extend indirect action sharing across the multiple ports. This kind of sharing would be extremely useful for the meters and counters, allowing to manage the single connection over the multiple ports.

This cross-port object sharing is hard to implement in generic way merely with software on the upper layers, but can be provided by the driver over the single hardware instance, where multiple ports reside on the same physical NIC and share the same hardware context.

To allow this action sharing application should specify the "host port" during flow configuring to claim the intention to share the indirect actions. All indirect actions reside within "host port" context and can be shared in flows being installed on the host port and on all the ports referencing this one.

If sharing between host and port being configured is not supported the configuration should be rejected with error. There might be multiple independent (mutual exclusive) sharing domains with dedicated host and referencing ports.

To manage the shared indirect action any port from sharing domain can be specified. To share or not the created action is up to application, no API change is needed.

---
 lib/ethdev/rte_flow.c |  6 ++++++
 lib/ethdev/rte_flow.h | 11 +++++++++++
 2 files changed, 17 insertions(+)
lib/ethdev/rte_flow.c +6 -0
index 7d0c24366c..692d37925a 100644
@@ -1476,6 +1476,12 @@ rte_flow_configure(uint16_t port_id,
 		RTE_FLOW_LOG(ERR, "Port %"PRIu16" queue info is NULL.\n", port_id);
 		return -EINVAL;
 	}
+	if ((port_attr->flags & RTE_FLOW_PORT_FLAG_SHARE_INDIRECT) &&
+	     !rte_eth_dev_is_valid_port(port_attr->host_port_id)) {
+		return rte_flow_error_set(error, ENODEV,
+					  RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
+					  NULL, rte_strerror(ENODEV));
+	}
 	if (likely(!!ops->configure)) {
 		ret = ops->configure(dev, port_attr, nb_queue, queue_attr, error);
 		if (ret == 0)
lib/ethdev/rte_flow.h +11 -0
index b60987db4b..c784f4ec30 100644
@@ -4903,6 +4903,13 @@ rte_flow_info_get(uint16_t port_id,
 		  struct rte_flow_queue_info *queue_info,
 		  struct rte_flow_error *error);
 
+/**
+ * Indicate all steering objects should be created on contexts
+ * of the host port, providing indirect object sharing beetween
+ * ports.
+ */
+#define RTE_FLOW_PORT_FLAG_SHARE_INDIRECT RTE_BIT32(0)
+
 /**
  * @warning
  * @b EXPERIMENTAL: this API may change without prior notice.
@@ -4932,6 +4939,10 @@ struct rte_flow_port_attr {
 	 * @see RTE_FLOW_ACTION_TYPE_CONNTRACK
 	 */
 	uint32_t nb_conn_tracks;
+	/**
+	 * Port to base shared objects on.
+	 */
+	uint16_t host_port_id;
 	/**
 	 * Port flags (RTE_FLOW_PORT_FLAG_*).
 	 */
Signature · 1 line
2.18.1
#9 lore raw

PATCH 2/9 net/mlx5/hws: Matcher, Free FT from RTC id before set the new value

From: Erez Shitrit <[email protected]>

While matcher is being connect/disconnect in shared gvmi flow we set the first ft in the table to point on the first matcher,
The FW is increasing the refcount on the first matcher RTC because of that no matcher if it is the same RTC that was set before, and when we will try to release that RTC we will get the following syndrome:
0xaa0093 - destroy_rtc_object: rtc in use or doesn't exist.

In order to resolve that we clean the current pointed RTC from that ft and only after that setting it to the new RTC value.

---
 drivers/net/mlx5/hws/mlx5dr_matcher.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
drivers/net/mlx5/hws/mlx5dr_matcher.c +18 -0
index d509a2f0e1..32bf3f5886 100644
@@ -334,6 +334,24 @@ static int mlx5dr_matcher_disconnect(struct mlx5dr_matcher *matcher)
 		return ret;
 	}
 
+	if (!next) {
+		/* ft no longer points to any RTC, drop refcount */
+		ret = mlx5dr_matcher_free_rtc_pointing(tbl->ctx,
+						       tbl->fw_ft_type,
+						       tbl->type,
+						       prev_ft);
+		if (ret) {
+			DR_LOG(ERR, "Failed to reset last RTC refcount");
+			return ret;
+		}
+	}
+
+	ret = mlx5dr_matcher_shared_update_local_ft(tbl);
+	if (ret) {
+		DR_LOG(ERR, "Failed to update local_ft in shared table");
+		return ret;
+	}
+
 	return 0;
 }
 
Signature · 1 line
2.18.1
#10 lore raw

PATCH 3/9 net/mlx5/hws: fix disconnecting matcher

In reply to Viacheslav Ovsiienko

From: Erez Shitrit <[email protected]>

This patch fixes the matcher disconnection handling, by removing the RTC references from flow table if the currently removed matcher was the last one for the given table. As a result RTC in this matcher can be correctly freed, since there are no dangling references to the RTC.

Fixes c467608215b2 ("net/mlx5/hws: add matcher object")
---
 drivers/net/mlx5/hws/mlx5dr_matcher.c | 6 ------
 1 file changed, 6 deletions(-)
drivers/net/mlx5/hws/mlx5dr_matcher.c +0 -6
index 32bf3f5886..a0297c9787 100644
@@ -346,12 +346,6 @@ static int mlx5dr_matcher_disconnect(struct mlx5dr_matcher *matcher)
 		}
 	}
 
-	ret = mlx5dr_matcher_shared_update_local_ft(tbl);
-	if (ret) {
-		DR_LOG(ERR, "Failed to update local_ft in shared table");
-		return ret;
-	}
-
 	return 0;
 }
 
Signature · 1 line
2.18.1
#11 lore raw

PATCH 4/9 common/mlx5: add cross port object sharing capability

In reply to Viacheslav Ovsiienko

Add query port capabilities to share steering objects between multiple ports of the same physical NIC.

---
 drivers/common/mlx5/mlx5_devx_cmds.c | 13 +++++++++++++
 drivers/common/mlx5/mlx5_devx_cmds.h |  1 +
 2 files changed, 14 insertions(+)
drivers/common/mlx5/mlx5_devx_cmds.c +13 -0
index e3a4927d0f..17128035ec 100644
@@ -1047,6 +1047,19 @@ mlx5_devx_cmd_query_hca_attr(void *ctx,
 		attr->flow_counter_bulk_log_granularity =
 			MLX5_GET(cmd_hca_cap_2, hcattr,
 				 flow_counter_bulk_log_granularity);
+		rc = MLX5_GET(cmd_hca_cap_2, hcattr,
+			      cross_vhca_object_to_object_supported);
+		attr->cross_vhca =
+			(rc & MLX5_CROSS_VHCA_OBJ_TO_OBJ_TYPE_STC_TO_TIR) &&
+			(rc & MLX5_CROSS_VHCA_OBJ_TO_OBJ_TYPE_STC_TO_FT) &&
+			(rc & MLX5_CROSS_VHCA_OBJ_TO_OBJ_TYPE_FT_TO_FT) &&
+			(rc & MLX5_CROSS_VHCA_OBJ_TO_OBJ_TYPE_FT_TO_RTC);
+		rc = MLX5_GET(cmd_hca_cap_2, hcattr,
+			      allowed_object_for_other_vhca_access);
+		attr->cross_vhca = attr->cross_vhca &&
+			(rc & MLX5_CROSS_VHCA_ALLOWED_OBJS_TIR) &&
+			(rc & MLX5_CROSS_VHCA_ALLOWED_OBJS_FT) &&
+			(rc & MLX5_CROSS_VHCA_ALLOWED_OBJS_RTC);
 	}
 	if (attr->log_min_stride_wqe_sz == 0)
 		attr->log_min_stride_wqe_sz = MLX5_MPRQ_LOG_MIN_STRIDE_WQE_SIZE;
drivers/common/mlx5/mlx5_devx_cmds.h +1 -0
index c94b9eac06..b65ba569bc 100644
@@ -288,6 +288,7 @@ struct mlx5_hca_attr {
 	uint32_t alloc_flow_counter_pd:1;
 	uint32_t flow_counter_access_aso:1;
 	uint32_t flow_access_aso_opc_mod:8;
+	uint32_t cross_vhca:1;
 };
 
 /* LAG Context. */
Signature · 1 line
2.18.1
#12 lore raw

PATCH 5/9 net/mlx5: add cross port shared mode for HW steering

In reply to Viacheslav Ovsiienko

Add host port option for sharing steering objects between multiple ports of the same physical NIC.

---
 drivers/net/mlx5/mlx5.c         |  6 +++
 drivers/net/mlx5/mlx5.h         |  2 +
 drivers/net/mlx5/mlx5_flow_hw.c | 78 +++++++++++++++++++++++++++++++--
 drivers/net/mlx5/mlx5_hws_cnt.c | 12 +++++
 4 files changed, 94 insertions(+), 4 deletions(-)
drivers/net/mlx5/mlx5.c +6 -0
index b8643cebdd..2eca2cceef 100644
@@ -2013,6 +2013,12 @@ mlx5_dev_close(struct rte_eth_dev *dev)
 	}
 	if (!priv->sh)
 		return 0;
+	if (priv->shared_refcnt) {
+		DRV_LOG(ERR, "port %u is shared host in use (%u)",
+			dev->data->port_id, priv->shared_refcnt);
+		rte_errno = EBUSY;
+		return -EBUSY;
+	}
 	DRV_LOG(DEBUG, "port %u closing device \"%s\"",
 		dev->data->port_id,
 		((priv->sh->cdev->ctx != NULL) ?
drivers/net/mlx5/mlx5.h +2 -0
index 16b33e1548..525bdd47f7 100644
@@ -1780,6 +1780,8 @@ struct mlx5_priv {
 	struct mlx5_flow_hw_ctrl_rx *hw_ctrl_rx;
 	/**< HW steering templates used to create control flow rules. */
 #endif
+	struct rte_eth_dev *shared_host; /* Host device for HW steering. */
+	uint16_t shared_refcnt; /* HW steering host reference counter. */
 };
 
 #define PORT_ID(priv) ((priv)->dev_data->port_id)
drivers/net/mlx5/mlx5_flow_hw.c +74 -4

138 lines not on this page · raw message

drivers/net/mlx5/mlx5_hws_cnt.c +12 -0
index 51704ef754..afc93821e4 100644
@@ -618,6 +618,12 @@ mlx5_hws_cnt_pool_create(struct rte_eth_dev *dev,
 	int ret = 0;
 	size_t sz;
 
+	if (pattr->flags & RTE_FLOW_PORT_FLAG_SHARE_INDIRECT) {
+		DRV_LOG(ERR, "Counters are not supported "
+			     "in cross vHCA sharing mode");
+		rte_errno = ENOTSUP;
+		return NULL;
+	}
 	/* init cnt service if not. */
 	if (priv->sh->cnt_svc == NULL) {
 		ret = mlx5_hws_cnt_svc_init(priv->sh);
@@ -1189,6 +1195,12 @@ mlx5_hws_age_pool_init(struct rte_eth_dev *dev,
 
 	strict_queue = !!(attr->flags & RTE_FLOW_PORT_FLAG_STRICT_QUEUE);
 	MLX5_ASSERT(priv->hws_cpool);
+	if (attr->flags & RTE_FLOW_PORT_FLAG_SHARE_INDIRECT) {
+		DRV_LOG(ERR, "Aging sn not supported "
+			     "in cross vHCA sharing mode");
+		rte_errno = ENOTSUP;
+		return -ENOTSUP;
+	}
 	nb_alloc_cnts = mlx5_hws_cnt_pool_get_size(priv->hws_cpool);
 	if (strict_queue) {
 		rsize = mlx5_hws_aged_out_q_ring_size_get(nb_alloc_cnts,
Signature · 1 line
2.18.1
#13 lore raw

PATCH 6/9 net/mlx5: support counters in cross port shared mode

In reply to Viacheslav Ovsiienko

In the cross vHCA sharing mode the host counter pool should be used in counter related routines. The local port pool is used to store the dedicated DR action handle, per queue counter caches and query data are ignored and not allocated on local pool.

---
 drivers/net/mlx5/mlx5_flow_hw.c |  12 ++-
 drivers/net/mlx5/mlx5_hws_cnt.c | 163 ++++++++++++++++----------------
 drivers/net/mlx5/mlx5_hws_cnt.h | 109 +++++++++++----------
 3 files changed, 150 insertions(+), 134 deletions(-)
drivers/net/mlx5/mlx5_flow_hw.c +8 -4
index fc87e687c9..1495bc384e 100644
@@ -2311,8 +2311,10 @@ flow_hw_actions_construct(struct rte_eth_dev *dev,
 				break;
 			/* Fall-through. */
 		case RTE_FLOW_ACTION_TYPE_COUNT:
-			ret = mlx5_hws_cnt_pool_get(priv->hws_cpool, &queue,
-						    &cnt_id, age_idx);
+			ret = mlx5_hws_cnt_pool_get(priv->hws_cpool,
+					(priv->shared_refcnt ||
+					 priv->hws_cpool->cfg.host_cpool) ?
+					NULL : &queue, &cnt_id, age_idx);
 			if (ret != 0)
 				return ret;
 			ret = mlx5_hws_cnt_pool_get_action_offset
@@ -7997,6 +7999,7 @@ static int
 flow_hw_query_counter(const struct rte_eth_dev *dev, uint32_t counter,
 		      void *data, struct rte_flow_error *error)
 {
+	struct mlx5_hws_cnt_pool *hpool;
 	struct mlx5_priv *priv = dev->data->dev_private;
 	struct mlx5_hws_cnt *cnt;
 	struct rte_flow_query_count *qc = data;
@@ -8007,8 +8010,9 @@ flow_hw_query_counter(const struct rte_eth_dev *dev, uint32_t counter,
 		return rte_flow_error_set(error, EINVAL,
 				RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
 				"counter are not available");
-	iidx = mlx5_hws_cnt_iidx(priv->hws_cpool, counter);
-	cnt = &priv->hws_cpool->pool[iidx];
+	hpool = mlx5_hws_cnt_host_pool(priv->hws_cpool);
+	iidx = mlx5_hws_cnt_iidx(hpool, counter);
+	cnt = &hpool->pool[iidx];
 	__hws_cnt_query_raw(priv->hws_cpool, counter, &pkts, &bytes);
 	qc->hits_set = 1;
 	qc->bytes_set = 1;
drivers/net/mlx5/mlx5_hws_cnt.c +84 -79

267 lines not on this page · raw message

drivers/net/mlx5/mlx5_hws_cnt.h +58 -51

218 lines not on this page · raw message

Signature · 1 line
2.18.1
#14 lore raw

PATCH 7/9 app/testpmd: add host port parameter into flow config

In reply to Viacheslav Ovsiienko

Host port id parameter is added to "flow configure" command.

---
 app/test-pmd/cmdline_flow.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
app/test-pmd/cmdline_flow.c +10 -0
index 88108498e0..b88756903b 100644
@@ -228,6 +228,7 @@ enum index {
 	CONFIG_METERS_NUMBER,
 	CONFIG_CONN_TRACK_NUMBER,
 	CONFIG_FLAGS,
+	CONFIG_HOST_PORT,
 
 	/* Indirect action arguments */
 	INDIRECT_ACTION_CREATE,
@@ -1098,6 +1099,7 @@ static const enum index next_config_attr[] = {
 	CONFIG_METERS_NUMBER,
 	CONFIG_CONN_TRACK_NUMBER,
 	CONFIG_FLAGS,
+	CONFIG_HOST_PORT,
 	END,
 	ZERO,
 };
@@ -2719,6 +2721,14 @@ static const struct token token_list[] = {
 		.args = ARGS(ARGS_ENTRY(struct buffer,
 					args.configure.port_attr.flags)),
 	},
+	[CONFIG_HOST_PORT] = {
+		.name = "host_port",
+		.help = "host port for shared objects",
+		.next = NEXT(next_config_attr,
+			     NEXT_ENTRY(COMMON_UNSIGNED)),
+		.args = ARGS(ARGS_ENTRY(struct buffer,
+					args.configure.port_attr.host_port_id)),
+	},
 	/* Top-level command. */
 	[PATTERN_TEMPLATE] = {
 		.name = "pattern_template",
Signature · 1 line
2.18.1
#15 lore raw

PATCH 8/9 app/testpmd: add shared indirect action support

In reply to Viacheslav Ovsiienko

The shared indirect action can be shared between ports, action should be created on single port and the handle can be used in the templates and flows on multiple ports, example:

flow configure 0 queues_number 1 queues_size 64 counters_number 64
flow configure 1 queues_number 1 queues_size 64 counters_number 0 host_port 0 flags 1

flow indirect_action 0 create ingress action_id 0 action count / end

flow actions_template 0 create ingress actions_template_id 8
template indirect 0 / queue index 0 / end mask count / queue index 0 / end

flow actions_template 1 create ingress actions_template_id 18
template shared_indirect 0 0 / queue index 0 / end mask count / queue index 0 / end

---
 app/test-pmd/cmdline_flow.c | 53 ++++++++++++++++++++++++++++++++++++-
 1 file changed, 52 insertions(+), 1 deletion(-)
app/test-pmd/cmdline_flow.c +52 -1
index b88756903b..734959ba9b 100644
@@ -595,6 +595,8 @@ enum index {
 	ACTION_SAMPLE_INDEX,
 	ACTION_SAMPLE_INDEX_VALUE,
 	ACTION_INDIRECT,
+	ACTION_SHARED_INDIRECT,
+	INDIRECT_ACTION_PORT,
 	INDIRECT_ACTION_ID2PTR,
 	ACTION_MODIFY_FIELD,
 	ACTION_MODIFY_FIELD_OP,
@@ -1882,6 +1884,7 @@ static const enum index next_action[] = {
 	ACTION_AGE_UPDATE,
 	ACTION_SAMPLE,
 	ACTION_INDIRECT,
+	ACTION_SHARED_INDIRECT,
 	ACTION_MODIFY_FIELD,
 	ACTION_CONNTRACK,
 	ACTION_CONNTRACK_UPDATE,
@@ -2387,6 +2390,9 @@ static int parse_ia_destroy(struct context *ctx, const struct token *token,
 static int parse_ia_id2ptr(struct context *ctx, const struct token *token,
 			   const char *str, unsigned int len, void *buf,
 			   unsigned int size);
+static int parse_ia_port(struct context *ctx, const struct token *token,
+			 const char *str, unsigned int len, void *buf,
+			 unsigned int size);
 static int parse_mp(struct context *, const struct token *,
 		    const char *, unsigned int,
 		    void *, unsigned int);
@@ -6374,6 +6380,23 @@ static const struct token token_list[] = {
 		.args = ARGS(ARGS_ENTRY_ARB(0, sizeof(uint32_t))),
 		.call = parse_vc,
 	},
+	[ACTION_SHARED_INDIRECT] = {
+		.name = "shared_indirect",
+		.help = "apply indirect action by id and port",
+		.priv = PRIV_ACTION(INDIRECT, 0),
+		.next = NEXT(NEXT_ENTRY(INDIRECT_ACTION_PORT)),
+		.args = ARGS(ARGS_ENTRY_ARB(0, sizeof(uint32_t)),
+			     ARGS_ENTRY_ARB(0, sizeof(uint32_t))),
+		.call = parse_vc,
+	},
+	[INDIRECT_ACTION_PORT] = {
+		.name = "{indirect_action_port}",
+		.type = "INDIRECT_ACTION_PORT",
+		.help = "indirect action port",
+		.next = NEXT(NEXT_ENTRY(INDIRECT_ACTION_ID2PTR)),
+		.call = parse_ia_port,
+		.comp = comp_none,
+	},
 	[INDIRECT_ACTION_ID2PTR] = {
 		.name = "{action_id}",
 		.type = "INDIRECT_ACTION_ID",
@@ -9788,6 +9811,31 @@ parse_port(struct context *ctx, const struct token *token,
 	return ret;
 }
 
+/** Parse tokens for shared indirect actions. */
+static int
+parse_ia_port(struct context *ctx, const struct token *token,
+	      const char *str, unsigned int len,
+	      void *buf, unsigned int size)
+{
+	struct rte_flow_action *action = ctx->object;
+	uint32_t id;
+	int ret;
+
+	(void)buf;
+	(void)size;
+	ctx->objdata = 0;
+	ctx->object = &id;
+	ctx->objmask = NULL;
+	ret = parse_int(ctx, token, str, len, ctx->object, sizeof(id));
+	ctx->object = action;
+	if (ret != (int)len)
+		return ret;
+	/* set indirect action */
+	if (action)
+		action->conf = (void *)(uintptr_t)id;
+	return ret;
+}
+
 static int
 parse_ia_id2ptr(struct context *ctx, const struct token *token,
 		const char *str, unsigned int len,
@@ -9808,7 +9856,10 @@ parse_ia_id2ptr(struct context *ctx, const struct token *token,
 		return ret;
 	/* set indirect action */
 	if (action) {
-		action->conf = port_action_handle_get_by_id(ctx->port, id);
+		portid_t port_id = ctx->port;
+		if (ctx->prev == INDIRECT_ACTION_PORT)
+			port_id = (portid_t)(uintptr_t)action->conf;
+		action->conf = port_action_handle_get_by_id(port_id, id);
 		ret = (action->conf) ? ret : -1;
 	}
 	return ret;
Signature · 1 line
2.18.1
#16 lore raw

PATCH 9/9 doc: update cross-port indirect shared action

In reply to Viacheslav Ovsiienko

The patch updates the Release Notes and documentation for the indirect RTE Flow actions as shared ones between ports on the same physical NIC.

---
 doc/guides/rel_notes/release_23_03.rst      | 6 ++++++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst | 4 +++-
 2 files changed, 9 insertions(+), 1 deletion(-)
doc/guides/rel_notes/release_23_03.rst +6 -0
index c15f6fbb9f..eb6643bc66 100644
@@ -55,6 +55,12 @@ New Features
      Also, make sure to start the actual text at the margin.
      =======================================================
 
+* **Added cross-port indirect action in asynchronous Flow API.**
+
+  * Added ``RTE_FLOW_PORT_FLAG_SHARE_INDIRECT`` flag option to
+    ``rte_flow_configure``.
+  * Added ``host_port_id`` to ``rte_flow_port_attr`` structure.
+
 * **Updated Intel QuickAssist Technology (QAT) crypto driver.**
 
   * Added support for SHA3 224/256/384/512 plain hash in QAT GEN 3.
doc/guides/testpmd_app_ug/testpmd_funcs.rst +3 -1
index 0037506a79..cf6c214197 100644
@@ -3047,7 +3047,9 @@ for asynchronous flow creation/destruction operations. It is bound to
        [queues_number {number}] [queues_size {size}]
        [counters_number {number}]
        [aging_counters_number {number}]
-       [meters_number {number}] [flags {number}]
+       [host_port {number}]
+       [meters_number {number}]
+       [flags {number}]
 
 If successful, it will show::
 
Signature · 1 line
2.18.1
#17 lore raw

PATCH v2 1/9 ethdev: sharing indirect actions between ports

In reply to Viacheslav Ovsiienko

The RTE Flow API implements the concept of shared objects, known as indirect actions (RTE_FLOW_ACTION_TYPE_INDIRECT). An application can create the indirect action of desired type and configuration with rte_flow_action_handle_create call and then specify the obtained action handle in multiple flows.

The initial concept supposes the action handle has strict attachment to the port it was created on and to be used exclusively in the flows being installed on the port.

Nowadays the multipath network topologies are quite common, packets belonging to the same connection might arrive and be sent over multiple ports, and there is the raising demand to handle these "spread" connections. To fulfil this demand it is proposed to extend indirect action sharing across the multiple ports. This kind of sharing would be extremely useful for the meters and counters, allowing to manage the single connection over the multiple ports.

This cross-port object sharing is hard to implement in generic way merely with software on the upper layers, but can be provided by the driver over the single hardware instance, where multiple ports reside on the same physical NIC and share the same hardware context.

To allow this action sharing application should specify the "host port" during flow configuring to claim the intention to share the indirect actions. All indirect actions reside within "host port" context and can be shared in flows being installed on the host port and on all the ports referencing this one.

If sharing between host and port being configured is not supported the configuration should be rejected with error. There might be multiple independent (mutual exclusive) sharing domains with dedicated host and referencing ports.

To manage the shared indirect action any port from sharing domain can be specified. To share or not the created action is up to application, no API change is needed.

---
 lib/ethdev/rte_flow.c |  6 ++++++
 lib/ethdev/rte_flow.h | 11 +++++++++++
 2 files changed, 17 insertions(+)
lib/ethdev/rte_flow.c +6 -0
index 7d0c24366c..692d37925a 100644
@@ -1476,6 +1476,12 @@ rte_flow_configure(uint16_t port_id,
 		RTE_FLOW_LOG(ERR, "Port %"PRIu16" queue info is NULL.\n", port_id);
 		return -EINVAL;
 	}
+	if ((port_attr->flags & RTE_FLOW_PORT_FLAG_SHARE_INDIRECT) &&
+	     !rte_eth_dev_is_valid_port(port_attr->host_port_id)) {
+		return rte_flow_error_set(error, ENODEV,
+					  RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
+					  NULL, rte_strerror(ENODEV));
+	}
 	if (likely(!!ops->configure)) {
 		ret = ops->configure(dev, port_attr, nb_queue, queue_attr, error);
 		if (ret == 0)
lib/ethdev/rte_flow.h +11 -0
index b60987db4b..89d2394bd8 100644
@@ -4903,6 +4903,13 @@ rte_flow_info_get(uint16_t port_id,
 		  struct rte_flow_queue_info *queue_info,
 		  struct rte_flow_error *error);
 
+/**
+ * Indicate all steering objects should be created on contexts
+ * of the host port, providing indirect object sharing between
+ * ports.
+ */
+#define RTE_FLOW_PORT_FLAG_SHARE_INDIRECT RTE_BIT32(0)
+
 /**
  * @warning
  * @b EXPERIMENTAL: this API may change without prior notice.
@@ -4932,6 +4939,10 @@ struct rte_flow_port_attr {
 	 * @see RTE_FLOW_ACTION_TYPE_CONNTRACK
 	 */
 	uint32_t nb_conn_tracks;
+	/**
+	 * Port to base shared objects on.
+	 */
+	uint16_t host_port_id;
 	/**
 	 * Port flags (RTE_FLOW_PORT_FLAG_*).
 	 */
Signature · 1 line
2.18.1
#18 lore raw

PATCH v2 2/9 app/testpmd: add host port parameter into flow config

Host port id parameter is added to "flow configure" command.

---
 app/test-pmd/cmdline_flow.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
app/test-pmd/cmdline_flow.c +10 -0
index 88108498e0..b88756903b 100644
@@ -228,6 +228,7 @@ enum index {
 	CONFIG_METERS_NUMBER,
 	CONFIG_CONN_TRACK_NUMBER,
 	CONFIG_FLAGS,
+	CONFIG_HOST_PORT,
 
 	/* Indirect action arguments */
 	INDIRECT_ACTION_CREATE,
@@ -1098,6 +1099,7 @@ static const enum index next_config_attr[] = {
 	CONFIG_METERS_NUMBER,
 	CONFIG_CONN_TRACK_NUMBER,
 	CONFIG_FLAGS,
+	CONFIG_HOST_PORT,
 	END,
 	ZERO,
 };
@@ -2719,6 +2721,14 @@ static const struct token token_list[] = {
 		.args = ARGS(ARGS_ENTRY(struct buffer,
 					args.configure.port_attr.flags)),
 	},
+	[CONFIG_HOST_PORT] = {
+		.name = "host_port",
+		.help = "host port for shared objects",
+		.next = NEXT(next_config_attr,
+			     NEXT_ENTRY(COMMON_UNSIGNED)),
+		.args = ARGS(ARGS_ENTRY(struct buffer,
+					args.configure.port_attr.host_port_id)),
+	},
 	/* Top-level command. */
 	[PATTERN_TEMPLATE] = {
 		.name = "pattern_template",
Signature · 1 line
2.18.1
#20 lore raw

PATCH v2 3/9 app/testpmd: add shared indirect action support

In reply to Viacheslav Ovsiienko

The shared indirect action can be shared between ports, action should be created on single port and the handle can be used in the templates and flows on multiple ports, example:

  flow configure 0 queues_number 1 queues_size 64 counters_number 64
  flow configure 1 queues_number 1 queues_size 64 counters_number 0 \
                   host_port 0 flags 1

flow indirect_action 0 create ingress action_id 0 action count / end

flow actions_template 0 create ingress actions_template_id 8
template indirect 0 / queue index 0 / end mask count / queue index 0 / end

flow actions_template 1 create ingress actions_template_id 18
template shared_indirect 0 0 / queue index 0 / end mask count / queue index 0 / end

---
 app/test-pmd/cmdline_flow.c | 53 ++++++++++++++++++++++++++++++++++++-
 1 file changed, 52 insertions(+), 1 deletion(-)
app/test-pmd/cmdline_flow.c +52 -1
index b88756903b..734959ba9b 100644
@@ -595,6 +595,8 @@ enum index {
 	ACTION_SAMPLE_INDEX,
 	ACTION_SAMPLE_INDEX_VALUE,
 	ACTION_INDIRECT,
+	ACTION_SHARED_INDIRECT,
+	INDIRECT_ACTION_PORT,
 	INDIRECT_ACTION_ID2PTR,
 	ACTION_MODIFY_FIELD,
 	ACTION_MODIFY_FIELD_OP,
@@ -1882,6 +1884,7 @@ static const enum index next_action[] = {
 	ACTION_AGE_UPDATE,
 	ACTION_SAMPLE,
 	ACTION_INDIRECT,
+	ACTION_SHARED_INDIRECT,
 	ACTION_MODIFY_FIELD,
 	ACTION_CONNTRACK,
 	ACTION_CONNTRACK_UPDATE,
@@ -2387,6 +2390,9 @@ static int parse_ia_destroy(struct context *ctx, const struct token *token,
 static int parse_ia_id2ptr(struct context *ctx, const struct token *token,
 			   const char *str, unsigned int len, void *buf,
 			   unsigned int size);
+static int parse_ia_port(struct context *ctx, const struct token *token,
+			 const char *str, unsigned int len, void *buf,
+			 unsigned int size);
 static int parse_mp(struct context *, const struct token *,
 		    const char *, unsigned int,
 		    void *, unsigned int);
@@ -6374,6 +6380,23 @@ static const struct token token_list[] = {
 		.args = ARGS(ARGS_ENTRY_ARB(0, sizeof(uint32_t))),
 		.call = parse_vc,
 	},
+	[ACTION_SHARED_INDIRECT] = {
+		.name = "shared_indirect",
+		.help = "apply indirect action by id and port",
+		.priv = PRIV_ACTION(INDIRECT, 0),
+		.next = NEXT(NEXT_ENTRY(INDIRECT_ACTION_PORT)),
+		.args = ARGS(ARGS_ENTRY_ARB(0, sizeof(uint32_t)),
+			     ARGS_ENTRY_ARB(0, sizeof(uint32_t))),
+		.call = parse_vc,
+	},
+	[INDIRECT_ACTION_PORT] = {
+		.name = "{indirect_action_port}",
+		.type = "INDIRECT_ACTION_PORT",
+		.help = "indirect action port",
+		.next = NEXT(NEXT_ENTRY(INDIRECT_ACTION_ID2PTR)),
+		.call = parse_ia_port,
+		.comp = comp_none,
+	},
 	[INDIRECT_ACTION_ID2PTR] = {
 		.name = "{action_id}",
 		.type = "INDIRECT_ACTION_ID",
@@ -9788,6 +9811,31 @@ parse_port(struct context *ctx, const struct token *token,
 	return ret;
 }
 
+/** Parse tokens for shared indirect actions. */
+static int
+parse_ia_port(struct context *ctx, const struct token *token,
+	      const char *str, unsigned int len,
+	      void *buf, unsigned int size)
+{
+	struct rte_flow_action *action = ctx->object;
+	uint32_t id;
+	int ret;
+
+	(void)buf;
+	(void)size;
+	ctx->objdata = 0;
+	ctx->object = &id;
+	ctx->objmask = NULL;
+	ret = parse_int(ctx, token, str, len, ctx->object, sizeof(id));
+	ctx->object = action;
+	if (ret != (int)len)
+		return ret;
+	/* set indirect action */
+	if (action)
+		action->conf = (void *)(uintptr_t)id;
+	return ret;
+}
+
 static int
 parse_ia_id2ptr(struct context *ctx, const struct token *token,
 		const char *str, unsigned int len,
@@ -9808,7 +9856,10 @@ parse_ia_id2ptr(struct context *ctx, const struct token *token,
 		return ret;
 	/* set indirect action */
 	if (action) {
-		action->conf = port_action_handle_get_by_id(ctx->port, id);
+		portid_t port_id = ctx->port;
+		if (ctx->prev == INDIRECT_ACTION_PORT)
+			port_id = (portid_t)(uintptr_t)action->conf;
+		action->conf = port_action_handle_get_by_id(port_id, id);
 		ret = (action->conf) ? ret : -1;
 	}
 	return ret;
Signature · 1 line
2.18.1
Acked-by on v2 3/9
#21 lore raw

RE: [PATCH v2 3/9] app/testpmd: add shared indirect action support

Hi Slava,

Quoted 20 lines

-----Original Message-----
From: Slava Ovsiienko <[email protected]>
Sent: Tuesday, 7 February 2023 16:02
Subject: [PATCH v2 3/9] app/testpmd: add shared indirect action support

The shared indirect action can be shared between ports, action should be created on single port and the handle can be used in the templates and flows on multiple ports, example:

  flow configure 0 queues_number 1 queues_size 64 counters_number 64
  flow configure 1 queues_number 1 queues_size 64 counters_number 0 \
                   host_port 0 flags 1

flow indirect_action 0 create ingress action_id 0 action count / end

flow actions_template 0 create ingress actions_template_id 8
template indirect 0 / queue index 0 / end mask count / queue index 0 / end

Quoted 6 lines

flow actions_template 1 create ingress actions_template_id 18
template shared_indirect 0 0 / queue index 0 / end mask count / queue index 0 / end

---

Best,
Ori

#22 lore raw

PATCH v2 4/9 net/mlx5/hws: free FT from RTC id before set the new value

In reply to Viacheslav Ovsiienko

From: Erez Shitrit <[email protected]>

While matcher is being connect/disconnect in shared gvmi flow we set the first ft in the table to point on the first matcher,
The FW is increasing the refcount on the first matcher RTC because of that no matcher if it is the same RTC that was set before, and when we will try to release that RTC we will get the following syndrome:
0xaa0093 - destroy_rtc_object: rtc in use or doesn't exist.

In order to resolve that we clean the current pointed RTC from that ft and only after that setting it to the new RTC value.

---
 drivers/net/mlx5/hws/mlx5dr_matcher.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
drivers/net/mlx5/hws/mlx5dr_matcher.c +18 -0
index d509a2f0e1..32bf3f5886 100644
@@ -334,6 +334,24 @@ static int mlx5dr_matcher_disconnect(struct mlx5dr_matcher *matcher)
 		return ret;
 	}
 
+	if (!next) {
+		/* ft no longer points to any RTC, drop refcount */
+		ret = mlx5dr_matcher_free_rtc_pointing(tbl->ctx,
+						       tbl->fw_ft_type,
+						       tbl->type,
+						       prev_ft);
+		if (ret) {
+			DR_LOG(ERR, "Failed to reset last RTC refcount");
+			return ret;
+		}
+	}
+
+	ret = mlx5dr_matcher_shared_update_local_ft(tbl);
+	if (ret) {
+		DR_LOG(ERR, "Failed to update local_ft in shared table");
+		return ret;
+	}
+
 	return 0;
 }
 
Signature · 1 line
2.18.1
#23 lore raw

PATCH v2 5/9 net/mlx5/hws: fix disconnecting matcher

In reply to Viacheslav Ovsiienko

From: Erez Shitrit <[email protected]>

This patch fixes the matcher disconnection handling, by removing the RTC references from flow table if the currently removed matcher was the last one for the given table. As a result RTC in this matcher can be correctly freed, since there are no dangling references to the RTC.

Fixes c467608215b2 ("net/mlx5/hws: add matcher object")
---
 drivers/net/mlx5/hws/mlx5dr_matcher.c | 6 ------
 1 file changed, 6 deletions(-)
drivers/net/mlx5/hws/mlx5dr_matcher.c +0 -6
index 32bf3f5886..a0297c9787 100644
@@ -346,12 +346,6 @@ static int mlx5dr_matcher_disconnect(struct mlx5dr_matcher *matcher)
 		}
 	}
 
-	ret = mlx5dr_matcher_shared_update_local_ft(tbl);
-	if (ret) {
-		DR_LOG(ERR, "Failed to update local_ft in shared table");
-		return ret;
-	}
-
 	return 0;
 }
 
Signature · 1 line
2.18.1
#24 lore raw

PATCH v2 6/9 common/mlx5: add cross port object sharing capability

In reply to Viacheslav Ovsiienko

Add query port capabilities to share steering objects between multiple ports of the same physical NIC.

---
 drivers/common/mlx5/mlx5_devx_cmds.c | 13 +++++++++++++
 drivers/common/mlx5/mlx5_devx_cmds.h |  1 +
 2 files changed, 14 insertions(+)
drivers/common/mlx5/mlx5_devx_cmds.c +13 -0
index e3a4927d0f..17128035ec 100644
@@ -1047,6 +1047,19 @@ mlx5_devx_cmd_query_hca_attr(void *ctx,
 		attr->flow_counter_bulk_log_granularity =
 			MLX5_GET(cmd_hca_cap_2, hcattr,
 				 flow_counter_bulk_log_granularity);
+		rc = MLX5_GET(cmd_hca_cap_2, hcattr,
+			      cross_vhca_object_to_object_supported);
+		attr->cross_vhca =
+			(rc & MLX5_CROSS_VHCA_OBJ_TO_OBJ_TYPE_STC_TO_TIR) &&
+			(rc & MLX5_CROSS_VHCA_OBJ_TO_OBJ_TYPE_STC_TO_FT) &&
+			(rc & MLX5_CROSS_VHCA_OBJ_TO_OBJ_TYPE_FT_TO_FT) &&
+			(rc & MLX5_CROSS_VHCA_OBJ_TO_OBJ_TYPE_FT_TO_RTC);
+		rc = MLX5_GET(cmd_hca_cap_2, hcattr,
+			      allowed_object_for_other_vhca_access);
+		attr->cross_vhca = attr->cross_vhca &&
+			(rc & MLX5_CROSS_VHCA_ALLOWED_OBJS_TIR) &&
+			(rc & MLX5_CROSS_VHCA_ALLOWED_OBJS_FT) &&
+			(rc & MLX5_CROSS_VHCA_ALLOWED_OBJS_RTC);
 	}
 	if (attr->log_min_stride_wqe_sz == 0)
 		attr->log_min_stride_wqe_sz = MLX5_MPRQ_LOG_MIN_STRIDE_WQE_SIZE;
drivers/common/mlx5/mlx5_devx_cmds.h +1 -0
index c94b9eac06..b65ba569bc 100644
@@ -288,6 +288,7 @@ struct mlx5_hca_attr {
 	uint32_t alloc_flow_counter_pd:1;
 	uint32_t flow_counter_access_aso:1;
 	uint32_t flow_access_aso_opc_mod:8;
+	uint32_t cross_vhca:1;
 };
 
 /* LAG Context. */
Signature · 1 line
2.18.1
#25 lore raw

PATCH v2 7/9 net/mlx5: add cross port shared mode for HW steering

In reply to Viacheslav Ovsiienko

Add host port option for sharing steering objects between multiple ports of the same physical NIC.

---
 drivers/net/mlx5/mlx5.c         |  6 +++
 drivers/net/mlx5/mlx5.h         |  2 +
 drivers/net/mlx5/mlx5_flow_hw.c | 78 +++++++++++++++++++++++++++++++--
 drivers/net/mlx5/mlx5_hws_cnt.c | 12 +++++
 4 files changed, 94 insertions(+), 4 deletions(-)
drivers/net/mlx5/mlx5.c +6 -0
index b8643cebdd..2eca2cceef 100644
@@ -2013,6 +2013,12 @@ mlx5_dev_close(struct rte_eth_dev *dev)
 	}
 	if (!priv->sh)
 		return 0;
+	if (priv->shared_refcnt) {
+		DRV_LOG(ERR, "port %u is shared host in use (%u)",
+			dev->data->port_id, priv->shared_refcnt);
+		rte_errno = EBUSY;
+		return -EBUSY;
+	}
 	DRV_LOG(DEBUG, "port %u closing device \"%s\"",
 		dev->data->port_id,
 		((priv->sh->cdev->ctx != NULL) ?
drivers/net/mlx5/mlx5.h +2 -0
index 16b33e1548..525bdd47f7 100644
@@ -1780,6 +1780,8 @@ struct mlx5_priv {
 	struct mlx5_flow_hw_ctrl_rx *hw_ctrl_rx;
 	/**< HW steering templates used to create control flow rules. */
 #endif
+	struct rte_eth_dev *shared_host; /* Host device for HW steering. */
+	uint16_t shared_refcnt; /* HW steering host reference counter. */
 };
 
 #define PORT_ID(priv) ((priv)->dev_data->port_id)
drivers/net/mlx5/mlx5_flow_hw.c +74 -4

138 lines not on this page · raw message

drivers/net/mlx5/mlx5_hws_cnt.c +12 -0
index 51704ef754..afc93821e4 100644
@@ -618,6 +618,12 @@ mlx5_hws_cnt_pool_create(struct rte_eth_dev *dev,
 	int ret = 0;
 	size_t sz;
 
+	if (pattr->flags & RTE_FLOW_PORT_FLAG_SHARE_INDIRECT) {
+		DRV_LOG(ERR, "Counters are not supported "
+			     "in cross vHCA sharing mode");
+		rte_errno = ENOTSUP;
+		return NULL;
+	}
 	/* init cnt service if not. */
 	if (priv->sh->cnt_svc == NULL) {
 		ret = mlx5_hws_cnt_svc_init(priv->sh);
@@ -1189,6 +1195,12 @@ mlx5_hws_age_pool_init(struct rte_eth_dev *dev,
 
 	strict_queue = !!(attr->flags & RTE_FLOW_PORT_FLAG_STRICT_QUEUE);
 	MLX5_ASSERT(priv->hws_cpool);
+	if (attr->flags & RTE_FLOW_PORT_FLAG_SHARE_INDIRECT) {
+		DRV_LOG(ERR, "Aging sn not supported "
+			     "in cross vHCA sharing mode");
+		rte_errno = ENOTSUP;
+		return -ENOTSUP;
+	}
 	nb_alloc_cnts = mlx5_hws_cnt_pool_get_size(priv->hws_cpool);
 	if (strict_queue) {
 		rsize = mlx5_hws_aged_out_q_ring_size_get(nb_alloc_cnts,
Signature · 1 line
2.18.1
#26 lore raw

PATCH v2 8/9 net/mlx5: support counters in cross port shared mode

In reply to Viacheslav Ovsiienko

In the cross vHCA sharing mode the host counter pool should be used in counter related routines. The local port pool is used to store the dedicated DR action handle, per queue counter caches and query data are ignored and not allocated on local pool.

---
 drivers/net/mlx5/mlx5_flow_hw.c |  12 ++-
 drivers/net/mlx5/mlx5_hws_cnt.c | 163 ++++++++++++++++----------------
 drivers/net/mlx5/mlx5_hws_cnt.h | 109 +++++++++++----------
 3 files changed, 150 insertions(+), 134 deletions(-)
drivers/net/mlx5/mlx5_flow_hw.c +8 -4
index 59b5d1980c..b9405669c8 100644
@@ -2311,8 +2311,10 @@ flow_hw_actions_construct(struct rte_eth_dev *dev,
 				break;
 			/* Fall-through. */
 		case RTE_FLOW_ACTION_TYPE_COUNT:
-			ret = mlx5_hws_cnt_pool_get(priv->hws_cpool, &queue,
-						    &cnt_id, age_idx);
+			ret = mlx5_hws_cnt_pool_get(priv->hws_cpool,
+					(priv->shared_refcnt ||
+					 priv->hws_cpool->cfg.host_cpool) ?
+					NULL : &queue, &cnt_id, age_idx);
 			if (ret != 0)
 				return ret;
 			ret = mlx5_hws_cnt_pool_get_action_offset
@@ -7996,6 +7998,7 @@ static int
 flow_hw_query_counter(const struct rte_eth_dev *dev, uint32_t counter,
 		      void *data, struct rte_flow_error *error)
 {
+	struct mlx5_hws_cnt_pool *hpool;
 	struct mlx5_priv *priv = dev->data->dev_private;
 	struct mlx5_hws_cnt *cnt;
 	struct rte_flow_query_count *qc = data;
@@ -8006,8 +8009,9 @@ flow_hw_query_counter(const struct rte_eth_dev *dev, uint32_t counter,
 		return rte_flow_error_set(error, EINVAL,
 				RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
 				"counter are not available");
-	iidx = mlx5_hws_cnt_iidx(priv->hws_cpool, counter);
-	cnt = &priv->hws_cpool->pool[iidx];
+	hpool = mlx5_hws_cnt_host_pool(priv->hws_cpool);
+	iidx = mlx5_hws_cnt_iidx(hpool, counter);
+	cnt = &hpool->pool[iidx];
 	__hws_cnt_query_raw(priv->hws_cpool, counter, &pkts, &bytes);
 	qc->hits_set = 1;
 	qc->bytes_set = 1;
drivers/net/mlx5/mlx5_hws_cnt.c +84 -79

267 lines not on this page · raw message

drivers/net/mlx5/mlx5_hws_cnt.h +58 -51

218 lines not on this page · raw message

Signature · 1 line
2.18.1
#27 lore raw

PATCH v2 9/9 doc: update cross-port indirect shared action

In reply to Viacheslav Ovsiienko

The patch updates the Release Notes and documentation for the indirect RTE Flow actions as shared ones between ports on the same physical NIC.

---
 doc/guides/rel_notes/release_23_03.rst      | 6 ++++++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst | 4 +++-
 2 files changed, 9 insertions(+), 1 deletion(-)
doc/guides/rel_notes/release_23_03.rst +6 -0
index c15f6fbb9f..eb6643bc66 100644
@@ -55,6 +55,12 @@ New Features
      Also, make sure to start the actual text at the margin.
      =======================================================
 
+* **Added cross-port indirect action in asynchronous Flow API.**
+
+  * Added ``RTE_FLOW_PORT_FLAG_SHARE_INDIRECT`` flag option to
+    ``rte_flow_configure``.
+  * Added ``host_port_id`` to ``rte_flow_port_attr`` structure.
+
 * **Updated Intel QuickAssist Technology (QAT) crypto driver.**
 
   * Added support for SHA3 224/256/384/512 plain hash in QAT GEN 3.
doc/guides/testpmd_app_ug/testpmd_funcs.rst +3 -1
index 0037506a79..cf6c214197 100644
@@ -3047,7 +3047,9 @@ for asynchronous flow creation/destruction operations. It is bound to
        [queues_number {number}] [queues_size {size}]
        [counters_number {number}]
        [aging_counters_number {number}]
-       [meters_number {number}] [flags {number}]
+       [host_port {number}]
+       [meters_number {number}]
+       [flags {number}]
 
 If successful, it will show::
 
Signature · 1 line
2.18.1
Acked-by on v2 9/9
#28 lore raw

RE: [PATCH v2 9/9] doc: update cross-port indirect shared action

Hi Slava,

Quoted 10 lines

-----Original Message-----
From: Slava Ovsiienko <[email protected]>
Sent: Tuesday, 7 February 2023 16:02

The patch updates the Release Notes and documentation for the indirect RTE Flow actions as shared ones between ports on the same physical NIC.

---

Best,
Ori

#29 lore raw

Re: [PATCH v2 9/9] doc: update cross-port indirect shared action

In reply to Viacheslav Ovsiienko
Quoted 32 lines · Viacheslav Ovsiienko

The patch updates the Release Notes and documentation for the indirect RTE Flow actions as shared ones between ports on the same physical NIC.

---
 doc/guides/rel_notes/release_23_03.rst      | 6 ++++++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst | 4 +++-
 2 files changed, 9 insertions(+), 1 deletion(-)
doc/guides/rel_notes/release_23_03.rst +6 -0
index c15f6fbb9f..eb6643bc66 100644
@@ -55,6 +55,12 @@ New Features
      Also, make sure to start the actual text at the margin.
      =======================================================
 
+* **Added cross-port indirect action in asynchronous Flow API.**
+
+  * Added ``RTE_FLOW_PORT_FLAG_SHARE_INDIRECT`` flag option to
+    ``rte_flow_configure``.
+  * Added ``host_port_id`` to ``rte_flow_port_attr`` structure.
+
 * **Updated Intel QuickAssist Technology (QAT) crypto driver.**
 
   * Added support for SHA3 224/256/384/512 plain hash in QAT GEN 3.
doc/guides/testpmd_app_ug/testpmd_funcs.rst +0 -0
index 0037506a79..cf6c214197 100644

doc/guides/testpmd_app_ug/testpmd_funcs.rst for asynchronous flow creation/destruction operations. It is bound to · line 3055

Quoted 10 lines
doc/guides/testpmd_app_ug/testpmd_funcs.rst +3 -1
@@ -3047,7 +3047,9 @@ for asynchronous flow creation/destruction operations. It is bound to
        [queues_number {number}] [queues_size {size}]
        [counters_number {number}]
        [aging_counters_number {number}]
-       [meters_number {number}] [flags {number}]
+       [host_port {number}]
+       [meters_number {number}]
+       [flags {number}]
 
 If successful, it will show::
 

Can you please distribute the documentation to the patches that actually adds the documented feature?
So no need to have document only patch.

#30 lore raw
In reply to Viacheslav Ovsiienko

Hi Slava

Quoted 41 lines

-----Original Message-----
From: Slava Ovsiienko <[email protected]>
Sent: Tuesday, 7 February 2023 16:02

The RTE Flow API implements the concept of shared objects, known as indirect actions (RTE_FLOW_ACTION_TYPE_INDIRECT). An application can create the indirect action of desired type and configuration with rte_flow_action_handle_create call and then specify the obtained action handle in multiple flows.

The initial concept supposes the action handle has strict attachment to the port it was created on and to be used exclusively in the flows being installed on the port.

Nowadays the multipath network topologies are quite common, packets belonging to the same connection might arrive and be sent over multiple ports, and there is the raising demand to handle these "spread" connections. To fulfil this demand it is proposed to extend indirect action sharing across the multiple ports. This kind of sharing would be extremely useful for the meters and counters, allowing to manage the single connection over the multiple ports.

This cross-port object sharing is hard to implement in generic way merely with software on the upper layers, but can be provided by the driver over the single hardware instance, where multiple ports reside on the same physical NIC and share the same hardware context.

To allow this action sharing application should specify the "host port" during flow configuring to claim the intention to share the indirect actions. All indirect actions reside within "host port" context and can be shared in flows being installed on the host port and on all the ports referencing this one.

If sharing between host and port being configured is not supported the configuration should be rejected with error. There might be multiple independent (mutual exclusive) sharing domains with dedicated host and referencing ports.

Quoted 6 lines

To manage the shared indirect action any port from sharing domain can be specified. To share or not the created action is up to application, no API change is needed.

---

Thanks,
Ori

Acked-by on v2 1/9
#31 lore raw
In reply to Viacheslav Ovsiienko

Hi Slava

Quoted 41 lines

-----Original Message-----
From: Slava Ovsiienko <[email protected]>
Sent: Tuesday, 7 February 2023 16:02

The RTE Flow API implements the concept of shared objects, known as indirect actions (RTE_FLOW_ACTION_TYPE_INDIRECT). An application can create the indirect action of desired type and configuration with rte_flow_action_handle_create call and then specify the obtained action handle in multiple flows.

The initial concept supposes the action handle has strict attachment to the port it was created on and to be used exclusively in the flows being installed on the port.

Nowadays the multipath network topologies are quite common, packets belonging to the same connection might arrive and be sent over multiple ports, and there is the raising demand to handle these "spread" connections. To fulfil this demand it is proposed to extend indirect action sharing across the multiple ports. This kind of sharing would be extremely useful for the meters and counters, allowing to manage the single connection over the multiple ports.

This cross-port object sharing is hard to implement in generic way merely with software on the upper layers, but can be provided by the driver over the single hardware instance, where multiple ports reside on the same physical NIC and share the same hardware context.

To allow this action sharing application should specify the "host port" during flow configuring to claim the intention to share the indirect actions. All indirect actions reside within "host port" context and can be shared in flows being installed on the host port and on all the ports referencing this one.

If sharing between host and port being configured is not supported the configuration should be rejected with error. There might be multiple independent (mutual exclusive) sharing domains with dedicated host and referencing ports.

Quoted 6 lines

To manage the shared indirect action any port from sharing domain can be specified. To share or not the created action is up to application, no API change is needed.

---

Best,
Ori

#32 lore raw
In reply to Viacheslav Ovsiienko
Quoted 37 lines · Viacheslav Ovsiienko

The RTE Flow API implements the concept of shared objects, known as indirect actions (RTE_FLOW_ACTION_TYPE_INDIRECT). An application can create the indirect action of desired type and configuration with rte_flow_action_handle_create call and then specify the obtained action handle in multiple flows.

The initial concept supposes the action handle has strict attachment to the port it was created on and to be used exclusively in the flows being installed on the port.

Nowadays the multipath network topologies are quite common, packets belonging to the same connection might arrive and be sent over multiple ports, and there is the raising demand to handle these "spread" connections. To fulfil this demand it is proposed to extend indirect action sharing across the multiple ports. This kind of sharing would be extremely useful for the meters and counters, allowing to manage the single connection over the multiple ports.

This cross-port object sharing is hard to implement in generic way merely with software on the upper layers, but can be provided by the driver over the single hardware instance, where multiple ports reside on the same physical NIC and share the same hardware context.

To allow this action sharing application should specify the "host port" during flow configuring to claim the intention to share the indirect actions. All indirect actions reside within "host port" context and can be shared in flows being installed on the host port and on all the ports referencing this one.

If sharing between host and port being configured is not supported the configuration should be rejected with error. There might be multiple independent (mutual exclusive) sharing domains with dedicated host and referencing ports.

Quoted 5 lines

To manage the shared indirect action any port from sharing domain can be specified. To share or not the created action is up to application, no API change is needed.

Hi Viacheslav,

This set doesn't compile, it fails because of some undefined variable/macro in driver code. By any chance can this patch based some internal code?

Do you want to separate ethdev and driver patches into different sets, so ehtdev part can go into next-net and driver part can be merged to mlx tree afterwards.

#33 lore raw

Hi, Ferruh

Quoted 8 lines

-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Friday, February 10, 2023 4:35 PM
To: Slava Ovsiienko <[email protected]>; [email protected]
Cc: Ori Kam <[email protected]>; Raslan Darawsheh <[email protected]>; Matan Azrad <[email protected]>; [email protected]
Subject: Re: [PATCH v2 1/9] ethdev: sharing indirect actions between ports

Quoted 5 lines

This set doesn't compile, it fails because of some undefined variable/macro in driver code. By any chance can this patch based some internal code?

Do you want to separate ethdev and driver patches into different sets, so ehtdev part can go into next-net and driver part can be merged to mlx tree afterwards.

Yes, let's merge ethdev part now and let me check what Is wrong with the rest of patch set.

With best regards,
Slava

#34 lore raw

v3 cover *ethdev: sharing indirect actions between port*

In reply to Viacheslav Ovsiienko

The RTE Flow API implements the concept of shared objects, known as indirect actions (RTE_FLOW_ACTION_TYPE_INDIRECT). An application can create the indirect action of desired type and configuration with rte_flow_action_handle_create call and then specify the obtained action handle in multiple flows.

The initial concept supposes the action handle has strict attachment to the port it was created on and to be used exclusively in the flows being installed on the port.

Nowadays the multipath network topologies are quite common, packets belonging to the same connection might arrive and be sent over multiple ports, and there is the raising demand to handle these "spread" connections. To fulfil this demand it is proposed to extend indirect action sharing across the multiple ports. This kind of sharing would be extremely useful for the meters and counters, allowing to manage the single connection over the multiple ports.

This cross-port object sharing is hard to implement in generic way merely with software on the upper layers, but can be provided by the driver over the single hardware instance, where multiple ports reside on the same physical NIC and share the same hardware context.

To allow this action sharing application should specify the "host port" during flow configuring to claim the intention to share the indirect actions. All indirect actions reside within "host port" context and can be shared in flows being installed on the host port and on all the ports referencing this one.

If sharing between host and port being configured is not supported the configuration should be rejected with error. There might be multiple independent (mutual exclusive) sharing domains with dedicated host and referencing ports.

To manage the shared indirect action any port from sharing domain can be specified. To share or not the created action is up to application, no API change is needed.

Viacheslav Ovsiienko (3):
ethdev: sharing indirect actions between ports app/testpmd: add host port parameter into flow config app/testpmd: add shared indirect action support

 app/test-pmd/cmdline_flow.c                 | 63 ++++++++++++++++++++-
 doc/guides/rel_notes/release_23_03.rst      |  6 ++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  4 +-
 lib/ethdev/rte_flow.c                       |  6 ++
 lib/ethdev/rte_flow.h                       | 11 ++++
 5 files changed, 88 insertions(+), 2 deletions(-)
Signature · 9 lines
2.18.1

---
RFC: https://inbox.dpdk.org/dev/[email protected]/
v1:  https://inbox.dpdk.org/dev/[email protected]/
v2:  https://inbox.dpdk.org/dev/[email protected]/
     minor comilation issues, rebase, typos
v3:  series split to ethdev/testpmd and mlx5 PMD patch to be smoothly applied
     over dpdk-next/main. The mlx5 PMD seris is coming.
#35 lore raw

PATCH v3 1/3 ethdev: sharing indirect actions between ports

The RTE Flow API implements the concept of shared objects, known as indirect actions (RTE_FLOW_ACTION_TYPE_INDIRECT). An application can create the indirect action of desired type and configuration with rte_flow_action_handle_create call and then specify the obtained action handle in multiple flows.

The initial concept supposes the action handle has strict attachment to the port it was created on and to be used exclusively in the flows being installed on the port.

Nowadays the multipath network topologies are quite common, packets belonging to the same connection might arrive and be sent over multiple ports, and there is the raising demand to handle these "spread" connections. To fulfil this demand it is proposed to extend indirect action sharing across the multiple ports. This kind of sharing would be extremely useful for the meters and counters, allowing to manage the single connection over the multiple ports.

This cross-port object sharing is hard to implement in generic way merely with software on the upper layers, but can be provided by the driver over the single hardware instance, where multiple ports reside on the same physical NIC and share the same hardware context.

To allow this action sharing application should specify the "host port" during flow configuring to claim the intention to share the indirect actions. All indirect actions reside within "host port" context and can be shared in flows being installed on the host port and on all the ports referencing this one.

If sharing between host and port being configured is not supported the configuration should be rejected with error. There might be multiple independent (mutual exclusive) sharing domains with dedicated host and referencing ports.

To manage the shared indirect action any port from sharing domain can be specified. To share or not the created action is up to application, no API change is needed.

---
 doc/guides/rel_notes/release_23_03.rst      |  6 ++++++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  4 +++-
 lib/ethdev/rte_flow.c                       |  6 ++++++
 lib/ethdev/rte_flow.h                       | 11 +++++++++++
 4 files changed, 26 insertions(+), 1 deletion(-)
doc/guides/rel_notes/release_23_03.rst +6 -0
index 75c64cafa4..ea12c746e3 100644
@@ -69,6 +69,12 @@ New Features
 
   * Added modify flex item: ``rte_flow_action_modify_data.flex_handle``.
 
+* **Added cross-port indirect action in asynchronous Flow API.**
+
+  * Added ``RTE_FLOW_PORT_FLAG_SHARE_INDIRECT`` flag option to
+    ``rte_flow_configure``.
+  * Added ``host_port_id`` to ``rte_flow_port_attr`` structure.
+
 * **Updated AMD axgbe driver.**
 
   * Added multi-process support.
doc/guides/testpmd_app_ug/testpmd_funcs.rst +3 -1
index 725062e6b0..c448cf47b3 100644
@@ -3076,7 +3076,9 @@ for asynchronous flow creation/destruction operations. It is bound to
        [queues_number {number}] [queues_size {size}]
        [counters_number {number}]
        [aging_counters_number {number}]
-       [meters_number {number}] [flags {number}]
+       [host_port {number}]
+       [meters_number {number}]
+       [flags {number}]
 
 If successful, it will show::
 
lib/ethdev/rte_flow.c +6 -0
index 57bec6f5e1..a5680daa19 100644
@@ -1597,6 +1597,12 @@ rte_flow_configure(uint16_t port_id,
 		RTE_FLOW_LOG(ERR, "Port %"PRIu16" queue info is NULL.\n", port_id);
 		return -EINVAL;
 	}
+	if ((port_attr->flags & RTE_FLOW_PORT_FLAG_SHARE_INDIRECT) &&
+	     !rte_eth_dev_is_valid_port(port_attr->host_port_id)) {
+		return rte_flow_error_set(error, ENODEV,
+					  RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
+					  NULL, rte_strerror(ENODEV));
+	}
 	if (likely(!!ops->configure)) {
 		ret = ops->configure(dev, port_attr, nb_queue, queue_attr, error);
 		if (ret == 0)
lib/ethdev/rte_flow.h +11 -0
index f4d8b7d3d5..c78684efb0 100644
@@ -4992,6 +4992,13 @@ rte_flow_info_get(uint16_t port_id,
 		  struct rte_flow_queue_info *queue_info,
 		  struct rte_flow_error *error);
 
+/**
+ * Indicate all steering objects should be created on contexts
+ * of the host port, providing indirect object sharing between
+ * ports.
+ */
+#define RTE_FLOW_PORT_FLAG_SHARE_INDIRECT RTE_BIT32(0)
+
 /**
  * @warning
  * @b EXPERIMENTAL: this API may change without prior notice.
@@ -5021,6 +5028,10 @@ struct rte_flow_port_attr {
 	 * @see RTE_FLOW_ACTION_TYPE_CONNTRACK
 	 */
 	uint32_t nb_conn_tracks;
+	/**
+	 * Port to base shared objects on.
+	 */
+	uint16_t host_port_id;
 	/**
 	 * Port flags (RTE_FLOW_PORT_FLAG_*).
 	 */
Signature · 1 line
2.18.1
#36 lore raw

PATCH v3 2/3 app/testpmd: add host port parameter into flow config

In reply to Viacheslav Ovsiienko

Host port id parameter is added to "flow configure" command.

---
 app/test-pmd/cmdline_flow.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
app/test-pmd/cmdline_flow.c +10 -0
index 3b846ae73f..7778828919 100644
@@ -230,6 +230,7 @@ enum index {
 	CONFIG_METERS_NUMBER,
 	CONFIG_CONN_TRACK_NUMBER,
 	CONFIG_FLAGS,
+	CONFIG_HOST_PORT,
 
 	/* Indirect action arguments */
 	INDIRECT_ACTION_CREATE,
@@ -1114,6 +1115,7 @@ static const enum index next_config_attr[] = {
 	CONFIG_METERS_NUMBER,
 	CONFIG_CONN_TRACK_NUMBER,
 	CONFIG_FLAGS,
+	CONFIG_HOST_PORT,
 	END,
 	ZERO,
 };
@@ -2767,6 +2769,14 @@ static const struct token token_list[] = {
 		.args = ARGS(ARGS_ENTRY(struct buffer,
 					args.configure.port_attr.flags)),
 	},
+	[CONFIG_HOST_PORT] = {
+		.name = "host_port",
+		.help = "host port for shared objects",
+		.next = NEXT(next_config_attr,
+			     NEXT_ENTRY(COMMON_UNSIGNED)),
+		.args = ARGS(ARGS_ENTRY(struct buffer,
+					args.configure.port_attr.host_port_id)),
+	},
 	/* Top-level command. */
 	[PATTERN_TEMPLATE] = {
 		.name = "pattern_template",
Signature · 1 line
2.18.1
#37 lore raw

PATCH v3 3/3 app/testpmd: add shared indirect action support

In reply to Viacheslav Ovsiienko

The shared indirect action can be shared between ports, action should be created on single port and the handle can be used in the templates and flows on multiple ports, example:

  flow configure 0 queues_number 1 queues_size 64 counters_number 64
  flow configure 1 queues_number 1 queues_size 64 counters_number 0 \
                   host_port 0 flags 1

flow indirect_action 0 create ingress action_id 0 action count / end

flow actions_template 0 create ingress actions_template_id 8
template indirect 0 / queue index 0 / end mask count / queue index 0 / end

flow actions_template 1 create ingress actions_template_id 18
template shared_indirect 0 0 / queue index 0 / end mask count / queue index 0 / end

---
 app/test-pmd/cmdline_flow.c | 53 ++++++++++++++++++++++++++++++++++++-
 1 file changed, 52 insertions(+), 1 deletion(-)
app/test-pmd/cmdline_flow.c +52 -1
index 7778828919..f2403622d6 100644
@@ -607,6 +607,8 @@ enum index {
 	ACTION_SAMPLE_INDEX,
 	ACTION_SAMPLE_INDEX_VALUE,
 	ACTION_INDIRECT,
+	ACTION_SHARED_INDIRECT,
+	INDIRECT_ACTION_PORT,
 	INDIRECT_ACTION_ID2PTR,
 	ACTION_MODIFY_FIELD,
 	ACTION_MODIFY_FIELD_OP,
@@ -1926,6 +1928,7 @@ static const enum index next_action[] = {
 	ACTION_AGE_UPDATE,
 	ACTION_SAMPLE,
 	ACTION_INDIRECT,
+	ACTION_SHARED_INDIRECT,
 	ACTION_MODIFY_FIELD,
 	ACTION_CONNTRACK,
 	ACTION_CONNTRACK_UPDATE,
@@ -2435,6 +2438,9 @@ static int parse_ia_destroy(struct context *ctx, const struct token *token,
 static int parse_ia_id2ptr(struct context *ctx, const struct token *token,
 			   const char *str, unsigned int len, void *buf,
 			   unsigned int size);
+static int parse_ia_port(struct context *ctx, const struct token *token,
+			 const char *str, unsigned int len, void *buf,
+			 unsigned int size);
 static int parse_mp(struct context *, const struct token *,
 		    const char *, unsigned int,
 		    void *, unsigned int);
@@ -6522,6 +6528,23 @@ static const struct token token_list[] = {
 		.args = ARGS(ARGS_ENTRY_ARB(0, sizeof(uint32_t))),
 		.call = parse_vc,
 	},
+	[ACTION_SHARED_INDIRECT] = {
+		.name = "shared_indirect",
+		.help = "apply indirect action by id and port",
+		.priv = PRIV_ACTION(INDIRECT, 0),
+		.next = NEXT(NEXT_ENTRY(INDIRECT_ACTION_PORT)),
+		.args = ARGS(ARGS_ENTRY_ARB(0, sizeof(uint32_t)),
+			     ARGS_ENTRY_ARB(0, sizeof(uint32_t))),
+		.call = parse_vc,
+	},
+	[INDIRECT_ACTION_PORT] = {
+		.name = "{indirect_action_port}",
+		.type = "INDIRECT_ACTION_PORT",
+		.help = "indirect action port",
+		.next = NEXT(NEXT_ENTRY(INDIRECT_ACTION_ID2PTR)),
+		.call = parse_ia_port,
+		.comp = comp_none,
+	},
 	[INDIRECT_ACTION_ID2PTR] = {
 		.name = "{action_id}",
 		.type = "INDIRECT_ACTION_ID",
@@ -10006,6 +10029,31 @@ parse_port(struct context *ctx, const struct token *token,
 	return ret;
 }
 
+/** Parse tokens for shared indirect actions. */
+static int
+parse_ia_port(struct context *ctx, const struct token *token,
+	      const char *str, unsigned int len,
+	      void *buf, unsigned int size)
+{
+	struct rte_flow_action *action = ctx->object;
+	uint32_t id;
+	int ret;
+
+	(void)buf;
+	(void)size;
+	ctx->objdata = 0;
+	ctx->object = &id;
+	ctx->objmask = NULL;
+	ret = parse_int(ctx, token, str, len, ctx->object, sizeof(id));
+	ctx->object = action;
+	if (ret != (int)len)
+		return ret;
+	/* set indirect action */
+	if (action)
+		action->conf = (void *)(uintptr_t)id;
+	return ret;
+}
+
 static int
 parse_ia_id2ptr(struct context *ctx, const struct token *token,
 		const char *str, unsigned int len,
@@ -10026,7 +10074,10 @@ parse_ia_id2ptr(struct context *ctx, const struct token *token,
 		return ret;
 	/* set indirect action */
 	if (action) {
-		action->conf = port_action_handle_get_by_id(ctx->port, id);
+		portid_t port_id = ctx->port;
+		if (ctx->prev == INDIRECT_ACTION_PORT)
+			port_id = (portid_t)(uintptr_t)action->conf;
+		action->conf = port_action_handle_get_by_id(port_id, id);
 		ret = (action->conf) ? ret : -1;
 	}
 	return ret;
Signature · 1 line
2.18.1
#38 lore raw

Re: [PATCH v3 0/3] *ethdev: sharing indirect actions between port*

In reply to Viacheslav Ovsiienko
Quoted 41 lines · Viacheslav Ovsiienko

The RTE Flow API implements the concept of shared objects, known as indirect actions (RTE_FLOW_ACTION_TYPE_INDIRECT). An application can create the indirect action of desired type and configuration with rte_flow_action_handle_create call and then specify the obtained action handle in multiple flows.

The initial concept supposes the action handle has strict attachment to the port it was created on and to be used exclusively in the flows being installed on the port.

Nowadays the multipath network topologies are quite common, packets belonging to the same connection might arrive and be sent over multiple ports, and there is the raising demand to handle these "spread" connections. To fulfil this demand it is proposed to extend indirect action sharing across the multiple ports. This kind of sharing would be extremely useful for the meters and counters, allowing to manage the single connection over the multiple ports.

This cross-port object sharing is hard to implement in generic way merely with software on the upper layers, but can be provided by the driver over the single hardware instance, where multiple ports reside on the same physical NIC and share the same hardware context.

To allow this action sharing application should specify the "host port" during flow configuring to claim the intention to share the indirect actions. All indirect actions reside within "host port" context and can be shared in flows being installed on the host port and on all the ports referencing this one.

If sharing between host and port being configured is not supported the configuration should be rejected with error. There might be multiple independent (mutual exclusive) sharing domains with dedicated host and referencing ports.

To manage the shared indirect action any port from sharing domain can be specified. To share or not the created action is up to application, no API change is needed.

Quoted 9 lines

Viacheslav Ovsiienko (3):
ethdev: sharing indirect actions between ports app/testpmd: add host port parameter into flow config app/testpmd: add shared indirect action support

Series applied to dpdk-next-net/main, thanks.

#39 lore raw

v4 cover net/mlx5: sharing indirect actions between port

In reply to Viacheslav Ovsiienko

Adds shared indirect action support to mlx5 PMD.

Erez Shitrit (2):
net/mlx5/hws: free FT from RTC ID before set the new value net/mlx5/hws: fix disconnecting matcher

Viacheslav Ovsiienko (3):
common/mlx5: add cross port object sharing capability net/mlx5: add cross port shared mode for HW steering net/mlx5: support counters in cross port shared mode

 drivers/common/mlx5/mlx5_devx_cmds.c  |  13 ++
 drivers/common/mlx5/mlx5_devx_cmds.h  |   1 +
 drivers/net/mlx5/hws/mlx5dr_matcher.c |  12 ++
 drivers/net/mlx5/mlx5.c               |   6 +
 drivers/net/mlx5/mlx5.h               |   2 +
 drivers/net/mlx5/mlx5_flow_hw.c       |  90 ++++++++++++--
 drivers/net/mlx5/mlx5_hws_cnt.c       | 167 ++++++++++++++------------
 drivers/net/mlx5/mlx5_hws_cnt.h       | 109 +++++++++--------
 8 files changed, 266 insertions(+), 134 deletions(-)
Signature · 10 lines
2.18.1

---
RFC: https://inbox.dpdk.org/dev/[email protected]/
v1:  https://inbox.dpdk.org/dev/[email protected]/
v2:  https://inbox.dpdk.org/dev/[email protected]/
     minor comilation issues, rebase, typos
v3:  series split to ethdev/testpmd and mlx5 PMD patch to be smoothly applied
     over dpdk-next/main. The mlx5 PMD seris is coming.
v4:  the remaining part of original series split for mlx5 PMD
#40 lore raw

PATCH v4 1/5 net/mlx5/hws: free FT from RTC ID before set the new value

From: Erez Shitrit <[email protected]>

While matcher is being connect/disconnect in shared gvmi flow we set the first ft in the table to point on the first matcher,
The FW is increasing the refcount on the first matcher RTC because of that no matcher if it is the same RTC that was set before, and when we will try to release that RTC we will get the following syndrome:
0xaa0093 - destroy_rtc_object: rtc in use or doesn't exist.

In order to resolve that we clean the current pointed RTC from that ft and only after that setting it to the new RTC value.

---
 drivers/net/mlx5/hws/mlx5dr_matcher.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
drivers/net/mlx5/hws/mlx5dr_matcher.c +18 -0
index 5508cfe230..6af493d87a 100644
@@ -334,6 +334,24 @@ static int mlx5dr_matcher_disconnect(struct mlx5dr_matcher *matcher)
 		return ret;
 	}
 
+	if (!next) {
+		/* ft no longer points to any RTC, drop refcount */
+		ret = mlx5dr_matcher_free_rtc_pointing(tbl->ctx,
+						       tbl->fw_ft_type,
+						       tbl->type,
+						       prev_ft);
+		if (ret) {
+			DR_LOG(ERR, "Failed to reset last RTC refcount");
+			return ret;
+		}
+	}
+
+	ret = mlx5dr_matcher_shared_update_local_ft(tbl);
+	if (ret) {
+		DR_LOG(ERR, "Failed to update local_ft in shared table");
+		return ret;
+	}
+
 	return 0;
 }
 
Signature · 1 line
2.18.1
#41 lore raw

PATCH v4 2/5 net/mlx5/hws: fix disconnecting matcher

In reply to Viacheslav Ovsiienko

From: Erez Shitrit <[email protected]>

This patch fixes the matcher disconnection handling, by removing the RTC references from flow table if the currently removed matcher was the last one for the given table. As a result RTC in this matcher can be correctly freed, since there are no dangling references to the RTC.

Fixes c467608215b2 ("net/mlx5/hws: add matcher object")
---
 drivers/net/mlx5/hws/mlx5dr_matcher.c | 6 ------
 1 file changed, 6 deletions(-)
drivers/net/mlx5/hws/mlx5dr_matcher.c +0 -6
index 6af493d87a..1fe7ec1bc3 100644
@@ -346,12 +346,6 @@ static int mlx5dr_matcher_disconnect(struct mlx5dr_matcher *matcher)
 		}
 	}
 
-	ret = mlx5dr_matcher_shared_update_local_ft(tbl);
-	if (ret) {
-		DR_LOG(ERR, "Failed to update local_ft in shared table");
-		return ret;
-	}
-
 	return 0;
 }
 
Signature · 1 line
2.18.1
#42 lore raw

PATCH v4 3/5 common/mlx5: add cross port object sharing capability

In reply to Viacheslav Ovsiienko

Add query port capabilities to share steering objects between multiple ports of the same physical NIC.

---
 drivers/common/mlx5/mlx5_devx_cmds.c | 13 +++++++++++++
 drivers/common/mlx5/mlx5_devx_cmds.h |  1 +
 2 files changed, 14 insertions(+)
drivers/common/mlx5/mlx5_devx_cmds.c +13 -0
index e3a4927d0f..17128035ec 100644
@@ -1047,6 +1047,19 @@ mlx5_devx_cmd_query_hca_attr(void *ctx,
 		attr->flow_counter_bulk_log_granularity =
 			MLX5_GET(cmd_hca_cap_2, hcattr,
 				 flow_counter_bulk_log_granularity);
+		rc = MLX5_GET(cmd_hca_cap_2, hcattr,
+			      cross_vhca_object_to_object_supported);
+		attr->cross_vhca =
+			(rc & MLX5_CROSS_VHCA_OBJ_TO_OBJ_TYPE_STC_TO_TIR) &&
+			(rc & MLX5_CROSS_VHCA_OBJ_TO_OBJ_TYPE_STC_TO_FT) &&
+			(rc & MLX5_CROSS_VHCA_OBJ_TO_OBJ_TYPE_FT_TO_FT) &&
+			(rc & MLX5_CROSS_VHCA_OBJ_TO_OBJ_TYPE_FT_TO_RTC);
+		rc = MLX5_GET(cmd_hca_cap_2, hcattr,
+			      allowed_object_for_other_vhca_access);
+		attr->cross_vhca = attr->cross_vhca &&
+			(rc & MLX5_CROSS_VHCA_ALLOWED_OBJS_TIR) &&
+			(rc & MLX5_CROSS_VHCA_ALLOWED_OBJS_FT) &&
+			(rc & MLX5_CROSS_VHCA_ALLOWED_OBJS_RTC);
 	}
 	if (attr->log_min_stride_wqe_sz == 0)
 		attr->log_min_stride_wqe_sz = MLX5_MPRQ_LOG_MIN_STRIDE_WQE_SIZE;
drivers/common/mlx5/mlx5_devx_cmds.h +1 -0
index c94b9eac06..b65ba569bc 100644
@@ -288,6 +288,7 @@ struct mlx5_hca_attr {
 	uint32_t alloc_flow_counter_pd:1;
 	uint32_t flow_counter_access_aso:1;
 	uint32_t flow_access_aso_opc_mod:8;
+	uint32_t cross_vhca:1;
 };
 
 /* LAG Context. */
Signature · 1 line
2.18.1
#43 lore raw

PATCH v4 4/5 net/mlx5: add cross port shared mode for HW steering

In reply to Viacheslav Ovsiienko

Add host port option for sharing steering objects between multiple ports of the same physical NIC.

---
 drivers/net/mlx5/mlx5.c         |  6 +++
 drivers/net/mlx5/mlx5.h         |  2 +
 drivers/net/mlx5/mlx5_flow_hw.c | 78 +++++++++++++++++++++++++++++++--
 drivers/net/mlx5/mlx5_hws_cnt.c | 12 +++++
 4 files changed, 94 insertions(+), 4 deletions(-)
drivers/net/mlx5/mlx5.c +6 -0
index b8643cebdd..2eca2cceef 100644
@@ -2013,6 +2013,12 @@ mlx5_dev_close(struct rte_eth_dev *dev)
 	}
 	if (!priv->sh)
 		return 0;
+	if (priv->shared_refcnt) {
+		DRV_LOG(ERR, "port %u is shared host in use (%u)",
+			dev->data->port_id, priv->shared_refcnt);
+		rte_errno = EBUSY;
+		return -EBUSY;
+	}
 	DRV_LOG(DEBUG, "port %u closing device \"%s\"",
 		dev->data->port_id,
 		((priv->sh->cdev->ctx != NULL) ?
drivers/net/mlx5/mlx5.h +2 -0
index 16b33e1548..525bdd47f7 100644
@@ -1780,6 +1780,8 @@ struct mlx5_priv {
 	struct mlx5_flow_hw_ctrl_rx *hw_ctrl_rx;
 	/**< HW steering templates used to create control flow rules. */
 #endif
+	struct rte_eth_dev *shared_host; /* Host device for HW steering. */
+	uint16_t shared_refcnt; /* HW steering host reference counter. */
 };
 
 #define PORT_ID(priv) ((priv)->dev_data->port_id)
drivers/net/mlx5/mlx5_flow_hw.c +74 -4

138 lines not on this page · raw message

drivers/net/mlx5/mlx5_hws_cnt.c +12 -0
index 05cc954903..797844439f 100644
@@ -619,6 +619,12 @@ mlx5_hws_cnt_pool_create(struct rte_eth_dev *dev,
 	int ret = 0;
 	size_t sz;
 
+	if (pattr->flags & RTE_FLOW_PORT_FLAG_SHARE_INDIRECT) {
+		DRV_LOG(ERR, "Counters are not supported "
+			     "in cross vHCA sharing mode");
+		rte_errno = ENOTSUP;
+		return NULL;
+	}
 	/* init cnt service if not. */
 	if (priv->sh->cnt_svc == NULL) {
 		ret = mlx5_hws_cnt_svc_init(priv->sh);
@@ -1190,6 +1196,12 @@ mlx5_hws_age_pool_init(struct rte_eth_dev *dev,
 
 	strict_queue = !!(attr->flags & RTE_FLOW_PORT_FLAG_STRICT_QUEUE);
 	MLX5_ASSERT(priv->hws_cpool);
+	if (attr->flags & RTE_FLOW_PORT_FLAG_SHARE_INDIRECT) {
+		DRV_LOG(ERR, "Aging sn not supported "
+			     "in cross vHCA sharing mode");
+		rte_errno = ENOTSUP;
+		return -ENOTSUP;
+	}
 	nb_alloc_cnts = mlx5_hws_cnt_pool_get_size(priv->hws_cpool);
 	if (strict_queue) {
 		rsize = mlx5_hws_aged_out_q_ring_size_get(nb_alloc_cnts,
Signature · 1 line
2.18.1
#44 lore raw

PATCH v4 5/5 net/mlx5: support counters in cross port shared mode

In reply to Viacheslav Ovsiienko

In the cross vHCA sharing mode the host counter pool should be used in counter related routines. The local port pool is used to store the dedicated DR action handle, per queue counter caches and query data are ignored and not allocated on local pool.

---
 drivers/net/mlx5/mlx5_flow_hw.c |  12 ++-
 drivers/net/mlx5/mlx5_hws_cnt.c | 163 ++++++++++++++++----------------
 drivers/net/mlx5/mlx5_hws_cnt.h | 109 +++++++++++----------
 3 files changed, 150 insertions(+), 134 deletions(-)
drivers/net/mlx5/mlx5_flow_hw.c +8 -4
index 3b9789aa53..8ff72871f3 100644
@@ -2311,8 +2311,10 @@ flow_hw_actions_construct(struct rte_eth_dev *dev,
 				break;
 			/* Fall-through. */
 		case RTE_FLOW_ACTION_TYPE_COUNT:
-			ret = mlx5_hws_cnt_pool_get(priv->hws_cpool, &queue,
-						    &cnt_id, age_idx);
+			ret = mlx5_hws_cnt_pool_get(priv->hws_cpool,
+					(priv->shared_refcnt ||
+					 priv->hws_cpool->cfg.host_cpool) ?
+					NULL : &queue, &cnt_id, age_idx);
 			if (ret != 0)
 				return ret;
 			ret = mlx5_hws_cnt_pool_get_action_offset
@@ -7998,6 +8000,7 @@ static int
 flow_hw_query_counter(const struct rte_eth_dev *dev, uint32_t counter,
 		      void *data, struct rte_flow_error *error)
 {
+	struct mlx5_hws_cnt_pool *hpool;
 	struct mlx5_priv *priv = dev->data->dev_private;
 	struct mlx5_hws_cnt *cnt;
 	struct rte_flow_query_count *qc = data;
@@ -8008,8 +8011,9 @@ flow_hw_query_counter(const struct rte_eth_dev *dev, uint32_t counter,
 		return rte_flow_error_set(error, EINVAL,
 				RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
 				"counter are not available");
-	iidx = mlx5_hws_cnt_iidx(priv->hws_cpool, counter);
-	cnt = &priv->hws_cpool->pool[iidx];
+	hpool = mlx5_hws_cnt_host_pool(priv->hws_cpool);
+	iidx = mlx5_hws_cnt_iidx(hpool, counter);
+	cnt = &hpool->pool[iidx];
 	__hws_cnt_query_raw(priv->hws_cpool, counter, &pkts, &bytes);
 	qc->hits_set = 1;
 	qc->bytes_set = 1;
drivers/net/mlx5/mlx5_hws_cnt.c +84 -79

267 lines not on this page · raw message

drivers/net/mlx5/mlx5_hws_cnt.h +58 -51

218 lines not on this page · raw message

Signature · 1 line
2.18.1
#45 lore raw

RE: [PATCH v4 0/5] net/mlx5: sharing indirect actions between port

In reply to Viacheslav Ovsiienko

Hi,

Quoted 32 lines

-----Original Message-----
From: Slava Ovsiienko <[email protected]>
Sent: Monday, February 13, 2023 3:38 PM
To: [email protected]
Cc: Ori Kam <[email protected]>; Raslan Darawsheh <[email protected]>; Matan Azrad <[email protected]>
Subject: [PATCH v4 0/5] net/mlx5: sharing indirect actions between port

Adds shared indirect action support to mlx5 PMD.

Erez Shitrit (2):
net/mlx5/hws: free FT from RTC ID before set the new value net/mlx5/hws: fix disconnecting matcher

Viacheslav Ovsiienko (3):
common/mlx5: add cross port object sharing capability net/mlx5: add cross port shared mode for HW steering net/mlx5: support counters in cross port shared mode

 drivers/common/mlx5/mlx5_devx_cmds.c  |  13 ++
 drivers/common/mlx5/mlx5_devx_cmds.h  |   1 +
 drivers/net/mlx5/hws/mlx5dr_matcher.c |  12 ++
 drivers/net/mlx5/mlx5.c               |   6 +
 drivers/net/mlx5/mlx5.h               |   2 +
 drivers/net/mlx5/mlx5_flow_hw.c       |  90 ++++++++++++--
 drivers/net/mlx5/mlx5_hws_cnt.c       | 167 ++++++++++++++------------
 drivers/net/mlx5/mlx5_hws_cnt.h       | 109 +++++++++--------
 8 files changed, 266 insertions(+), 134 deletions(-)

--
2.18.1

Quoted 12 lines

---
RFC: https://inbox.dpdk.org/dev/20221228165433.18185-1-
[email protected]/
v1: https://inbox.dpdk.org/dev/20230206095229.23027-1-
[email protected]/
v2: https://inbox.dpdk.org/dev/20230207140206.29139-1-
[email protected]/
minor comilation issues, rebase, typos
v3: series split to ethdev/testpmd and mlx5 PMD patch to be smoothly applied
over dpdk-next/main. The mlx5 PMD seris is coming.
v4: the remaining part of original series split for mlx5 PMD

Series applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh