Skip to contentSkip to conversation

ethdev: add send to kernel action

RFC In review Michael Savisko 5 participants 24 messages Aug 11, 2022 – Oct 4, 2022

lore
Share & tools
lore
#0 lore raw

RFC 1/1 ethdev: add send to kernel action

In some cases application may receive a packet that should have been received by the kernel. In this case application uses KNI or other means to transfer the packet to the kernel.
This commit introduces rte flow action that the application may use to route the packet to the kernel while still in the HW.

---
 lib/librte_ethdev/rte_flow.h | 5 +++++
 1 file changed, 5 insertions(+)
lib/librte_ethdev/rte_flow.h +5 -0
index f92bef0184..969a607115 100644
@@ -2853,6 +2853,11 @@ enum rte_flow_action_type {
 	 * See file rte_mtr.h for MTR profile object configuration.
 	 */
 	RTE_FLOW_ACTION_TYPE_METER_MARK,
+
+	/*
+	 * Send traffic to kernel.
+	 */
+	RTE_FLOW_ACTION_TYPE_SEND_TO_KERNEL,
 };
 
 /**
Signature · 1 line
2.27.0
Acked-by on v1 1/1
#1 lore raw
Quoted 33 lines

-----Original Message-----
From: Michael Savisko <[email protected]>
Sent: Thursday, 11 August 2022 14:36

In some cases application may receive a packet that should have been received by the kernel. In this case application uses KNI or other means to transfer the packet to the kernel.
This commit introduces rte flow action that the application may use to route the packet to the kernel while still in the HW.

---
 lib/librte_ethdev/rte_flow.h | 5 +++++
 1 file changed, 5 insertions(+)
lib/librte_ethdev/rte_flow.h +5 -1
index f92bef0184..969a607115 100644
@@ -2853,6 +2853,11 @@ enum rte_flow_action_type {
 	 * See file rte_mtr.h for MTR profile object configuration.
 	 */
 	RTE_FLOW_ACTION_TYPE_METER_MARK,
+
+	/*
+	 * Send traffic to kernel.
+	 */
+	RTE_FLOW_ACTION_TYPE_SEND_TO_KERNEL,
 };
 
 /**
--
Quoted 1 line

2.27.0

Best,
Ori

#2 lore raw
In reply to Michael Savisko
Quoted 10 lines · Michael Savisko

CAUTION: This message has originated from an External Source. Please use proper judgment and caution when opening attachments, clicking links, or responding to this email.

In some cases application may receive a packet that should have been received by the kernel. In this case application uses KNI or other means to transfer the packet to the kernel.
This commit introduces rte flow action that the application may use to route the packet to the kernel while still in the HW.

I assume this only works for bifurcated drivers, right?

#3 lore raw

16/08/2022 11:50, Ferruh Yigit:

Quoted 10 lines · Michael Savisko
Quoted 9 lines

CAUTION: This message has originated from an External Source. Please use proper judgment and caution when opening attachments, clicking links, or responding to this email.

In some cases application may receive a packet that should have been received by the kernel. In this case application uses KNI or other means to transfer the packet to the kernel.
This commit introduces rte flow action that the application may use to route the packet to the kernel while still in the HW.

Quoted 3 lines
Quoted 1 line

I assume this only works for bifurcated drivers, right?

This question has not been replied after a month.
Please let's be more reactive.

#4 lore raw

I replied to it the same day but unfortunately only to the author (see attached). My apologies.

Here's the answer:
"Depends on HW. If it can forward packets to different places then it can also be supported. But in most cases yes - for bifurcated drivers."

Regards,
Michael

-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Monday, 12 September 2022 16:33
To: Michael Savisko <[email protected]>; Ori Kam <[email protected]>
Cc: [email protected]; [email protected]; Ferruh Yigit <[email protected]>; Slava Ovsiienko <[email protected]>
Subject: Re: [RFC] ethdev: add send to kernel action

16/08/2022 11:50, Ferruh Yigit:

Quoted 10 lines · Michael Savisko
Quoted 9 lines

CAUTION: This message has originated from an External Source. Please use proper judgment and caution when opening attachments, clicking links, or responding to this email.

In some cases application may receive a packet that should have been received by the kernel. In this case application uses KNI or other means to transfer the packet to the kernel.
This commit introduces rte flow action that the application may use to route the packet to the kernel while still in the HW.

Quoted 3 lines
Quoted 1 line

I assume this only works for bifurcated drivers, right?

This question has not been replied after a month.
Please let's be more reactive.

Depends on HW. If it can forward packets to different places then it can also be supported. But in most cases yes - for bifurcated drivers.

-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Tuesday, August 16, 2022 12:51 PM
To: Michael Savisko <[email protected]>; Ori Kam <[email protected]>; [email protected]
Cc: [email protected]
Subject: Re: [RFC] ethdev: add send to kernel action

Quoted 10 lines · Michael Savisko

CAUTION: This message has originated from an External Source. Please use proper judgment and caution when opening attachments, clicking links, or responding to this email.

In some cases application may receive a packet that should have been received by the kernel. In this case application uses KNI or other means to transfer the packet to the kernel.
This commit introduces rte flow action that the application may use to route the packet to the kernel while still in the HW.

I assume this only works for bifurcated drivers, right?

#5 lore raw
Quoted 16 lines · Michael Savisko
Quoted 16 lines

-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Monday, 12 September 2022 16:33
To: Michael Savisko <[email protected]>; Ori Kam <[email protected]>
Cc: [email protected]; [email protected]; Ferruh Yigit <[email protected]>; Slava Ovsiienko <[email protected]>
Subject: Re: [RFC] ethdev: add send to kernel action

16/08/2022 11:50, Ferruh Yigit:

Quoted 8 lines · Michael Savisko
Quoted 7 lines

In some cases application may receive a packet that should have been received by the kernel. In this case application uses KNI or other means to transfer the packet to the kernel.
This commit introduces rte flow action that the application may use to route the packet to the kernel while still in the HW.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Quoted 1 line

I assume this only works for bifurcated drivers, right?

This question has not been replied after a month.
Please let's be more reactive.

Depends on HW. If it can forward packets to different places then it can also be supported. But in most cases yes - for bifurcated drivers.

The action sounds like "do some magic". As far as I know we have no concept of kernel and cooperation with the kernel in DPDK yet.

Is it a transfer or non-transfer action?
I guess non-transfer, since otherwise the next question is which kernel...

In the case of non-transfer DPDK has a concept of Rx queues which are used to deliver traffic to and we have QUEUE and RSS flow actions to do it.

The patch adds some magic direction "kernel". Don't we want to control destination queue? RSS?
May be we need dedicated control steps to setup kernel Rx queues and than use QUEUE/RSS to direct traffic there?

#6 lore raw
Quoted 23 lines

-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Monday, 12 September 2022 17:41

Quoted 17 lines · Michael Savisko
Quoted 17 lines

-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Monday, 12 September 2022 16:33

16/08/2022 11:50, Ferruh Yigit:

Quoted 11 lines · Michael Savisko
Quoted 8 lines

In some cases application may receive a packet that should have been received by the kernel. In this case application uses KNI or other means to transfer the packet to the kernel.
This commit introduces rte flow action that the application may use to route the packet to the kernel while still in the HW.

I assume this only works for bifurcated drivers, right?

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

This question has not been replied after a month.
Please let's be more reactive.

Depends on HW. If it can forward packets to different places then it can also

be supported. But in most cases yes - for bifurcated drivers.

The action sounds like "do some magic". As far as I know we have no concept of kernel and cooperation with the kernel in DPDK yet.

There's nothing "magical". Kernel is not a part of DPDK, but DPDK can use KNI to transfer messages between application and kernel.
With bifurcated driver we can have a rule to route the packet matching a pattern (example: IPv4 packets) to the DPDK application and the rest of the traffic will be received by the kernel. But if we want to receive most of the traffic in DPDK except specific pattern (example: ICMP packets) that should be processed by the kernel, then it's easier to re-route these packets with a single rule. The new action I'm suggesting allows application to route packets directly to the kernel without software involvement, it is a HW offload.
We see it used when working with bifurcated driver, because the kernel driver and the DPDK driver are sharing the same HW.

Quoted 2 lines

Is it a transfer or non-transfer action?
I guess non-transfer, since otherwise the next question is which kernel...

This is an ingress action only.

Quoted 2 lines

In the case of non-transfer DPDK has a concept of Rx queues which are used to deliver traffic to and we have QUEUE and RSS flow actions to do it.

The idea of this offload action is to route traffic away from the DPDK application.

Quoted 4 lines

The patch adds some magic direction "kernel". Don't we want to control destination queue? RSS?
May be we need dedicated control steps to setup kernel Rx queues and than use QUEUE/RSS to direct traffic there?

We have no control of how the kernel is configured.

I will provide a new version of the patch with better documentation. Please feel free to suggest any wording.

Thank you,
Michael

#7 lore raw

13/09/2022 14:09, Michael Savisko:

Quoted 31 lines

From: Andrew Rybchenko <[email protected]>

Quoted 15 lines · Michael Savisko
Quoted 14 lines

From: Thomas Monjalon <[email protected]>

Quoted 13 lines

16/08/2022 11:50, Ferruh Yigit:

Quoted 11 lines · Michael Savisko
Quoted 8 lines

In some cases application may receive a packet that should have been received by the kernel. In this case application uses KNI or other means to transfer the packet to the kernel.
This commit introduces rte flow action that the application may use to route the packet to the kernel while still in the HW.

I assume this only works for bifurcated drivers, right?

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

This question has not been replied after a month.
Please let's be more reactive.

Depends on HW. If it can forward packets to different places then it can also

be supported. But in most cases yes - for bifurcated drivers.

The action sounds like "do some magic". As far as I know we have no concept of kernel and cooperation with the kernel in DPDK yet.

There's nothing "magical". Kernel is not a part of DPDK, but DPDK can use KNI to transfer messages between application and kernel.
With bifurcated driver we can have a rule to route the packet matching a pattern (example: IPv4 packets) to the DPDK application and the rest of the traffic will be received by the kernel. But if we want to receive most of the traffic in DPDK except specific pattern (example: ICMP packets) that should be processed by the kernel, then it's easier to re-route these packets with a single rule. The new action I'm suggesting allows application to route packets directly to the kernel without software involvement, it is a HW offload.
We see it used when working with bifurcated driver, because the kernel driver and the DPDK driver are sharing the same HW.

Quoted 4 lines
Quoted 2 lines

Is it a transfer or non-transfer action?
I guess non-transfer, since otherwise the next question is which kernel...

This is an ingress action only.

Should we add this note in the doxygen comment?
This is the wording in the v2 sent today:

+ /*

+        * Send packets to the kernel, without going to userspace at all.
+        * The packets will be received by the kernel driver sharing
+        * the same device as the DPDK port.
+        *
+        * No associated configuration structure.
+        */

+ RTE_FLOW_ACTION_TYPE_SEND_TO_KERNEL,

Quoted 11 lines
Quoted 2 lines

In the case of non-transfer DPDK has a concept of Rx queues which are used to deliver traffic to and we have QUEUE and RSS flow actions to do it.

The idea of this offload action is to route traffic away from the DPDK application.

Quoted 4 lines

The patch adds some magic direction "kernel". Don't we want to control destination queue? RSS?
May be we need dedicated control steps to setup kernel Rx queues and than use QUEUE/RSS to direct traffic there?

We have no control of how the kernel is configured.

#8 lore raw

PATCH v2 1/1 ethdev: add send to kernel action

In reply to Michael Savisko

In some cases application may receive a packet that should have been received by the kernel. In this case application uses KNI or other means to transfer the packet to the kernel.

With bifurcated driver we can have a rule to route packets matching a pattern (example: IPv4 packets) to the DPDK application and the rest of the traffic will be received by the kernel.
But if we want to receive most of the traffic in DPDK except specific pattern (example: ICMP packets) that should be processed by the kernel, then it's easier to re-route these packets with a single rule.

This commit introduces new rte_flow action which allows application to re-route packets directly to the kernel without software involvement.

Add new testpmd rte_flow action 'send_to_kernel'. The application may use this action to route the packet to the kernel while still in the HW.

Example with testpmd command:

flow create 0 ingress priority 0 group 1 pattern eth type spec 0x0800 type mask 0xffff / end actions send_to_kernel / end

---
 app/test-pmd/cmdline_flow.c                 | 9 +++++++++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst | 2 ++
 lib/ethdev/rte_flow.c                       | 1 +
 lib/ethdev/rte_flow.h                       | 9 +++++++++
 4 files changed, 21 insertions(+)
app/test-pmd/cmdline_flow.c +9 -0
index 7f50028eb7..042f6b34a6 100644
@@ -612,6 +612,7 @@ enum index {
 	ACTION_PORT_REPRESENTOR_PORT_ID,
 	ACTION_REPRESENTED_PORT,
 	ACTION_REPRESENTED_PORT_ETHDEV_PORT_ID,
+	ACTION_SEND_TO_KERNEL,
 };
 
 /** Maximum size for pattern in struct rte_flow_item_raw. */
@@ -1872,6 +1873,7 @@ static const enum index next_action[] = {
 	ACTION_CONNTRACK_UPDATE,
 	ACTION_PORT_REPRESENTOR,
 	ACTION_REPRESENTED_PORT,
+	ACTION_SEND_TO_KERNEL,
 	ZERO,
 };
 
@@ -6341,6 +6343,13 @@ static const struct token token_list[] = {
 		.help = "submit a list of associated actions for red",
 		.next = NEXT(next_action),
 	},
+	[ACTION_SEND_TO_KERNEL] = {
+		.name = "send_to_kernel",
+		.help = "send packets to kernel",
+		.priv = PRIV_ACTION(SEND_TO_KERNEL, 0),
+		.next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
+		.call = parse_vc,
+	},
 
 	/* Top-level command. */
 	[ADD] = {
doc/guides/testpmd_app_ug/testpmd_funcs.rst +2 -0
index 330e34427d..c259c8239a 100644
@@ -4189,6 +4189,8 @@ This section lists supported actions and their attributes, if any.
 
   - ``ethdev_port_id {unsigned}``: ethdev port ID
 
+- ``send_to_kernel``: send packets to kernel.
+
 Destroying flow rules
 ~~~~~~~~~~~~~~~~~~~~~
 
lib/ethdev/rte_flow.c +1 -0
index 501be9d602..627c671ce4 100644
@@ -259,6 +259,7 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = {
 	MK_FLOW_ACTION(CONNTRACK, sizeof(struct rte_flow_action_conntrack)),
 	MK_FLOW_ACTION(PORT_REPRESENTOR, sizeof(struct rte_flow_action_ethdev)),
 	MK_FLOW_ACTION(REPRESENTED_PORT, sizeof(struct rte_flow_action_ethdev)),
+	MK_FLOW_ACTION(SEND_TO_KERNEL, 0),
 };
 
 int
lib/ethdev/rte_flow.h +9 -0
index a79f1e7ef0..a82992a6ae 100644
@@ -2879,6 +2879,15 @@ enum rte_flow_action_type {
 	 * @see struct rte_flow_action_ethdev
 	 */
 	RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT,
+
+	/*
+	 * Send packets to the kernel, without going to userspace at all.
+	 * The packets will be received by the kernel driver sharing
+	 * the same device as the DPDK port.
+	 *
+	 * No associated configuration structure.
+	 */
+	RTE_FLOW_ACTION_TYPE_SEND_TO_KERNEL,
 };
 
 /**
Signature · 1 line
2.27.0
#9 lore raw

PATCH v3 1/1 ethdev: add send to kernel action

In some cases application may receive a packet that should have been received by the kernel. In this case application uses KNI or other means to transfer the packet to the kernel.

With bifurcated driver we can have a rule to route packets matching a pattern (example: IPv4 packets) to the DPDK application and the rest of the traffic will be received by the kernel.
But if we want to receive most of the traffic in DPDK except specific pattern (example: ICMP packets) that should be processed by the kernel, then it's easier to re-route these packets with a single rule.

This commit introduces new rte_flow action which allows application to re-route packets directly to the kernel without software involvement.

Add new testpmd rte_flow action 'send_to_kernel'. The application may use this action to route the packet to the kernel while still in the HW.

Example with testpmd command:

flow create 0 ingress priority 0 group 1 pattern eth type spec 0x0800 type mask 0xffff / end actions send_to_kernel / end

---
 app/test-pmd/cmdline_flow.c                 |  9 +++++++++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  2 ++
 lib/ethdev/rte_flow.c                       |  1 +
 lib/ethdev/rte_flow.h                       | 10 ++++++++++
 4 files changed, 22 insertions(+)
app/test-pmd/cmdline_flow.c +9 -0
index 7f50028eb7..042f6b34a6 100644
@@ -612,6 +612,7 @@ enum index {
 	ACTION_PORT_REPRESENTOR_PORT_ID,
 	ACTION_REPRESENTED_PORT,
 	ACTION_REPRESENTED_PORT_ETHDEV_PORT_ID,
+	ACTION_SEND_TO_KERNEL,
 };
 
 /** Maximum size for pattern in struct rte_flow_item_raw. */
@@ -1872,6 +1873,7 @@ static const enum index next_action[] = {
 	ACTION_CONNTRACK_UPDATE,
 	ACTION_PORT_REPRESENTOR,
 	ACTION_REPRESENTED_PORT,
+	ACTION_SEND_TO_KERNEL,
 	ZERO,
 };
 
@@ -6341,6 +6343,13 @@ static const struct token token_list[] = {
 		.help = "submit a list of associated actions for red",
 		.next = NEXT(next_action),
 	},
+	[ACTION_SEND_TO_KERNEL] = {
+		.name = "send_to_kernel",
+		.help = "send packets to kernel",
+		.priv = PRIV_ACTION(SEND_TO_KERNEL, 0),
+		.next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
+		.call = parse_vc,
+	},
 
 	/* Top-level command. */
 	[ADD] = {
doc/guides/testpmd_app_ug/testpmd_funcs.rst +2 -0
index 330e34427d..c259c8239a 100644
@@ -4189,6 +4189,8 @@ This section lists supported actions and their attributes, if any.
 
   - ``ethdev_port_id {unsigned}``: ethdev port ID
 
+- ``send_to_kernel``: send packets to kernel.
+
 Destroying flow rules
 ~~~~~~~~~~~~~~~~~~~~~
 
lib/ethdev/rte_flow.c +1 -0
index 501be9d602..627c671ce4 100644
@@ -259,6 +259,7 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = {
 	MK_FLOW_ACTION(CONNTRACK, sizeof(struct rte_flow_action_conntrack)),
 	MK_FLOW_ACTION(PORT_REPRESENTOR, sizeof(struct rte_flow_action_ethdev)),
 	MK_FLOW_ACTION(REPRESENTED_PORT, sizeof(struct rte_flow_action_ethdev)),
+	MK_FLOW_ACTION(SEND_TO_KERNEL, 0),
 };
 
 int
lib/ethdev/rte_flow.h +10 -0
index a79f1e7ef0..bf076087b3 100644
@@ -2879,6 +2879,16 @@ enum rte_flow_action_type {
 	 * @see struct rte_flow_action_ethdev
 	 */
 	RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT,
+
+	/**
+	 * Send packets to the kernel, without going to userspace at all.
+	 * The packets will be received by the kernel driver sharing
+	 * the same device as the DPDK port.
+	 * This is an ingress action only.
+	 *
+	 * No associated configuration structure.
+	 */
+	RTE_FLOW_ACTION_TYPE_SEND_TO_KERNEL,
 };
 
 /**
Signature · 1 line
2.27.0
Acked-by on v3 1/1
#10 lore raw

Hi Michael

Quoted 122 lines

-----Original Message-----
From: Michael Savisko <[email protected]>
Sent: Monday, 19 September 2022 18:50

In some cases application may receive a packet that should have been received by the kernel. In this case application uses KNI or other means to transfer the packet to the kernel.

With bifurcated driver we can have a rule to route packets matching a pattern (example: IPv4 packets) to the DPDK application and the rest of the traffic will be received by the kernel.
But if we want to receive most of the traffic in DPDK except specific pattern (example: ICMP packets) that should be processed by the kernel, then it's easier to re-route these packets with a single rule.

This commit introduces new rte_flow action which allows application to re-route packets directly to the kernel without software involvement.

Add new testpmd rte_flow action 'send_to_kernel'. The application may use this action to route the packet to the kernel while still in the HW.

Example with testpmd command:

flow create 0 ingress priority 0 group 1 pattern eth type spec 0x0800 type mask 0xffff / end actions send_to_kernel / end

---
 app/test-pmd/cmdline_flow.c                 |  9 +++++++++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  2 ++
 lib/ethdev/rte_flow.c                       |  1 +
 lib/ethdev/rte_flow.h                       | 10 ++++++++++
 4 files changed, 22 insertions(+)
app/test-pmd/cmdline_flow.c +9 -0
index 7f50028eb7..042f6b34a6 100644
@@ -612,6 +612,7 @@ enum index {
 	ACTION_PORT_REPRESENTOR_PORT_ID,
 	ACTION_REPRESENTED_PORT,
 	ACTION_REPRESENTED_PORT_ETHDEV_PORT_ID,
+	ACTION_SEND_TO_KERNEL,
 };
 
 /** Maximum size for pattern in struct rte_flow_item_raw. */
@@ -1872,6 +1873,7 @@ static const enum index next_action[] = {
 	ACTION_CONNTRACK_UPDATE,
 	ACTION_PORT_REPRESENTOR,
 	ACTION_REPRESENTED_PORT,
+	ACTION_SEND_TO_KERNEL,
 	ZERO,
 };
 
@@ -6341,6 +6343,13 @@ static const struct token token_list[] = {
 		.help = "submit a list of associated actions for red",
 		.next = NEXT(next_action),
 	},
+	[ACTION_SEND_TO_KERNEL] = {
+		.name = "send_to_kernel",
+		.help = "send packets to kernel",
+		.priv = PRIV_ACTION(SEND_TO_KERNEL, 0),
+		.next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
+		.call = parse_vc,
+	},
 
 	/* Top-level command. */
 	[ADD] = {
doc/guides/testpmd_app_ug/testpmd_funcs.rst +0 -0
index 330e34427d..c259c8239a 100644
@@ -4189,6 +4189,8 @@ This section lists supported actions and their

attributes, if any.

- ``ethdev_port_id {unsigned}``: ethdev port ID

+- ``send_to_kernel``: send packets to kernel.

doc/guides/testpmd_app_ug/testpmd_funcs.rst +1 -0
+
 Destroying flow rules
 ~~~~~~~~~~~~~~~~~~~~~
lib/ethdev/rte_flow.c +0 -0
index 501be9d602..627c671ce4 100644
@@ -259,6 +259,7 @@ static const struct rte_flow_desc_data
 rte_flow_desc_action[] = {
 	MK_FLOW_ACTION(CONNTRACK, sizeof(struct
 rte_flow_action_conntrack)),
 	MK_FLOW_ACTION(PORT_REPRESENTOR, sizeof(struct
 rte_flow_action_ethdev)),
 	MK_FLOW_ACTION(REPRESENTED_PORT, sizeof(struct

rte_flow_action_ethdev)),

lib/ethdev/rte_flow.c +1 -0
+	MK_FLOW_ACTION(SEND_TO_KERNEL, 0),
 };
 
 int
lib/ethdev/rte_flow.h +10 -1
index a79f1e7ef0..bf076087b3 100644
@@ -2879,6 +2879,16 @@ enum rte_flow_action_type {
 	 * @see struct rte_flow_action_ethdev
 	 */
 	RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT,
+
+	/**
+	 * Send packets to the kernel, without going to userspace at all.
+	 * The packets will be received by the kernel driver sharing
+	 * the same device as the DPDK port.
+	 * This is an ingress action only.
+	 *
+	 * No associated configuration structure.
+	 */
+	RTE_FLOW_ACTION_TYPE_SEND_TO_KERNEL,
 };
 
 /**
--
Quoted 1 line

2.27.0

Best,
Ori

#11 lore raw
In reply to Michael Savisko
Quoted 95 lines · Michael Savisko

In some cases application may receive a packet that should have been received by the kernel. In this case application uses KNI or other means to transfer the packet to the kernel.

With bifurcated driver we can have a rule to route packets matching a pattern (example: IPv4 packets) to the DPDK application and the rest of the traffic will be received by the kernel.
But if we want to receive most of the traffic in DPDK except specific pattern (example: ICMP packets) that should be processed by the kernel, then it's easier to re-route these packets with a single rule.

This commit introduces new rte_flow action which allows application to re-route packets directly to the kernel without software involvement.

Add new testpmd rte_flow action 'send_to_kernel'. The application may use this action to route the packet to the kernel while still in the HW.

Example with testpmd command:

flow create 0 ingress priority 0 group 1 pattern eth type spec 0x0800 type mask 0xffff / end actions send_to_kernel / end

---
  app/test-pmd/cmdline_flow.c                 |  9 +++++++++
  doc/guides/testpmd_app_ug/testpmd_funcs.rst |  2 ++
  lib/ethdev/rte_flow.c                       |  1 +
  lib/ethdev/rte_flow.h                       | 10 ++++++++++
  4 files changed, 22 insertions(+)
app/test-pmd/cmdline_flow.c +9 -0
index 7f50028eb7..042f6b34a6 100644
@@ -612,6 +612,7 @@ enum index {
  	ACTION_PORT_REPRESENTOR_PORT_ID,
  	ACTION_REPRESENTED_PORT,
  	ACTION_REPRESENTED_PORT_ETHDEV_PORT_ID,
+	ACTION_SEND_TO_KERNEL,
  };
 
  /** Maximum size for pattern in struct rte_flow_item_raw. */
@@ -1872,6 +1873,7 @@ static const enum index next_action[] = {
  	ACTION_CONNTRACK_UPDATE,
  	ACTION_PORT_REPRESENTOR,
  	ACTION_REPRESENTED_PORT,
+	ACTION_SEND_TO_KERNEL,
  	ZERO,
  };
 
@@ -6341,6 +6343,13 @@ static const struct token token_list[] = {
  		.help = "submit a list of associated actions for red",
  		.next = NEXT(next_action),
  	},
+	[ACTION_SEND_TO_KERNEL] = {
+		.name = "send_to_kernel",
+		.help = "send packets to kernel",
+		.priv = PRIV_ACTION(SEND_TO_KERNEL, 0),
+		.next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
+		.call = parse_vc,
+	},
 
  	/* Top-level command. */
  	[ADD] = {
doc/guides/testpmd_app_ug/testpmd_funcs.rst +2 -0
index 330e34427d..c259c8239a 100644
@@ -4189,6 +4189,8 @@ This section lists supported actions and their attributes, if any.
 
    - ``ethdev_port_id {unsigned}``: ethdev port ID
 
+- ``send_to_kernel``: send packets to kernel.
+
  Destroying flow rules
  ~~~~~~~~~~~~~~~~~~~~~
 
lib/ethdev/rte_flow.c +1 -0
index 501be9d602..627c671ce4 100644
@@ -259,6 +259,7 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = {
  	MK_FLOW_ACTION(CONNTRACK, sizeof(struct rte_flow_action_conntrack)),
  	MK_FLOW_ACTION(PORT_REPRESENTOR, sizeof(struct rte_flow_action_ethdev)),
  	MK_FLOW_ACTION(REPRESENTED_PORT, sizeof(struct rte_flow_action_ethdev)),
+	MK_FLOW_ACTION(SEND_TO_KERNEL, 0),
  };
 
  int
lib/ethdev/rte_flow.h +0 -0
index a79f1e7ef0..bf076087b3 100644

lib/ethdev/rte_flow.h enum rte_flow_action_type { · line 2885

Quoted 7 lines
lib/ethdev/rte_flow.h +4 -0
@@ -2879,6 +2879,16 @@ enum rte_flow_action_type {
  	 * @see struct rte_flow_action_ethdev
  	 */
  	RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT,
+
+	/**
+	 * Send packets to the kernel, without going to userspace at all.
+	 * The packets will be received by the kernel driver sharing

May be it is better to mentioned bifurcated driver model and add a reference to the documentation.

lib/ethdev/rte_flow.h enum rte_flow_action_type { · line 2886

Quoted 1 line
lib/ethdev/rte_flow.h +1 -0
+	 * the same device as the DPDK port.

Which DPDK port? There is no control structure associated with the action.

I guess it is the port used to create the flow rule. If so, it should be documented that it is non-transfer action and highlighted that the port used to create the action.

Quoted 8 lines
lib/ethdev/rte_flow.h +5 -0
+	 * This is an ingress action only.
+	 *
+	 * No associated configuration structure.
+	 */
+	RTE_FLOW_ACTION_TYPE_SEND_TO_KERNEL,
  };
 
  /**
#12 lore raw
Quoted 101 lines

-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Monday, 26 September 2022 16:07

doc/guides/testpmd_app_ug/testpmd_funcs.rst This section lists supported actions and their

Quoted 71 lines · Michael Savisko

In some cases application may receive a packet that should have been received by the kernel. In this case application uses KNI or other means to transfer the packet to the kernel.

With bifurcated driver we can have a rule to route packets matching a pattern (example: IPv4 packets) to the DPDK application and the rest of the traffic will be received by the kernel.
But if we want to receive most of the traffic in DPDK except specific pattern (example: ICMP packets) that should be processed by the kernel, then it's easier to re-route these packets with a single rule.

This commit introduces new rte_flow action which allows application to re-route packets directly to the kernel without software involvement.

Add new testpmd rte_flow action 'send_to_kernel'. The application may use this action to route the packet to the kernel while still in the HW.

Example with testpmd command:

flow create 0 ingress priority 0 group 1 pattern eth type spec 0x0800 type mask 0xffff / end actions send_to_kernel / end

---
  app/test-pmd/cmdline_flow.c                 |  9 +++++++++
  doc/guides/testpmd_app_ug/testpmd_funcs.rst |  2 ++
  lib/ethdev/rte_flow.c                       |  1 +
  lib/ethdev/rte_flow.h                       | 10 ++++++++++
  4 files changed, 22 insertions(+)
app/test-pmd/cmdline_flow.c +9 -1
index 7f50028eb7..042f6b34a6 100644
@@ -612,6 +612,7 @@ enum index {
  	ACTION_PORT_REPRESENTOR_PORT_ID,
  	ACTION_REPRESENTED_PORT,
  	ACTION_REPRESENTED_PORT_ETHDEV_PORT_ID,
+	ACTION_SEND_TO_KERNEL,
  };
 
  /** Maximum size for pattern in struct rte_flow_item_raw. */ @@
-1872,6 +1873,7 @@ static const enum index next_action[] = {
  	ACTION_CONNTRACK_UPDATE,
  	ACTION_PORT_REPRESENTOR,
  	ACTION_REPRESENTED_PORT,
+	ACTION_SEND_TO_KERNEL,
  	ZERO,
  };
@@ -6341,6 +6343,13 @@ static const struct token token_list[] = {
  		.help = "submit a list of associated actions for red",
  		.next = NEXT(next_action),
  	},
+	[ACTION_SEND_TO_KERNEL] = {
+		.name = "send_to_kernel",
+		.help = "send packets to kernel",
+		.priv = PRIV_ACTION(SEND_TO_KERNEL, 0),
+		.next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
+		.call = parse_vc,
+	},
 
  	/* Top-level command. */
  	[ADD] = {
doc/guides/testpmd_app_ug/testpmd_funcs.rst +0 -0
index 330e34427d..c259c8239a 100644
@@ -4189,6 +4189,8 @@ This section lists supported actions and their

attributes, if any.

lib/ethdev/rte_flow.c static const struct rte_flow_desc_data

Quoted 13 lines
doc/guides/testpmd_app_ug/testpmd_funcs.rst +2 -0
    - ``ethdev_port_id {unsigned}``: ethdev port ID
 
+- ``send_to_kernel``: send packets to kernel.
+
  Destroying flow rules
  ~~~~~~~~~~~~~~~~~~~~~
 
lib/ethdev/rte_flow.c index renamed from lib/ethdev/rte_flow.c +0 -0

501be9d602..627c671ce4 100644

lib/ethdev/rte_flow.c +0 -0
@@ -259,6 +259,7 @@ static const struct rte_flow_desc_data

rte_flow_desc_action[] = {

lib/ethdev/rte_flow.c static const struct rte_flow_desc_data · line 259

Quoted 1 line
lib/ethdev/rte_flow.c +0 -0
  	MK_FLOW_ACTION(CONNTRACK, sizeof(struct

rte_flow_action_conntrack)),

lib/ethdev/rte_flow.c static const struct rte_flow_desc_data · line 260

Quoted 1 line
lib/ethdev/rte_flow.c +0 -0
  	MK_FLOW_ACTION(PORT_REPRESENTOR, sizeof(struct

rte_flow_action_ethdev)),

Quoted 5 lines
lib/ethdev/rte_flow.c +1 -0
  	MK_FLOW_ACTION(REPRESENTED_PORT, sizeof(struct
 rte_flow_action_ethdev)),
+	MK_FLOW_ACTION(SEND_TO_KERNEL, 0),
  };
 
Quoted 16 lines

lib/ethdev/rte_flow.h enum rte_flow_action_type { · line 2885

Quoted 13 lines

int

lib/ethdev/rte_flow.h index renamed from lib/ethdev/rte_flow.h +0 -0

a79f1e7ef0..bf076087b3 100644

lib/ethdev/rte_flow.h +4 -0
@@ -2879,6 +2879,16 @@ enum rte_flow_action_type {
  	 * @see struct rte_flow_action_ethdev
  	 */
  	RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT,
+
+	/**
+	 * Send packets to the kernel, without going to userspace at all.
+	 * The packets will be received by the kernel driver sharing

May be it is better to mentioned bifurcated driver model and add a reference to the documentation.

Yes, I will add mentioning bifurcated driver model.

Quoted 8 lines

lib/ethdev/rte_flow.h enum rte_flow_action_type { · line 2886

Quoted 2 lines
lib/ethdev/rte_flow.h +1 -0
+	 * the same device as the DPDK port.

Which DPDK port? There is no control structure associated with the action.

I guess it is the port used to create the flow rule.
If so, it should be documented that it is non-transfer action and highlighted that the port used to create the action.

Yes, its is the port used to create the flow rule. I will add this to the comment. I will emphasize that it's non-transfer action as well.

I will provide a new version of the patch with better documentation.

Thank you,
Michael Savisko

Quoted 9 lines
Quoted 9 lines
lib/ethdev/rte_flow.h +5 -0
+	 * This is an ingress action only.
+	 *
+	 * No associated configuration structure.
+	 */
+	RTE_FLOW_ACTION_TYPE_SEND_TO_KERNEL,
  };
 
  /**
#13 lore raw

PATCH v4 1/1 ethdev: add send to kernel action

In reply to Michael Savisko

In some cases application may receive a packet that should have been received by the kernel. In this case application uses KNI or other means to transfer the packet to the kernel.

With bifurcated driver we can have a rule to route packets matching a pattern (example: IPv4 packets) to the DPDK application and the rest of the traffic will be received by the kernel.
But if we want to receive most of the traffic in DPDK except specific pattern (example: ICMP packets) that should be processed by the kernel, then it's easier to re-route these packets with a single rule.

This commit introduces new rte_flow action which allows application to re-route packets directly to the kernel without software involvement.

Add new testpmd rte_flow action 'send_to_kernel'. The application may use this action to route the packet to the kernel while still in the HW.

Example with testpmd command:

flow create 0 ingress priority 0 group 1 pattern eth type spec 0x0800 type mask 0xffff / end actions send_to_kernel / end

---
v4:
- improve description comment above RTE_FLOW_ACTION_TYPE_SEND_TO_KERNEL

v3:
http://patches.dpdk.org/project/dpdk/patch/[email protected]/

v2:
http://patches.dpdk.org/project/dpdk/patch/[email protected]/

---
 app/test-pmd/cmdline_flow.c                 |  9 +++++++++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  2 ++
 lib/ethdev/rte_flow.c                       |  1 +
 lib/ethdev/rte_flow.h                       | 12 ++++++++++++
 4 files changed, 24 insertions(+)
app/test-pmd/cmdline_flow.c +9 -0
index 7f50028eb7..042f6b34a6 100644
@@ -612,6 +612,7 @@ enum index {
 	ACTION_PORT_REPRESENTOR_PORT_ID,
 	ACTION_REPRESENTED_PORT,
 	ACTION_REPRESENTED_PORT_ETHDEV_PORT_ID,
+	ACTION_SEND_TO_KERNEL,
 };
 
 /** Maximum size for pattern in struct rte_flow_item_raw. */
@@ -1872,6 +1873,7 @@ static const enum index next_action[] = {
 	ACTION_CONNTRACK_UPDATE,
 	ACTION_PORT_REPRESENTOR,
 	ACTION_REPRESENTED_PORT,
+	ACTION_SEND_TO_KERNEL,
 	ZERO,
 };
 
@@ -6341,6 +6343,13 @@ static const struct token token_list[] = {
 		.help = "submit a list of associated actions for red",
 		.next = NEXT(next_action),
 	},
+	[ACTION_SEND_TO_KERNEL] = {
+		.name = "send_to_kernel",
+		.help = "send packets to kernel",
+		.priv = PRIV_ACTION(SEND_TO_KERNEL, 0),
+		.next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
+		.call = parse_vc,
+	},
 
 	/* Top-level command. */
 	[ADD] = {
doc/guides/testpmd_app_ug/testpmd_funcs.rst +2 -0
index 330e34427d..c259c8239a 100644
@@ -4189,6 +4189,8 @@ This section lists supported actions and their attributes, if any.
 
   - ``ethdev_port_id {unsigned}``: ethdev port ID
 
+- ``send_to_kernel``: send packets to kernel.
+
 Destroying flow rules
 ~~~~~~~~~~~~~~~~~~~~~
 
lib/ethdev/rte_flow.c +1 -0
index 501be9d602..627c671ce4 100644
@@ -259,6 +259,7 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = {
 	MK_FLOW_ACTION(CONNTRACK, sizeof(struct rte_flow_action_conntrack)),
 	MK_FLOW_ACTION(PORT_REPRESENTOR, sizeof(struct rte_flow_action_ethdev)),
 	MK_FLOW_ACTION(REPRESENTED_PORT, sizeof(struct rte_flow_action_ethdev)),
+	MK_FLOW_ACTION(SEND_TO_KERNEL, 0),
 };
 
 int
lib/ethdev/rte_flow.h +12 -0
index a79f1e7ef0..2c15279a3b 100644
@@ -2879,6 +2879,18 @@ enum rte_flow_action_type {
 	 * @see struct rte_flow_action_ethdev
 	 */
 	RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT,
+
+	/**
+	 * Send packets to the kernel, without going to userspace at all.
+	 * The packets will be received by the kernel driver sharing
+	 * the same device as the DPDK port on which this action is
+	 * configured. This action is mostly suits bifurcated driver
+	 * model.
+	 * This is an ingress non-transfer action only.
+	 *
+	 * No associated configuration structure.
+	 */
+	RTE_FLOW_ACTION_TYPE_SEND_TO_KERNEL,
 };
 
 /**
Signature · 1 line
2.27.0
#14 lore raw
Quoted 107 lines · Michael Savisko

In some cases application may receive a packet that should have been received by the kernel. In this case application uses KNI or other means to transfer the packet to the kernel.

With bifurcated driver we can have a rule to route packets matching a pattern (example: IPv4 packets) to the DPDK application and the rest of the traffic will be received by the kernel.
But if we want to receive most of the traffic in DPDK except specific pattern (example: ICMP packets) that should be processed by the kernel, then it's easier to re-route these packets with a single rule.

This commit introduces new rte_flow action which allows application to re-route packets directly to the kernel without software involvement.

Add new testpmd rte_flow action 'send_to_kernel'. The application may use this action to route the packet to the kernel while still in the HW.

Example with testpmd command:

flow create 0 ingress priority 0 group 1 pattern eth type spec 0x0800 type mask 0xffff / end actions send_to_kernel / end

---
v4:
- improve description comment above RTE_FLOW_ACTION_TYPE_SEND_TO_KERNEL

v3:
http://patches.dpdk.org/project/dpdk/patch/[email protected]/

v2:
http://patches.dpdk.org/project/dpdk/patch/[email protected]/

---
  app/test-pmd/cmdline_flow.c                 |  9 +++++++++
  doc/guides/testpmd_app_ug/testpmd_funcs.rst |  2 ++
  lib/ethdev/rte_flow.c                       |  1 +
  lib/ethdev/rte_flow.h                       | 12 ++++++++++++
  4 files changed, 24 insertions(+)
app/test-pmd/cmdline_flow.c +9 -0
index 7f50028eb7..042f6b34a6 100644
@@ -612,6 +612,7 @@ enum index {
  	ACTION_PORT_REPRESENTOR_PORT_ID,
  	ACTION_REPRESENTED_PORT,
  	ACTION_REPRESENTED_PORT_ETHDEV_PORT_ID,
+	ACTION_SEND_TO_KERNEL,
  };
 
  /** Maximum size for pattern in struct rte_flow_item_raw. */
@@ -1872,6 +1873,7 @@ static const enum index next_action[] = {
  	ACTION_CONNTRACK_UPDATE,
  	ACTION_PORT_REPRESENTOR,
  	ACTION_REPRESENTED_PORT,
+	ACTION_SEND_TO_KERNEL,
  	ZERO,
  };
 
@@ -6341,6 +6343,13 @@ static const struct token token_list[] = {
  		.help = "submit a list of associated actions for red",
  		.next = NEXT(next_action),
  	},
+	[ACTION_SEND_TO_KERNEL] = {
+		.name = "send_to_kernel",
+		.help = "send packets to kernel",
+		.priv = PRIV_ACTION(SEND_TO_KERNEL, 0),
+		.next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
+		.call = parse_vc,
+	},
 
  	/* Top-level command. */
  	[ADD] = {
doc/guides/testpmd_app_ug/testpmd_funcs.rst +2 -0
index 330e34427d..c259c8239a 100644
@@ -4189,6 +4189,8 @@ This section lists supported actions and their attributes, if any.
 
    - ``ethdev_port_id {unsigned}``: ethdev port ID
 
+- ``send_to_kernel``: send packets to kernel.
+
  Destroying flow rules
  ~~~~~~~~~~~~~~~~~~~~~
 
lib/ethdev/rte_flow.c +1 -0
index 501be9d602..627c671ce4 100644
@@ -259,6 +259,7 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = {
  	MK_FLOW_ACTION(CONNTRACK, sizeof(struct rte_flow_action_conntrack)),
  	MK_FLOW_ACTION(PORT_REPRESENTOR, sizeof(struct rte_flow_action_ethdev)),
  	MK_FLOW_ACTION(REPRESENTED_PORT, sizeof(struct rte_flow_action_ethdev)),
+	MK_FLOW_ACTION(SEND_TO_KERNEL, 0),
  };
 
  int
lib/ethdev/rte_flow.h +0 -0
index a79f1e7ef0..2c15279a3b 100644
@@ -2879,6 +2879,18 @@ enum rte_flow_action_type {
  	 * @see struct rte_flow_action_ethdev

lib/ethdev/rte_flow.h enum rte_flow_action_type { · line 2889

Quoted 10 lines
lib/ethdev/rte_flow.h +8 -0
  	 */
  	RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT,
+
+	/**
+	 * Send packets to the kernel, without going to userspace at all.
+	 * The packets will be received by the kernel driver sharing
+	 * the same device as the DPDK port on which this action is
+	 * configured. This action is mostly suits bifurcated driver
+	 * model.
+	 * This is an ingress non-transfer action only.

May be we should not limit the definition to ingress only? It could be useful on egress as a way to reroute packet back to kernel.

Quoted 7 lines
lib/ethdev/rte_flow.h +4 -0
+	 *
+	 * No associated configuration structure.
+	 */
+	RTE_FLOW_ACTION_TYPE_SEND_TO_KERNEL,
  };
 
  /**
#15 lore raw

Hi Andrew

Quoted 126 lines

-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Monday, 3 October 2022 10:54

Quoted 20 lines · Michael Savisko

In some cases application may receive a packet that should have been received by the kernel. In this case application uses KNI or other means to transfer the packet to the kernel.

With bifurcated driver we can have a rule to route packets matching a pattern (example: IPv4 packets) to the DPDK application and the rest of the traffic will be received by the kernel.
But if we want to receive most of the traffic in DPDK except specific pattern (example: ICMP packets) that should be processed by the kernel, then it's easier to re-route these packets with a single rule.

This commit introduces new rte_flow action which allows application to re-route packets directly to the kernel without software involvement.

Add new testpmd rte_flow action 'send_to_kernel'. The application may use this action to route the packet to the kernel while still in the HW.

Example with testpmd command:

Quoted 8 lines

flow create 0 ingress priority 0 group 1 pattern eth type spec 0x0800 type mask 0xffff / end actions send_to_kernel / end

---
v4:
- improve description comment above

RTE_FLOW_ACTION_TYPE_SEND_TO_KERNEL

Quoted 3 lines

v3:
http://patches.dpdk.org/project/dpdk/patch/20220919155013.61473-1-

[email protected]/

Quoted 3 lines

v2:
http://patches.dpdk.org/project/dpdk/patch/20220914093219.11728-1-

[email protected]/

Review

Quoted 43 lines
---
  app/test-pmd/cmdline_flow.c                 |  9 +++++++++
  doc/guides/testpmd_app_ug/testpmd_funcs.rst |  2 ++
  lib/ethdev/rte_flow.c                       |  1 +
  lib/ethdev/rte_flow.h                       | 12 ++++++++++++
  4 files changed, 24 insertions(+)
app/test-pmd/cmdline_flow.c +9 -0
index 7f50028eb7..042f6b34a6 100644
@@ -612,6 +612,7 @@ enum index {
  	ACTION_PORT_REPRESENTOR_PORT_ID,
  	ACTION_REPRESENTED_PORT,
  	ACTION_REPRESENTED_PORT_ETHDEV_PORT_ID,
+	ACTION_SEND_TO_KERNEL,
  };
 
  /** Maximum size for pattern in struct rte_flow_item_raw. */
@@ -1872,6 +1873,7 @@ static const enum index next_action[] = {
  	ACTION_CONNTRACK_UPDATE,
  	ACTION_PORT_REPRESENTOR,
  	ACTION_REPRESENTED_PORT,
+	ACTION_SEND_TO_KERNEL,
  	ZERO,
  };
 
@@ -6341,6 +6343,13 @@ static const struct token token_list[] = {
  		.help = "submit a list of associated actions for red",
  		.next = NEXT(next_action),
  	},
+	[ACTION_SEND_TO_KERNEL] = {
+		.name = "send_to_kernel",
+		.help = "send packets to kernel",
+		.priv = PRIV_ACTION(SEND_TO_KERNEL, 0),
+		.next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
+		.call = parse_vc,
+	},
 
  	/* Top-level command. */
  	[ADD] = {
(quoted diff) +0 -0

b/doc/guides/testpmd_app_ug/testpmd_funcs.rst

doc/guides/testpmd_app_ug/testpmd_funcs.rst This section lists supported actions and their

Quoted 4 lines

index 330e34427d..c259c8239a 100644

doc/guides/testpmd_app_ug/testpmd_funcs.rst +0 -0
@@ -4189,6 +4189,8 @@ This section lists supported actions and their

attributes, if any.

lib/ethdev/rte_flow.c static const struct rte_flow_desc_data

Quoted 13 lines
doc/guides/testpmd_app_ug/testpmd_funcs.rst +2 -0
    - ``ethdev_port_id {unsigned}``: ethdev port ID
 
+- ``send_to_kernel``: send packets to kernel.
+
  Destroying flow rules
  ~~~~~~~~~~~~~~~~~~~~~
 
lib/ethdev/rte_flow.c +0 -0
index 501be9d602..627c671ce4 100644
@@ -259,6 +259,7 @@ static const struct rte_flow_desc_data

rte_flow_desc_action[] = {

lib/ethdev/rte_flow.c static const struct rte_flow_desc_data · line 259

Quoted 1 line
lib/ethdev/rte_flow.c +0 -0
  	MK_FLOW_ACTION(CONNTRACK, sizeof(struct

rte_flow_action_conntrack)),

lib/ethdev/rte_flow.c static const struct rte_flow_desc_data · line 260

Quoted 1 line
lib/ethdev/rte_flow.c +0 -0
  	MK_FLOW_ACTION(PORT_REPRESENTOR, sizeof(struct

rte_flow_action_ethdev)),

lib/ethdev/rte_flow.c static const struct rte_flow_desc_data · line 261

Quoted 1 line
lib/ethdev/rte_flow.c +0 -0
  	MK_FLOW_ACTION(REPRESENTED_PORT, sizeof(struct

rte_flow_action_ethdev)),

Quoted 16 lines
lib/ethdev/rte_flow.c +1 -0
+	MK_FLOW_ACTION(SEND_TO_KERNEL, 0),
  };
 
  int
lib/ethdev/rte_flow.h +4 -0
index a79f1e7ef0..2c15279a3b 100644
@@ -2879,6 +2879,18 @@ enum rte_flow_action_type {
  	 * @see struct rte_flow_action_ethdev
  	 */
  	RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT,
+
+	/**
+	 * Send packets to the kernel, without going to userspace at all.
+	 * The packets will be received by the kernel driver sharing
Quoted 9 lines

lib/ethdev/rte_flow.h enum rte_flow_action_type { · line 2889

Quoted 4 lines
lib/ethdev/rte_flow.h +4 -0
+	 * the same device as the DPDK port on which this action is
+	 * configured. This action is mostly suits bifurcated driver
+	 * model.
+	 * This is an ingress non-transfer action only.

May be we should not limit the definition to ingress only? It could be useful on egress as a way to reroute packet back to kernel.

Interesting, but there are no Kernel queues on egress that can receive packets (by definition of egress) do you mean that this will also do loopback from the egress back to the ingress of the same port and then send to kernel?
if so, I think we need a new action "loop_back"

Quoted 8 lines
Quoted 8 lines
lib/ethdev/rte_flow.h +4 -0
+	 *
+	 * No associated configuration structure.
+	 */
+	RTE_FLOW_ACTION_TYPE_SEND_TO_KERNEL,
  };
 
  /**
#16 lore raw
Quoted 138 lines · Ori Kam

Hi Andrew

Quoted 126 lines

-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Monday, 3 October 2022 10:54

Quoted 20 lines · Michael Savisko

In some cases application may receive a packet that should have been received by the kernel. In this case application uses KNI or other means to transfer the packet to the kernel.

With bifurcated driver we can have a rule to route packets matching a pattern (example: IPv4 packets) to the DPDK application and the rest of the traffic will be received by the kernel.
But if we want to receive most of the traffic in DPDK except specific pattern (example: ICMP packets) that should be processed by the kernel, then it's easier to re-route these packets with a single rule.

This commit introduces new rte_flow action which allows application to re-route packets directly to the kernel without software involvement.

Add new testpmd rte_flow action 'send_to_kernel'. The application may use this action to route the packet to the kernel while still in the HW.

Example with testpmd command:

Quoted 8 lines

flow create 0 ingress priority 0 group 1 pattern eth type spec 0x0800 type mask 0xffff / end actions send_to_kernel / end

---
v4:
- improve description comment above

RTE_FLOW_ACTION_TYPE_SEND_TO_KERNEL

Quoted 3 lines

v3:
http://patches.dpdk.org/project/dpdk/patch/20220919155013.61473-1-

[email protected]/

Quoted 3 lines

v2:
http://patches.dpdk.org/project/dpdk/patch/20220914093219.11728-1-

[email protected]/

Review

Quoted 43 lines
---
   app/test-pmd/cmdline_flow.c                 |  9 +++++++++
   doc/guides/testpmd_app_ug/testpmd_funcs.rst |  2 ++
   lib/ethdev/rte_flow.c                       |  1 +
   lib/ethdev/rte_flow.h                       | 12 ++++++++++++
   4 files changed, 24 insertions(+)
app/test-pmd/cmdline_flow.c +9 -0
index 7f50028eb7..042f6b34a6 100644
@@ -612,6 +612,7 @@ enum index {
   	ACTION_PORT_REPRESENTOR_PORT_ID,
   	ACTION_REPRESENTED_PORT,
   	ACTION_REPRESENTED_PORT_ETHDEV_PORT_ID,
+	ACTION_SEND_TO_KERNEL,
   };
 
   /** Maximum size for pattern in struct rte_flow_item_raw. */
@@ -1872,6 +1873,7 @@ static const enum index next_action[] = {
   	ACTION_CONNTRACK_UPDATE,
   	ACTION_PORT_REPRESENTOR,
   	ACTION_REPRESENTED_PORT,
+	ACTION_SEND_TO_KERNEL,
   	ZERO,
   };
 
@@ -6341,6 +6343,13 @@ static const struct token token_list[] = {
   		.help = "submit a list of associated actions for red",
   		.next = NEXT(next_action),
   	},
+	[ACTION_SEND_TO_KERNEL] = {
+		.name = "send_to_kernel",
+		.help = "send packets to kernel",
+		.priv = PRIV_ACTION(SEND_TO_KERNEL, 0),
+		.next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
+		.call = parse_vc,
+	},
 
   	/* Top-level command. */
   	[ADD] = {
(quoted diff) +0 -0

b/doc/guides/testpmd_app_ug/testpmd_funcs.rst

doc/guides/testpmd_app_ug/testpmd_funcs.rst This section lists supported actions and their

Quoted 4 lines

index 330e34427d..c259c8239a 100644

doc/guides/testpmd_app_ug/testpmd_funcs.rst +0 -0
@@ -4189,6 +4189,8 @@ This section lists supported actions and their

attributes, if any.

lib/ethdev/rte_flow.c static const struct rte_flow_desc_data

Quoted 13 lines
doc/guides/testpmd_app_ug/testpmd_funcs.rst +2 -0
     - ``ethdev_port_id {unsigned}``: ethdev port ID
 
+- ``send_to_kernel``: send packets to kernel.
+
   Destroying flow rules
   ~~~~~~~~~~~~~~~~~~~~~
 
lib/ethdev/rte_flow.c +0 -0
index 501be9d602..627c671ce4 100644
@@ -259,6 +259,7 @@ static const struct rte_flow_desc_data

rte_flow_desc_action[] = {

lib/ethdev/rte_flow.c static const struct rte_flow_desc_data · line 259

Quoted 1 line
lib/ethdev/rte_flow.c +0 -0
   	MK_FLOW_ACTION(CONNTRACK, sizeof(struct

rte_flow_action_conntrack)),

lib/ethdev/rte_flow.c static const struct rte_flow_desc_data · line 260

Quoted 1 line
lib/ethdev/rte_flow.c +0 -0
   	MK_FLOW_ACTION(PORT_REPRESENTOR, sizeof(struct

rte_flow_action_ethdev)),

lib/ethdev/rte_flow.c static const struct rte_flow_desc_data · line 261

Quoted 1 line
lib/ethdev/rte_flow.c +0 -0
   	MK_FLOW_ACTION(REPRESENTED_PORT, sizeof(struct

rte_flow_action_ethdev)),

Quoted 16 lines
lib/ethdev/rte_flow.c +1 -0
+	MK_FLOW_ACTION(SEND_TO_KERNEL, 0),
   };
 
   int
lib/ethdev/rte_flow.h +4 -0
index a79f1e7ef0..2c15279a3b 100644
@@ -2879,6 +2879,18 @@ enum rte_flow_action_type {
   	 * @see struct rte_flow_action_ethdev
   	 */
   	RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT,
+
+	/**
+	 * Send packets to the kernel, without going to userspace at all.
+	 * The packets will be received by the kernel driver sharing
Quoted 9 lines

lib/ethdev/rte_flow.h enum rte_flow_action_type { · line 2889

Quoted 4 lines
lib/ethdev/rte_flow.h +4 -0
+	 * the same device as the DPDK port on which this action is
+	 * configured. This action is mostly suits bifurcated driver
+	 * model.
+	 * This is an ingress non-transfer action only.

May be we should not limit the definition to ingress only? It could be useful on egress as a way to reroute packet back to kernel.

Quoted 4 lines

Interesting, but there are no Kernel queues on egress that can receive packets (by definition of egress) do you mean that this will also do loopback from the egress back to the ingress of the same port and then send to kernel?
if so, I think we need a new action "loop_back"

Yes, I meant intercept packet on egress and send to kernel. But we still need loopback+send_to_kernel. Loopback itself cannot send to kernel. Moreover it should be two rules:
loopback on egress plus send-to-kernel on ingress. Does it really worse it? I'm not sure. Yes, it sounds a bit better from arch point of view, but I'm still unsure. I'd allow send-to-kernel on egress. Up to you.

Quoted 10 lines
Quoted 9 lines
Quoted 9 lines
lib/ethdev/rte_flow.h +4 -0
+	 *
+	 * No associated configuration structure.
+	 */
+	RTE_FLOW_ACTION_TYPE_SEND_TO_KERNEL,
   };
 
   /**
#17 lore raw

Hi Andrew,

Quoted 152 lines

-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Monday, 3 October 2022 12:44

Quoted 15 lines · Ori Kam

Hi Andrew

Quoted 13 lines

-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Monday, 3 October 2022 10:54

Quoted 9 lines · Michael Savisko

In some cases application may receive a packet that should have been received by the kernel. In this case application uses KNI or other means to transfer the packet to the kernel.

With bifurcated driver we can have a rule to route packets matching a pattern (example: IPv4 packets) to the DPDK application and the rest of the traffic will be received by the kernel.
But if we want to receive most of the traffic in DPDK except specific pattern (example: ICMP packets) that should be processed by the

kernel,

Quoted 29 lines
Quoted 29 lines
Quoted 11 lines

then it's easier to re-route these packets with a single rule.

This commit introduces new rte_flow action which allows application to re-route packets directly to the kernel without software involvement.

Add new testpmd rte_flow action 'send_to_kernel'. The application may use this action to route the packet to the kernel while still in the HW.

Example with testpmd command:

Quoted 8 lines

flow create 0 ingress priority 0 group 1 pattern eth type spec 0x0800 type mask 0xffff / end actions send_to_kernel / end

---
v4:
- improve description comment above

RTE_FLOW_ACTION_TYPE_SEND_TO_KERNEL

Quoted 3 lines

v3:
http://patches.dpdk.org/project/dpdk/patch/20220919155013.61473-1-

[email protected]/

Quoted 3 lines

v2:
http://patches.dpdk.org/project/dpdk/patch/20220914093219.11728-1-

[email protected]/

Quoted 1 line
Quoted 8 lines
Quoted 8 lines

app/test-

Quoted 8 lines
---
   app/test-pmd/cmdline_flow.c                 |  9 +++++++++
   doc/guides/testpmd_app_ug/testpmd_funcs.rst |  2 ++
   lib/ethdev/rte_flow.c                       |  1 +
   lib/ethdev/rte_flow.h                       | 12 ++++++++++++
   4 files changed, 24 insertions(+)
app/test- renamed from app/test-pmd/cmdline_flow.c +0 -0

pmd/cmdline_flow.c

Quoted 86 lines
Quoted 76 lines

Review

Quoted 34 lines

index 7f50028eb7..042f6b34a6 100644

app/test-pmd/cmdline_flow.c +9 -0
@@ -612,6 +612,7 @@ enum index {
   	ACTION_PORT_REPRESENTOR_PORT_ID,
   	ACTION_REPRESENTED_PORT,
   	ACTION_REPRESENTED_PORT_ETHDEV_PORT_ID,
+	ACTION_SEND_TO_KERNEL,
   };
 
   /** Maximum size for pattern in struct rte_flow_item_raw. */
@@ -1872,6 +1873,7 @@ static const enum index next_action[] = {
   	ACTION_CONNTRACK_UPDATE,
   	ACTION_PORT_REPRESENTOR,
   	ACTION_REPRESENTED_PORT,
+	ACTION_SEND_TO_KERNEL,
   	ZERO,
   };
 
@@ -6341,6 +6343,13 @@ static const struct token token_list[] = {
   		.help = "submit a list of associated actions for red",
   		.next = NEXT(next_action),
   	},
+	[ACTION_SEND_TO_KERNEL] = {
+		.name = "send_to_kernel",
+		.help = "send packets to kernel",
+		.priv = PRIV_ACTION(SEND_TO_KERNEL, 0),
+		.next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
+		.call = parse_vc,
+	},
 
   	/* Top-level command. */
   	[ADD] = {
(quoted diff) +0 -0

b/doc/guides/testpmd_app_ug/testpmd_funcs.rst

doc/guides/testpmd_app_ug/testpmd_funcs.rst This section lists supported actions and their

Quoted 4 lines

index 330e34427d..c259c8239a 100644

doc/guides/testpmd_app_ug/testpmd_funcs.rst +0 -0
@@ -4189,6 +4189,8 @@ This section lists supported actions and their

attributes, if any.

lib/ethdev/rte_flow.c static const struct rte_flow_desc_data

Quoted 13 lines
doc/guides/testpmd_app_ug/testpmd_funcs.rst +2 -0
     - ``ethdev_port_id {unsigned}``: ethdev port ID
 
+- ``send_to_kernel``: send packets to kernel.
+
   Destroying flow rules
   ~~~~~~~~~~~~~~~~~~~~~
 
lib/ethdev/rte_flow.c +0 -0
index 501be9d602..627c671ce4 100644
@@ -259,6 +259,7 @@ static const struct rte_flow_desc_data

rte_flow_desc_action[] = {

lib/ethdev/rte_flow.c static const struct rte_flow_desc_data · line 259

Quoted 1 line
lib/ethdev/rte_flow.c +0 -0
   	MK_FLOW_ACTION(CONNTRACK, sizeof(struct

rte_flow_action_conntrack)),

lib/ethdev/rte_flow.c static const struct rte_flow_desc_data · line 260

Quoted 1 line
lib/ethdev/rte_flow.c +0 -0
   	MK_FLOW_ACTION(PORT_REPRESENTOR, sizeof(struct

rte_flow_action_ethdev)),

lib/ethdev/rte_flow.c static const struct rte_flow_desc_data · line 261

Quoted 1 line
lib/ethdev/rte_flow.c +0 -0
   	MK_FLOW_ACTION(REPRESENTED_PORT, sizeof(struct

rte_flow_action_ethdev)),

Quoted 16 lines
lib/ethdev/rte_flow.c +1 -0
+	MK_FLOW_ACTION(SEND_TO_KERNEL, 0),
   };
 
   int
lib/ethdev/rte_flow.h +4 -0
index a79f1e7ef0..2c15279a3b 100644
@@ -2879,6 +2879,18 @@ enum rte_flow_action_type {
   	 * @see struct rte_flow_action_ethdev
   	 */
   	RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT,
+
+	/**
+	 * Send packets to the kernel, without going to userspace at all.
+	 * The packets will be received by the kernel driver sharing
Quoted 9 lines

lib/ethdev/rte_flow.h enum rte_flow_action_type { · line 2889

Quoted 4 lines
lib/ethdev/rte_flow.h +4 -0
+	 * the same device as the DPDK port on which this action is
+	 * configured. This action is mostly suits bifurcated driver
+	 * model.
+	 * This is an ingress non-transfer action only.

May be we should not limit the definition to ingress only? It could be useful on egress as a way to reroute packet back to kernel.

Quoted 1 line

Interesting, but there are no Kernel queues on egress that can receive

packets (by definition of egress)

Quoted 1 line

do you mean that this will also do loopback from the egress back to the

ingress of the same port and then

Quoted 2 lines

send to kernel?
if so, I think we need a new action "loop_back"

Quoted 8 lines

Yes, I meant intercept packet on egress and send to kernel. But we still need loopback+send_to_kernel. Loopback itself cannot send to kernel. Moreover it should be two rules:
loopback on egress plus send-to-kernel on ingress. Does it really worse it? I'm not sure. Yes, it sounds a bit better from arch point of view, but I'm still unsure. I'd allow send-to-kernel on egress. Up to you.

It looks more correct with loop_back on the egress and send-to-kernel on egress I suggest to keep the current design,
and if we see that we can merge those to commands, we will change it

Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
Quoted 9 lines
lib/ethdev/rte_flow.h +4 -0
+	 *
+	 * No associated configuration structure.
+	 */
+	RTE_FLOW_ACTION_TYPE_SEND_TO_KERNEL,
   };
 
   /**
#18 lore raw
Quoted 163 lines · Ori Kam

Hi Andrew,

Quoted 152 lines

-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Monday, 3 October 2022 12:44

Quoted 15 lines · Ori Kam

Hi Andrew

Quoted 13 lines

-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Monday, 3 October 2022 10:54

Quoted 9 lines · Michael Savisko

In some cases application may receive a packet that should have been received by the kernel. In this case application uses KNI or other means to transfer the packet to the kernel.

With bifurcated driver we can have a rule to route packets matching a pattern (example: IPv4 packets) to the DPDK application and the rest of the traffic will be received by the kernel.
But if we want to receive most of the traffic in DPDK except specific pattern (example: ICMP packets) that should be processed by the

kernel,

Quoted 29 lines
Quoted 29 lines
Quoted 11 lines

then it's easier to re-route these packets with a single rule.

This commit introduces new rte_flow action which allows application to re-route packets directly to the kernel without software involvement.

Add new testpmd rte_flow action 'send_to_kernel'. The application may use this action to route the packet to the kernel while still in the HW.

Example with testpmd command:

Quoted 8 lines

flow create 0 ingress priority 0 group 1 pattern eth type spec 0x0800 type mask 0xffff / end actions send_to_kernel / end

---
v4:
- improve description comment above

RTE_FLOW_ACTION_TYPE_SEND_TO_KERNEL

Quoted 3 lines

v3:
http://patches.dpdk.org/project/dpdk/patch/20220919155013.61473-1-

[email protected]/

Quoted 3 lines

v2:
http://patches.dpdk.org/project/dpdk/patch/20220914093219.11728-1-

[email protected]/

Quoted 1 line
Quoted 8 lines
Quoted 8 lines

app/test-

Quoted 8 lines
---
    app/test-pmd/cmdline_flow.c                 |  9 +++++++++
    doc/guides/testpmd_app_ug/testpmd_funcs.rst |  2 ++
    lib/ethdev/rte_flow.c                       |  1 +
    lib/ethdev/rte_flow.h                       | 12 ++++++++++++
    4 files changed, 24 insertions(+)
app/test- renamed from app/test-pmd/cmdline_flow.c +0 -0

pmd/cmdline_flow.c

Quoted 86 lines
Quoted 76 lines

Review

Quoted 34 lines

index 7f50028eb7..042f6b34a6 100644

app/test-pmd/cmdline_flow.c +9 -0
@@ -612,6 +612,7 @@ enum index {
    	ACTION_PORT_REPRESENTOR_PORT_ID,
    	ACTION_REPRESENTED_PORT,
    	ACTION_REPRESENTED_PORT_ETHDEV_PORT_ID,
+	ACTION_SEND_TO_KERNEL,
    };
 
    /** Maximum size for pattern in struct rte_flow_item_raw. */
@@ -1872,6 +1873,7 @@ static const enum index next_action[] = {
    	ACTION_CONNTRACK_UPDATE,
    	ACTION_PORT_REPRESENTOR,
    	ACTION_REPRESENTED_PORT,
+	ACTION_SEND_TO_KERNEL,
    	ZERO,
    };
 
@@ -6341,6 +6343,13 @@ static const struct token token_list[] = {
    		.help = "submit a list of associated actions for red",
    		.next = NEXT(next_action),
    	},
+	[ACTION_SEND_TO_KERNEL] = {
+		.name = "send_to_kernel",
+		.help = "send packets to kernel",
+		.priv = PRIV_ACTION(SEND_TO_KERNEL, 0),
+		.next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
+		.call = parse_vc,
+	},
 
    	/* Top-level command. */
    	[ADD] = {
(quoted diff) +0 -0

b/doc/guides/testpmd_app_ug/testpmd_funcs.rst

doc/guides/testpmd_app_ug/testpmd_funcs.rst This section lists supported actions and their

Quoted 4 lines

index 330e34427d..c259c8239a 100644

doc/guides/testpmd_app_ug/testpmd_funcs.rst +0 -0
@@ -4189,6 +4189,8 @@ This section lists supported actions and their

attributes, if any.

lib/ethdev/rte_flow.c static const struct rte_flow_desc_data

Quoted 13 lines
doc/guides/testpmd_app_ug/testpmd_funcs.rst +2 -0
      - ``ethdev_port_id {unsigned}``: ethdev port ID
 
+- ``send_to_kernel``: send packets to kernel.
+
    Destroying flow rules
    ~~~~~~~~~~~~~~~~~~~~~
 
lib/ethdev/rte_flow.c +0 -0
index 501be9d602..627c671ce4 100644
@@ -259,6 +259,7 @@ static const struct rte_flow_desc_data

rte_flow_desc_action[] = {

lib/ethdev/rte_flow.c static const struct rte_flow_desc_data · line 259

Quoted 1 line
lib/ethdev/rte_flow.c +0 -0
    	MK_FLOW_ACTION(CONNTRACK, sizeof(struct

rte_flow_action_conntrack)),

lib/ethdev/rte_flow.c static const struct rte_flow_desc_data · line 260

Quoted 1 line
lib/ethdev/rte_flow.c +0 -0
    	MK_FLOW_ACTION(PORT_REPRESENTOR, sizeof(struct

rte_flow_action_ethdev)),

lib/ethdev/rte_flow.c static const struct rte_flow_desc_data · line 261

Quoted 1 line
lib/ethdev/rte_flow.c +0 -0
    	MK_FLOW_ACTION(REPRESENTED_PORT, sizeof(struct

rte_flow_action_ethdev)),

Quoted 16 lines
lib/ethdev/rte_flow.c +1 -0
+	MK_FLOW_ACTION(SEND_TO_KERNEL, 0),
    };
 
    int
lib/ethdev/rte_flow.h +4 -0
index a79f1e7ef0..2c15279a3b 100644
@@ -2879,6 +2879,18 @@ enum rte_flow_action_type {
    	 * @see struct rte_flow_action_ethdev
    	 */
    	RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT,
+
+	/**
+	 * Send packets to the kernel, without going to userspace at all.
+	 * The packets will be received by the kernel driver sharing
Quoted 9 lines

lib/ethdev/rte_flow.h enum rte_flow_action_type { · line 2889

Quoted 4 lines
lib/ethdev/rte_flow.h +4 -0
+	 * the same device as the DPDK port on which this action is
+	 * configured. This action is mostly suits bifurcated driver
+	 * model.
+	 * This is an ingress non-transfer action only.

May be we should not limit the definition to ingress only? It could be useful on egress as a way to reroute packet back to kernel.

Quoted 1 line

Interesting, but there are no Kernel queues on egress that can receive

packets (by definition of egress)

Quoted 1 line

do you mean that this will also do loopback from the egress back to the

ingress of the same port and then

Quoted 2 lines

send to kernel?
if so, I think we need a new action "loop_back"

Quoted 8 lines

Yes, I meant intercept packet on egress and send to kernel. But we still need loopback+send_to_kernel. Loopback itself cannot send to kernel. Moreover it should be two rules:
loopback on egress plus send-to-kernel on ingress. Does it really worse it? I'm not sure. Yes, it sounds a bit better from arch point of view, but I'm still unsure. I'd allow send-to-kernel on egress. Up to you.

Quoted 3 lines

It looks more correct with loop_back on the egress and send-to-kernel on egress I suggest to keep the current design,
and if we see that we can merge those to commands, we will change it

OK. And the last question: do we need to announce it in release notes?

Quoted 12 lines
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
Quoted 10 lines
lib/ethdev/rte_flow.h +4 -0
+	 *
+	 * No associated configuration structure.
+	 */
+	RTE_FLOW_ACTION_TYPE_SEND_TO_KERNEL,
    };
 
    /**
#19 lore raw

Hi Andrew,

Quoted 174 lines

-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Monday, 3 October 2022 13:47

Quoted 15 lines · Ori Kam

Hi Andrew,

Quoted 13 lines

-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Monday, 3 October 2022 12:44

Quoted 8 lines · Ori Kam

Hi Andrew

Quoted 6 lines

-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Monday, 3 October 2022 10:54

Quoted 2 lines · Michael Savisko

In some cases application may receive a packet that should have been received by the kernel. In this case application uses KNI or other

means

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

to transfer the packet to the kernel.

With bifurcated driver we can have a rule to route packets matching a pattern (example: IPv4 packets) to the DPDK application and the

rest

Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

of the traffic will be received by the kernel.
But if we want to receive most of the traffic in DPDK except specific pattern (example: ICMP packets) that should be processed by the

kernel,

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

then it's easier to re-route these packets with a single rule.

This commit introduces new rte_flow action which allows application

to

Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines

re-route packets directly to the kernel without software involvement.

Add new testpmd rte_flow action 'send_to_kernel'. The application may use this action to route the packet to the kernel while still in the HW.

Example with testpmd command:

flow create 0 ingress priority 0 group 1 pattern eth type spec 0x0800 type mask 0xffff / end actions send_to_kernel / end

---
v4:
- improve description comment above

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

RTE_FLOW_ACTION_TYPE_SEND_TO_KERNEL

Quoted 3 lines

v3:
http://patches.dpdk.org/project/dpdk/patch/20220919155013.61473-

1-

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

[email protected]/

Quoted 3 lines

v2:
http://patches.dpdk.org/project/dpdk/patch/20220914093219.11728-

1-

Quoted 74 lines
Quoted 74 lines
Quoted 10 lines
Quoted 10 lines

[email protected]/

app/test-

Quoted 9 lines
---
    app/test-pmd/cmdline_flow.c                 |  9 +++++++++
    doc/guides/testpmd_app_ug/testpmd_funcs.rst |  2 ++
    lib/ethdev/rte_flow.c                       |  1 +
    lib/ethdev/rte_flow.h                       | 12 ++++++++++++
    4 files changed, 24 insertions(+)
app/test- renamed from app/test-pmd/cmdline_flow.c +0 -0

pmd/cmdline_flow.c

Quoted 63 lines
Quoted 63 lines

Review

Quoted 34 lines

index 7f50028eb7..042f6b34a6 100644

app/test-pmd/cmdline_flow.c +9 -0
@@ -612,6 +612,7 @@ enum index {
    	ACTION_PORT_REPRESENTOR_PORT_ID,
    	ACTION_REPRESENTED_PORT,
    	ACTION_REPRESENTED_PORT_ETHDEV_PORT_ID,
+	ACTION_SEND_TO_KERNEL,
    };
 
    /** Maximum size for pattern in struct rte_flow_item_raw. */
@@ -1872,6 +1873,7 @@ static const enum index next_action[] = {
    	ACTION_CONNTRACK_UPDATE,
    	ACTION_PORT_REPRESENTOR,
    	ACTION_REPRESENTED_PORT,
+	ACTION_SEND_TO_KERNEL,
    	ZERO,
    };
 
@@ -6341,6 +6343,13 @@ static const struct token token_list[] = {
    		.help = "submit a list of associated actions for red",
    		.next = NEXT(next_action),
    	},
+	[ACTION_SEND_TO_KERNEL] = {
+		.name = "send_to_kernel",
+		.help = "send packets to kernel",
+		.priv = PRIV_ACTION(SEND_TO_KERNEL, 0),
+		.next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
+		.call = parse_vc,
+	},
 
    	/* Top-level command. */
    	[ADD] = {
(quoted diff) +0 -0

b/doc/guides/testpmd_app_ug/testpmd_funcs.rst

doc/guides/testpmd_app_ug/testpmd_funcs.rst This section lists supported actions and their

Quoted 4 lines

index 330e34427d..c259c8239a 100644

doc/guides/testpmd_app_ug/testpmd_funcs.rst +0 -0
@@ -4189,6 +4189,8 @@ This section lists supported actions and their

attributes, if any.

lib/ethdev/rte_flow.c static const struct rte_flow_desc_data

Quoted 13 lines
doc/guides/testpmd_app_ug/testpmd_funcs.rst +2 -0
      - ``ethdev_port_id {unsigned}``: ethdev port ID
 
+- ``send_to_kernel``: send packets to kernel.
+
    Destroying flow rules
    ~~~~~~~~~~~~~~~~~~~~~
 
lib/ethdev/rte_flow.c +0 -0
index 501be9d602..627c671ce4 100644
@@ -259,6 +259,7 @@ static const struct rte_flow_desc_data

rte_flow_desc_action[] = {

lib/ethdev/rte_flow.c static const struct rte_flow_desc_data · line 259

Quoted 1 line
lib/ethdev/rte_flow.c +0 -0
    	MK_FLOW_ACTION(CONNTRACK, sizeof(struct

rte_flow_action_conntrack)),

lib/ethdev/rte_flow.c static const struct rte_flow_desc_data · line 260

Quoted 1 line
lib/ethdev/rte_flow.c +0 -0
    	MK_FLOW_ACTION(PORT_REPRESENTOR, sizeof(struct

rte_flow_action_ethdev)),

lib/ethdev/rte_flow.c static const struct rte_flow_desc_data · line 261

Quoted 1 line
lib/ethdev/rte_flow.c +0 -0
    	MK_FLOW_ACTION(REPRESENTED_PORT, sizeof(struct

rte_flow_action_ethdev)),

Quoted 3 lines
lib/ethdev/rte_flow.c +1 -0
+	MK_FLOW_ACTION(SEND_TO_KERNEL, 0),
    };
 
Quoted 12 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
lib/ethdev/rte_flow.c +0 -0
    int
lib/ethdev/rte_flow.h +0 -1
index a79f1e7ef0..2c15279a3b 100644
--- a/lib/ethdev/rte_flow.h
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

lib/ethdev/rte_flow.h enum rte_flow_action_type { · line 2884

Quoted 8 lines

+++ b/lib/ethdev/rte_flow.h

lib/ethdev/rte_flow.h +3 -0
@@ -2879,6 +2879,18 @@ enum rte_flow_action_type {
    	 * @see struct rte_flow_action_ethdev
    	 */
    	RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT,
+
+	/**
+	 * Send packets to the kernel, without going to userspace at

all.

Quoted 27 lines
Quoted 26 lines
Quoted 11 lines
Quoted 10 lines

lib/ethdev/rte_flow.h enum rte_flow_action_type { · line 2889

Quoted 5 lines
lib/ethdev/rte_flow.h +5 -0
+	 * The packets will be received by the kernel driver sharing
+	 * the same device as the DPDK port on which this action is
+	 * configured. This action is mostly suits bifurcated driver
+	 * model.
+	 * This is an ingress non-transfer action only.

May be we should not limit the definition to ingress only? It could be useful on egress as a way to reroute packet back to kernel.

Quoted 1 line

Interesting, but there are no Kernel queues on egress that can receive

packets (by definition of egress)

Quoted 1 line

do you mean that this will also do loopback from the egress back to the

ingress of the same port and then

Quoted 2 lines

send to kernel?
if so, I think we need a new action "loop_back"

Yes, I meant intercept packet on egress and send to kernel. But we still need loopback+send_to_kernel. Loopback itself cannot send to kernel. Moreover it should be two rules:
loopback on egress plus send-to-kernel on ingress. Does it really worse it? I'm not sure. Yes, it sounds a bit better from arch point of view, but I'm still unsure. I'd allow send-to-kernel on egress. Up to you.

Quoted 8 lines
Quoted 1 line

It looks more correct with loop_back on the egress and send-to-kernel on

egress

Quoted 2 lines

I suggest to keep the current design,
and if we see that we can merge those to commands, we will change it

OK. And the last question: do we need to announce it in release notes?

+1

Quoted 14 lines
Quoted 12 lines
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
Quoted 10 lines
lib/ethdev/rte_flow.h +4 -0
+	 *
+	 * No associated configuration structure.
+	 */
+	RTE_FLOW_ACTION_TYPE_SEND_TO_KERNEL,
    };
 
    /**
#20 lore raw
Quoted 178 lines · Ori Kam

Hi Andrew,

Quoted 176 lines

-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Monday, 3 October 2022 13:47

Quoted 15 lines · Ori Kam

Hi Andrew,

Quoted 13 lines

-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Monday, 3 October 2022 12:44

Quoted 8 lines · Ori Kam

Hi Andrew

Quoted 6 lines

-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Monday, 3 October 2022 10:54

Quoted 2 lines · Michael Savisko

In some cases application may receive a packet that should have been received by the kernel. In this case application uses KNI or other

means

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

to transfer the packet to the kernel.

With bifurcated driver we can have a rule to route packets matching a pattern (example: IPv4 packets) to the DPDK application and the

rest

Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

of the traffic will be received by the kernel.
But if we want to receive most of the traffic in DPDK except specific pattern (example: ICMP packets) that should be processed by the

kernel,

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

then it's easier to re-route these packets with a single rule.

This commit introduces new rte_flow action which allows application

to

Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines

re-route packets directly to the kernel without software involvement.

Add new testpmd rte_flow action 'send_to_kernel'. The application may use this action to route the packet to the kernel while still in the HW.

Example with testpmd command:

flow create 0 ingress priority 0 group 1 pattern eth type spec 0x0800 type mask 0xffff / end actions send_to_kernel / end

---
v4:
- improve description comment above

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

RTE_FLOW_ACTION_TYPE_SEND_TO_KERNEL

Quoted 3 lines

v3:
http://patches.dpdk.org/project/dpdk/patch/20220919155013.61473-

1-

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

[email protected]/

Quoted 3 lines

v2:
http://patches.dpdk.org/project/dpdk/patch/20220914093219.11728-

1-

Quoted 74 lines
Quoted 74 lines
Quoted 10 lines
Quoted 10 lines

[email protected]/

app/test-

Quoted 9 lines
---
     app/test-pmd/cmdline_flow.c                 |  9 +++++++++
     doc/guides/testpmd_app_ug/testpmd_funcs.rst |  2 ++
     lib/ethdev/rte_flow.c                       |  1 +
     lib/ethdev/rte_flow.h                       | 12 ++++++++++++
     4 files changed, 24 insertions(+)
app/test- renamed from app/test-pmd/cmdline_flow.c +0 -0

pmd/cmdline_flow.c

Quoted 63 lines
Quoted 63 lines

Review

Quoted 34 lines

index 7f50028eb7..042f6b34a6 100644

app/test-pmd/cmdline_flow.c +9 -0
@@ -612,6 +612,7 @@ enum index {
     	ACTION_PORT_REPRESENTOR_PORT_ID,
     	ACTION_REPRESENTED_PORT,
     	ACTION_REPRESENTED_PORT_ETHDEV_PORT_ID,
+	ACTION_SEND_TO_KERNEL,
     };
 
     /** Maximum size for pattern in struct rte_flow_item_raw. */
@@ -1872,6 +1873,7 @@ static const enum index next_action[] = {
     	ACTION_CONNTRACK_UPDATE,
     	ACTION_PORT_REPRESENTOR,
     	ACTION_REPRESENTED_PORT,
+	ACTION_SEND_TO_KERNEL,
     	ZERO,
     };
 
@@ -6341,6 +6343,13 @@ static const struct token token_list[] = {
     		.help = "submit a list of associated actions for red",
     		.next = NEXT(next_action),
     	},
+	[ACTION_SEND_TO_KERNEL] = {
+		.name = "send_to_kernel",
+		.help = "send packets to kernel",
+		.priv = PRIV_ACTION(SEND_TO_KERNEL, 0),
+		.next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
+		.call = parse_vc,
+	},
 
     	/* Top-level command. */
     	[ADD] = {
(quoted diff) +0 -0

b/doc/guides/testpmd_app_ug/testpmd_funcs.rst

doc/guides/testpmd_app_ug/testpmd_funcs.rst This section lists supported actions and their

Quoted 4 lines

index 330e34427d..c259c8239a 100644

doc/guides/testpmd_app_ug/testpmd_funcs.rst +0 -0
@@ -4189,6 +4189,8 @@ This section lists supported actions and their

attributes, if any.

lib/ethdev/rte_flow.c static const struct rte_flow_desc_data

Quoted 13 lines
doc/guides/testpmd_app_ug/testpmd_funcs.rst +2 -0
       - ``ethdev_port_id {unsigned}``: ethdev port ID
 
+- ``send_to_kernel``: send packets to kernel.
+
     Destroying flow rules
     ~~~~~~~~~~~~~~~~~~~~~
 
lib/ethdev/rte_flow.c +0 -0
index 501be9d602..627c671ce4 100644
@@ -259,6 +259,7 @@ static const struct rte_flow_desc_data

rte_flow_desc_action[] = {

lib/ethdev/rte_flow.c static const struct rte_flow_desc_data · line 259

Quoted 1 line
lib/ethdev/rte_flow.c +0 -0
     	MK_FLOW_ACTION(CONNTRACK, sizeof(struct

rte_flow_action_conntrack)),

lib/ethdev/rte_flow.c static const struct rte_flow_desc_data · line 260

Quoted 1 line
lib/ethdev/rte_flow.c +0 -0
     	MK_FLOW_ACTION(PORT_REPRESENTOR, sizeof(struct

rte_flow_action_ethdev)),

lib/ethdev/rte_flow.c static const struct rte_flow_desc_data · line 261

Quoted 1 line
lib/ethdev/rte_flow.c +0 -0
     	MK_FLOW_ACTION(REPRESENTED_PORT, sizeof(struct

rte_flow_action_ethdev)),

Quoted 3 lines
lib/ethdev/rte_flow.c +1 -0
+	MK_FLOW_ACTION(SEND_TO_KERNEL, 0),
     };
 
Quoted 12 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
lib/ethdev/rte_flow.c +0 -0
     int
lib/ethdev/rte_flow.h +0 -1
index a79f1e7ef0..2c15279a3b 100644
--- a/lib/ethdev/rte_flow.h
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

lib/ethdev/rte_flow.h enum rte_flow_action_type { · line 2884

Quoted 8 lines

+++ b/lib/ethdev/rte_flow.h

lib/ethdev/rte_flow.h +3 -0
@@ -2879,6 +2879,18 @@ enum rte_flow_action_type {
     	 * @see struct rte_flow_action_ethdev
     	 */
     	RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT,
+
+	/**
+	 * Send packets to the kernel, without going to userspace at

all.

Quoted 27 lines
Quoted 18 lines
Quoted 11 lines
Quoted 10 lines

lib/ethdev/rte_flow.h enum rte_flow_action_type { · line 2889

Quoted 5 lines
lib/ethdev/rte_flow.h +5 -0
+	 * The packets will be received by the kernel driver sharing
+	 * the same device as the DPDK port on which this action is
+	 * configured. This action is mostly suits bifurcated driver
+	 * model.
+	 * This is an ingress non-transfer action only.

May be we should not limit the definition to ingress only? It could be useful on egress as a way to reroute packet back to kernel.

Quoted 1 line

Interesting, but there are no Kernel queues on egress that can receive

packets (by definition of egress)

Quoted 1 line

do you mean that this will also do loopback from the egress back to the

ingress of the same port and then

Quoted 2 lines

send to kernel?
if so, I think we need a new action "loop_back"

Quoted 8 lines

Yes, I meant intercept packet on egress and send to kernel. But we still need loopback+send_to_kernel. Loopback itself cannot send to kernel. Moreover it should be two rules:
loopback on egress plus send-to-kernel on ingress. Does it really worse it? I'm not sure. Yes, it sounds a bit better from arch point of view, but I'm still unsure. I'd allow send-to-kernel on egress. Up to you.

Quoted 1 line

It looks more correct with loop_back on the egress and send-to-kernel on

egress

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

I suggest to keep the current design,
and if we see that we can merge those to commands, we will change it

OK. And the last question: do we need to announce it in release notes?

+1

Michael,

please, send v5 with release notes update. Don't forget to rebase in on current next-net/main, please.

Thanks,
Andrew.

Quoted 16 lines
Quoted 15 lines
Quoted 12 lines
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
Quoted 10 lines
lib/ethdev/rte_flow.h +4 -0
+	 *
+	 * No associated configuration structure.
+	 */
+	RTE_FLOW_ACTION_TYPE_SEND_TO_KERNEL,
     };
 
     /**
#21 lore raw

PATCH v5 1/1 ethdev: add send to kernel action

In reply to Michael Savisko

In some cases application may receive a packet that should have been received by the kernel. In this case application uses KNI or other means to transfer the packet to the kernel.

With bifurcated driver we can have a rule to route packets matching a pattern (example: IPv4 packets) to the DPDK application and the rest of the traffic will be received by the kernel.
But if we want to receive most of the traffic in DPDK except specific pattern (example: ICMP packets) that should be processed by the kernel, then it's easier to re-route these packets with a single rule.

This commit introduces new rte_flow action which allows application to re-route packets directly to the kernel without software involvement.

Add new testpmd rte_flow action 'send_to_kernel'. The application may use this action to route the packet to the kernel while still in the HW.

Example with testpmd command:

flow create 0 ingress priority 0 group 1 pattern eth type spec 0x0800 type mask 0xffff / end actions send_to_kernel / end

---
v5:
- added description of the feature to release notes

v4:
- improve description comment above RTE_FLOW_ACTION_TYPE_SEND_TO_KERNEL
http://patches.dpdk.org/project/dpdk/patch/[email protected]/

v3:
http://patches.dpdk.org/project/dpdk/patch/[email protected]/

v2:
http://patches.dpdk.org/project/dpdk/patch/[email protected]/

---
 app/test-pmd/cmdline_flow.c                 |  9 +++++++++
 doc/guides/rel_notes/release_22_11.rst      |  5 +++++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  3 +++
 lib/ethdev/rte_flow.c                       |  1 +
 lib/ethdev/rte_flow.h                       | 12 ++++++++++++
 5 files changed, 30 insertions(+)
app/test-pmd/cmdline_flow.c +9 -0
index 91c6950b60..9e299b8335 100644
@@ -622,6 +622,7 @@ enum index {
 	ACTION_PORT_REPRESENTOR_PORT_ID,
 	ACTION_REPRESENTED_PORT,
 	ACTION_REPRESENTED_PORT_ETHDEV_PORT_ID,
+	ACTION_SEND_TO_KERNEL,
 };
 
 /** Maximum size for pattern in struct rte_flow_item_raw. */
@@ -1888,6 +1889,7 @@ static const enum index next_action[] = {
 	ACTION_CONNTRACK_UPDATE,
 	ACTION_PORT_REPRESENTOR,
 	ACTION_REPRESENTED_PORT,
+	ACTION_SEND_TO_KERNEL,
 	ZERO,
 };
 
@@ -6098,6 +6100,13 @@ static const struct token token_list[] = {
 					width)),
 		.call = parse_vc_conf,
 	},
+	[ACTION_SEND_TO_KERNEL] = {
+		.name = "send_to_kernel",
+		.help = "send packets to kernel",
+		.priv = PRIV_ACTION(SEND_TO_KERNEL, 0),
+		.next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
+		.call = parse_vc,
+	},
 	/* Top level command. */
 	[SET] = {
 		.name = "set",
doc/guides/rel_notes/release_22_11.rst +5 -0
index c6bcb45100..7783eeb489 100644
@@ -114,6 +114,11 @@ New Features
   * Added ``rte_event_eth_tx_adapter_queue_stop`` to stop the Tx Adapter
     from enqueueing any packets to the Tx queue.
 
+* **Added new rte_flow action SEND_TO_KERNEL.**
+
+  Added new rte_flow action which allows application to re-route packets
+  directly to the kernel without software involvement.
+
 
 Removed Items
 -------------
doc/guides/testpmd_app_ug/testpmd_funcs.rst +3 -0
index b4e9d978ba..a5b6fb12e3 100644
@@ -3691,6 +3691,9 @@ This section lists supported pattern items and their attributes, if any.
 
   - ``color {value}``: Meter color value(green/yellow/red).
 
+- ``send_to_kernel``: send packets to kernel.
+
+
 Actions list
 ^^^^^^^^^^^^
 
lib/ethdev/rte_flow.c +1 -0
index fd802f87a2..a6b1bf21c4 100644
@@ -257,6 +257,7 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = {
 	MK_FLOW_ACTION(PORT_REPRESENTOR, sizeof(struct rte_flow_action_ethdev)),
 	MK_FLOW_ACTION(REPRESENTED_PORT, sizeof(struct rte_flow_action_ethdev)),
 	MK_FLOW_ACTION(METER_MARK, sizeof(struct rte_flow_action_meter_mark)),
+	MK_FLOW_ACTION(SEND_TO_KERNEL, 0),
 };
 
 int
lib/ethdev/rte_flow.h +12 -0
index 49aaf05b67..c895c574cd 100644
@@ -2797,6 +2797,18 @@ enum rte_flow_action_type {
 	 * See file rte_mtr.h for MTR profile object configuration.
 	 */
 	RTE_FLOW_ACTION_TYPE_METER_MARK,
+
+	/**
+	 * Send packets to the kernel, without going to userspace at all.
+	 * The packets will be received by the kernel driver sharing
+	 * the same device as the DPDK port on which this action is
+	 * configured. This action is mostly suits bifurcated driver
+	 * model.
+	 * This is an ingress non-transfer action only.
+	 *
+	 * No associated configuration structure.
+	 */
+	RTE_FLOW_ACTION_TYPE_SEND_TO_KERNEL,
 };
 
 /**
Signature · 1 line
2.27.0
Acked-by on v5 1/1 Applied
#22 lore raw
Quoted 18 lines · Michael Savisko

In some cases application may receive a packet that should have been received by the kernel. In this case application uses KNI or other means to transfer the packet to the kernel.

With bifurcated driver we can have a rule to route packets matching a pattern (example: IPv4 packets) to the DPDK application and the rest of the traffic will be received by the kernel.
But if we want to receive most of the traffic in DPDK except specific pattern (example: ICMP packets) that should be processed by the kernel, then it's easier to re-route these packets with a single rule.

This commit introduces new rte_flow action which allows application to re-route packets directly to the kernel without software involvement.

Add new testpmd rte_flow action 'send_to_kernel'. The application may use this action to route the packet to the kernel while still in the HW.

Quoted 7 lines

Example with testpmd command:

flow create 0 ingress priority 0 group 1 pattern eth type spec 0x0800 type mask 0xffff / end actions send_to_kernel / end

Applied to dpdk-next-net/main, thanks.

Acked-by on v2 1/1
#23 lore raw
In reply to Michael Savisko

Hi Michael,

Quoted 121 lines

-----Original Message-----
From: Michael Savisko <[email protected]>
Sent: Wednesday, 14 September 2022 12:32

In some cases application may receive a packet that should have been received by the kernel. In this case application uses KNI or other means to transfer the packet to the kernel.

With bifurcated driver we can have a rule to route packets matching a pattern (example: IPv4 packets) to the DPDK application and the rest of the traffic will be received by the kernel.
But if we want to receive most of the traffic in DPDK except specific pattern (example: ICMP packets) that should be processed by the kernel, then it's easier to re-route these packets with a single rule.

This commit introduces new rte_flow action which allows application to re-route packets directly to the kernel without software involvement.

Add new testpmd rte_flow action 'send_to_kernel'. The application may use this action to route the packet to the kernel while still in the HW.

Example with testpmd command:

flow create 0 ingress priority 0 group 1 pattern eth type spec 0x0800 type mask 0xffff / end actions send_to_kernel / end

---
 app/test-pmd/cmdline_flow.c                 | 9 +++++++++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst | 2 ++
 lib/ethdev/rte_flow.c                       | 1 +
 lib/ethdev/rte_flow.h                       | 9 +++++++++
 4 files changed, 21 insertions(+)
app/test-pmd/cmdline_flow.c +9 -0
index 7f50028eb7..042f6b34a6 100644
@@ -612,6 +612,7 @@ enum index {
 	ACTION_PORT_REPRESENTOR_PORT_ID,
 	ACTION_REPRESENTED_PORT,
 	ACTION_REPRESENTED_PORT_ETHDEV_PORT_ID,
+	ACTION_SEND_TO_KERNEL,
 };
 
 /** Maximum size for pattern in struct rte_flow_item_raw. */
@@ -1872,6 +1873,7 @@ static const enum index next_action[] = {
 	ACTION_CONNTRACK_UPDATE,
 	ACTION_PORT_REPRESENTOR,
 	ACTION_REPRESENTED_PORT,
+	ACTION_SEND_TO_KERNEL,
 	ZERO,
 };
 
@@ -6341,6 +6343,13 @@ static const struct token token_list[] = {
 		.help = "submit a list of associated actions for red",
 		.next = NEXT(next_action),
 	},
+	[ACTION_SEND_TO_KERNEL] = {
+		.name = "send_to_kernel",
+		.help = "send packets to kernel",
+		.priv = PRIV_ACTION(SEND_TO_KERNEL, 0),
+		.next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
+		.call = parse_vc,
+	},
 
 	/* Top-level command. */
 	[ADD] = {
doc/guides/testpmd_app_ug/testpmd_funcs.rst +0 -0
index 330e34427d..c259c8239a 100644
@@ -4189,6 +4189,8 @@ This section lists supported actions and their

attributes, if any.

- ``ethdev_port_id {unsigned}``: ethdev port ID

+- ``send_to_kernel``: send packets to kernel.

doc/guides/testpmd_app_ug/testpmd_funcs.rst +1 -0
+
 Destroying flow rules
 ~~~~~~~~~~~~~~~~~~~~~
lib/ethdev/rte_flow.c +0 -0
index 501be9d602..627c671ce4 100644
@@ -259,6 +259,7 @@ static const struct rte_flow_desc_data
 rte_flow_desc_action[] = {
 	MK_FLOW_ACTION(CONNTRACK, sizeof(struct
 rte_flow_action_conntrack)),
 	MK_FLOW_ACTION(PORT_REPRESENTOR, sizeof(struct
 rte_flow_action_ethdev)),
 	MK_FLOW_ACTION(REPRESENTED_PORT, sizeof(struct

rte_flow_action_ethdev)),

lib/ethdev/rte_flow.c +1 -0
+	MK_FLOW_ACTION(SEND_TO_KERNEL, 0),
 };
 
 int
lib/ethdev/rte_flow.h +9 -1
index a79f1e7ef0..a82992a6ae 100644
@@ -2879,6 +2879,15 @@ enum rte_flow_action_type {
 	 * @see struct rte_flow_action_ethdev
 	 */
 	RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT,
+
+	/*
+	 * Send packets to the kernel, without going to userspace at all.
+	 * The packets will be received by the kernel driver sharing
+	 * the same device as the DPDK port.
+	 *
+	 * No associated configuration structure.
+	 */
+	RTE_FLOW_ACTION_TYPE_SEND_TO_KERNEL,
 };
 
 /**
--
Quoted 1 line

2.27.0

Best,
Ori