Skip to contentSkip to conversation

doc: add sampling and mirroring in testpmd guide

PATCH Superseded Jiawei Wang 3 participants 11 messages Mar 9, 2021 – Apr 1, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 doc: add sampling and mirroring in testpmd guide

Update documentation for sample action usage in testpmd and show the command line example.

---
 doc/guides/testpmd_app_ug/testpmd_funcs.rst | 60 +++++++++++++++++++++++++++++
 1 file changed, 60 insertions(+)
doc/guides/testpmd_app_ug/testpmd_funcs.rst +60 -0
index f59eb8a..3a31cc6 100644
@@ -2003,6 +2003,24 @@ Set fec mode for a specific port::
 
   testpmd> set port (port_id) fec_mode auto|off|rs|baser
 
+Config Sample actions list
+~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Configure the sample actions list to be used when sampling a packet by
+rte_flow_action_sample::
+
+ set sample_actions {index} {action} [/ {action} [...]] / end
+
+There are multiple global buffers for ``sample_actions``, this command will set
+one internal buffer index by ``{index}``.
+
+In order to use different sample actions list, ``index`` must be specified
+during the flow rule creation::
+
+ testpmd> flow create 0 ingress pattern eth / ipv4 / end actions
+        sample ratio 2 index 2 / end
+
+Otherwise the default index ``0`` is used.
 
 Port Functions
 --------------
@@ -4841,6 +4859,48 @@ if seid is set)::
  testpmd> flow create 0 ingress pattern eth / ipv6 / pfcp s_field is 1
         seid is 1 / end actions queue index 3 / end
 
+Sample Sampling/Mirroring rules
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Sample/Mirroring rules can be set by the following commands
+
+NIC-RX Sampling rule, the matched ingress packets are duplicated and sent to
+the queue 1, and each second packets are marked with 0x1234 and sent to
+queue 0.
+
+::
+
+ testpmd> set sample_actions 0 mark id  0x1234 / queue index 0 / end
+ testpmd> flow create 0 ingress group 1 pattern eth / end actions
+        sample ratio 2 index 0 / queue index 1 / end
+
+E-Switch Sampling rule, the matched ingress packets are duplicated and sent
+to port id 2, and each second packets are sent to eswitch manager.
+
+::
+
+ testpmd> set sample_actions 0 / end
+ testpmd> flow create 0 ingress transfer pattern eth / end actions
+        sample ratio 2 index 0 / port_id id 2 / end
+
+E-Switch Mirroring rule, the matched ingress packets with encapsulation header
+are sent to port id 0, and also mirrored the packets and sent to port id 2.
+
+::
+
+ testpmd> set sample_actions 0 port_id id 2 / end
+ testpmd> flow create 1 ingress transfer pattern eth / end actions
+        sample ratio 1 index 0  / raw_encap / port_id id 0 / end
+
+E-Switch Mirroring rule, the matched ingress packets are sent to port id 2,
+and also mirrored the packets with encapsulation header and sent to port id 0.
+
+::
+
+ testpmd> set sample_actions 0 raw_encap / port_id id 0 / end
+ testpmd> flow create 0 ingress transfer pattern eth / end actions
+        sample ratio 1 index 0  / port_id id 2 / end
+
 BPF Functions
 --------------
 
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 3 lines · Jiawei Wang

Update documentation for sample action usage in testpmd and show the command line example.

+1 to document this.

Indeed for all testpmd flow update, it must be mandatory to update "Flow rules management" section for it, Ori what do you think?

Quoted 2 lines

<...>

doc/guides/testpmd_app_ug/testpmd_funcs.rst if seid is set):: · line 4870

Quoted 9 lines
doc/guides/testpmd_app_ug/testpmd_funcs.rst +9 -0
+Sample Sampling/Mirroring rules
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Sample/Mirroring rules can be set by the following commands
+
+NIC-RX Sampling rule, the matched ingress packets are duplicated and sent to
+the queue 1, and each second packets are marked with 0x1234 and sent to
+queue 0.
+

Also each second packets duplicated to queue 1, isn't it, because of 'ratio 2'?

doc/guides/testpmd_app_ug/testpmd_funcs.rst if seid is set):: · line 4879

Quoted 9 lines

+::

doc/guides/testpmd_app_ug/testpmd_funcs.rst +8 -0
+
+ testpmd> set sample_actions 0 mark id  0x1234 / queue index 0 / end
+ testpmd> flow create 0 ingress group 1 pattern eth / end actions
+        sample ratio 2 index 0 / queue index 1 / end
+
+E-Switch Sampling rule, the matched ingress packets are duplicated and sent
+to port id 2, and each second packets are sent to eswitch manager.
+

what is 'E-Switch', or "eswitch manager", isn't the mirror rule generic?

#2 lore raw

25/03/2021 18:10, Ferruh Yigit:

Quoted 27 lines · Jiawei Wang
Quoted 3 lines

Update documentation for sample action usage in testpmd and show the command line example.

+1 to document this.

Indeed for all testpmd flow update, it must be mandatory to update "Flow rules management" section for it, Ori what do you think?

Quoted 2 lines

<...>

doc/guides/testpmd_app_ug/testpmd_funcs.rst if seid is set):: · line 4870

Quoted 9 lines
doc/guides/testpmd_app_ug/testpmd_funcs.rst +9 -0
+Sample Sampling/Mirroring rules
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Sample/Mirroring rules can be set by the following commands
+
+NIC-RX Sampling rule, the matched ingress packets are duplicated and sent to
+the queue 1, and each second packets are marked with 0x1234 and sent to
+queue 0.
+

Also each second packets duplicated to queue 1, isn't it, because of 'ratio 2'?

Quoted 11 lines

doc/guides/testpmd_app_ug/testpmd_funcs.rst if seid is set):: · line 4879

Quoted 9 lines

+::

doc/guides/testpmd_app_ug/testpmd_funcs.rst +8 -0
+
+ testpmd> set sample_actions 0 mark id  0x1234 / queue index 0 / end
+ testpmd> flow create 0 ingress group 1 pattern eth / end actions
+        sample ratio 2 index 0 / queue index 1 / end
+
+E-Switch Sampling rule, the matched ingress packets are duplicated and sent
+to port id 2, and each second packets are sent to eswitch manager.
+

what is 'E-Switch', or "eswitch manager", isn't the mirror rule generic?

This is the HW switch in Mellanox devices.
It should not be mentioned in this generic doc.

#3 lore raw

Hi Thomas,

Quoted 48 lines

-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Friday, March 26, 2021 1:16 AM
To: Jiawei(Jonny) Wang <[email protected]>; Slava Ovsiienko <[email protected]>; Ori Kam <[email protected]>; Ferruh Yigit <[email protected]>
Cc: [email protected]; [email protected]; Andrew Rybchenko <[email protected]>
Subject: Re: [PATCH] doc: add sampling and mirroring in testpmd guide

25/03/2021 18:10, Ferruh Yigit:

Quoted 27 lines · Jiawei Wang
Quoted 3 lines

Update documentation for sample action usage in testpmd and show the command line example.

+1 to document this.

Indeed for all testpmd flow update, it must be mandatory to update "Flow rules management" section for it, Ori what do you think?

Quoted 2 lines

<...>

doc/guides/testpmd_app_ug/testpmd_funcs.rst if seid is set):: · line 4870

Quoted 9 lines
doc/guides/testpmd_app_ug/testpmd_funcs.rst +9 -0
+Sample Sampling/Mirroring rules
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Sample/Mirroring rules can be set by the following commands
+
+NIC-RX Sampling rule, the matched ingress packets are duplicated
+and sent to the queue 1, and each second packets are marked with
+0x1234 and sent to queue 0.
+

Also each second packets duplicated to queue 1, isn't it, because of 'ratio 2'?

Quoted 9 lines

Review

Quoted 9 lines

+::

(quoted diff) +8 -0
+
+ testpmd> set sample_actions 0 mark id  0x1234 / queue index 0 /
+ testpmd> end flow create 0 ingress group 1 pattern eth / end
+ testpmd> actions
+        sample ratio 2 index 0 / queue index 1 / end
+
+E-Switch Sampling rule, the matched ingress packets are duplicated
+and sent to port id 2, and each second packets are sent to eswitch

manager.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

+

what is 'E-Switch', or "eswitch manager", isn't the mirror rule generic?

This is the HW switch in Mellanox devices. It should not be mentioned in this generic doc.

Yes, I will remove it and send v2 patch.
Thanks.

#4 lore raw
In reply to Ferruh Yigit

Hi Ferruh,

Quoted 25 lines

-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Friday, March 26, 2021 1:11 AM
To: Jiawei(Jonny) Wang <[email protected]>; Slava Ovsiienko <[email protected]>; [email protected]; Ori Kam <[email protected]>
Cc: [email protected]; Andrew Rybchenko <[email protected]>; NBU- Contact-Thomas Monjalon <[email protected]>
Subject: Re: [PATCH] doc: add sampling and mirroring in testpmd guide

Quoted 3 lines · Jiawei Wang

Update documentation for sample action usage in testpmd and show the command line example.

+1 to document this.

Indeed for all testpmd flow update, it must be mandatory to update "Flow rules management" section for it, Ori what do you think?

Quoted 2 lines

<...>

Quoted 12 lines

doc/guides/testpmd_app_ug/testpmd_funcs.rst if seid is set):: · line 4870

Quoted 9 lines
doc/guides/testpmd_app_ug/testpmd_funcs.rst +9 -0
+Sample Sampling/Mirroring rules
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Sample/Mirroring rules can be set by the following commands
+
+NIC-RX Sampling rule, the matched ingress packets are duplicated and
+sent to the queue 1, and each second packets are marked with 0x1234
+and sent to queue 0.
+

Also each second packets duplicated to queue 1, isn't it, because of 'ratio 2'?

Yes, 'ratio=2' means that 50% packet will be sampled.

Quoted 9 lines

doc/guides/testpmd_app_ug/testpmd_funcs.rst if seid is set)::

Quoted 8 lines

+::

doc/guides/testpmd_app_ug/testpmd_funcs.rst +7 -0
+
+ testpmd> set sample_actions 0 mark id  0x1234 / queue index 0 / end
+ testpmd> flow create 0 ingress group 1 pattern eth / end actions
+        sample ratio 2 index 0 / queue index 1 / end
+
+E-Switch Sampling rule, the matched ingress packets are duplicated
+and sent to port id 2, and each second packets are sent to eswitch

manager.

Quoted 3 lines
Quoted 1 line

+

what is 'E-Switch', or "eswitch manager", isn't the mirror rule generic?

Here E-Switch means 'transfer=1' in flow attribute, I will remove it since the concept is for Mellanox HW.

#5 lore raw
Quoted 40 lines · Jiawei(Jonny) Wang

Hi Ferruh,

Quoted 25 lines

-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Friday, March 26, 2021 1:11 AM
To: Jiawei(Jonny) Wang <[email protected]>; Slava Ovsiienko <[email protected]>; [email protected]; Ori Kam <[email protected]>
Cc: [email protected]; Andrew Rybchenko <[email protected]>; NBU- Contact-Thomas Monjalon <[email protected]>
Subject: Re: [PATCH] doc: add sampling and mirroring in testpmd guide

Quoted 3 lines · Jiawei Wang

Update documentation for sample action usage in testpmd and show the command line example.

+1 to document this.

Indeed for all testpmd flow update, it must be mandatory to update "Flow rules management" section for it, Ori what do you think?

Quoted 2 lines

<...>

Quoted 12 lines

doc/guides/testpmd_app_ug/testpmd_funcs.rst if seid is set):: · line 4870

Quoted 9 lines
doc/guides/testpmd_app_ug/testpmd_funcs.rst +9 -0
+Sample Sampling/Mirroring rules
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Sample/Mirroring rules can be set by the following commands
+
+NIC-RX Sampling rule, the matched ingress packets are duplicated and
+sent to the queue 1, and each second packets are marked with 0x1234
+and sent to queue 0.
+

Also each second packets duplicated to queue 1, isn't it, because of 'ratio 2'?

Quoted 2 lines

Yes, 'ratio=2' means that 50% packet will be sampled.

I thought 'sample' action also applies to the "queue index 1" but most probably it only applies to 'sample_actions', so original paragraph is correct, perhaps except the 'duplicated' detail, and my comment "each second packets duplicated to queue 1" is wrong.

Can you please confirm if below is correct:
Assume 10 packets are received, from 1 to 10, after below rule queue status will be:
Queue0: 2, 4, 6, 8, 10 [All marked with 0x1234, duplicated packets]
Queue1: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 [Original packets]

Quoted 15 lines
Quoted 9 lines

doc/guides/testpmd_app_ug/testpmd_funcs.rst if seid is set)::

Quoted 8 lines

+::

doc/guides/testpmd_app_ug/testpmd_funcs.rst +7 -0
+
+ testpmd> set sample_actions 0 mark id  0x1234 / queue index 0 / end
+ testpmd> flow create 0 ingress group 1 pattern eth / end actions
+        sample ratio 2 index 0 / queue index 1 / end
+
+E-Switch Sampling rule, the matched ingress packets are duplicated
+and sent to port id 2, and each second packets are sent to eswitch

manager.

Quoted 3 lines
Quoted 1 line

+

what is 'E-Switch', or "eswitch manager", isn't the mirror rule generic?

Here E-Switch means 'transfer=1' in flow attribute, I will remove it since the concept is for Mellanox HW.

#6 lore raw

Hi Ferruh,

Quoted 53 lines

-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Wednesday, March 31, 2021 5:45 PM
To: Jiawei(Jonny) Wang <[email protected]>; Slava Ovsiienko <[email protected]>; [email protected]; Ori Kam <[email protected]>
Cc: [email protected]; Andrew Rybchenko <[email protected]>; NBU- Contact-Thomas Monjalon <[email protected]>
Subject: Re: [PATCH] doc: add sampling and mirroring in testpmd guide

Quoted 9 lines · Jiawei(Jonny) Wang

Hi Ferruh,

Quoted 7 lines

-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Friday, March 26, 2021 1:11 AM
To: Jiawei(Jonny) Wang <[email protected]>; Slava Ovsiienko <[email protected]>; [email protected]; Ori Kam <[email protected]>
Cc: [email protected]; Andrew Rybchenko <[email protected]>;

NBU-

Quoted 18 lines
Quoted 18 lines

Contact-Thomas Monjalon <[email protected]>
Subject: Re: [PATCH] doc: add sampling and mirroring in testpmd guide

Quoted 3 lines · Jiawei Wang

Update documentation for sample action usage in testpmd and show the command line example.

+1 to document this.

Indeed for all testpmd flow update, it must be mandatory to update "Flow rules management" section for it, Ori what do you think?

Quoted 2 lines

<...>

Quoted 11 lines
Quoted 11 lines

doc/guides/testpmd_app_ug/testpmd_funcs.rst if seid is set):: · line 4870

Quoted 9 lines
doc/guides/testpmd_app_ug/testpmd_funcs.rst +9 -0
+Sample Sampling/Mirroring rules
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Sample/Mirroring rules can be set by the following commands
+
+NIC-RX Sampling rule, the matched ingress packets are duplicated
+and sent to the queue 1, and each second packets are marked with
+0x1234 and sent to queue 0.
+

Also each second packets duplicated to queue 1, isn't it, because of 'ratio

2'?

Quoted 2 lines
Quoted 1 line
Quoted 8 lines
Quoted 2 lines

Yes, 'ratio=2' means that 50% packet will be sampled.

I thought 'sample' action also applies to the "queue index 1" but most probably it only applies to 'sample_actions', so original paragraph is correct, perhaps except the 'duplicated' detail, and my comment "each second packets duplicated to queue 1" is wrong.

Here sample action is 'Queue index 0" and original action is 'Queue index 1", sample action only impact on duplicated packets, so 50% duplicated to queue 0.

Quoted 7 lines

Can you please confirm if below is correct:
Assume 10 packets are received, from 1 to 10, after below rule queue status will be:
Queue0: 2, 4, 6, 8, 10 [All marked with 0x1234, duplicated packets]
Queue1: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 [Original packets]

My description is not correct here.
The Marked 0x1234 and 5 duplicated packet will be sent to queue 0; But the duplicated packet order not strict 'each second packet'. All of the 10 packet will be sent to Queue 1 without mark.

I will update as below:
"
NIC-RX Sampling rule, the matched ingress packets are sent to the queue 1, and 50% packets are duplicated and marked with 0x1234 and sent to queue 0. "

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

Review

Quoted 9 lines

+::

(quoted diff) +8 -0
+
+ testpmd> set sample_actions 0 mark id  0x1234 / queue index 0 /
+ testpmd> end flow create 0 ingress group 1 pattern eth / end
+ testpmd> actions
+        sample ratio 2 index 0 / queue index 1 / end
+
+E-Switch Sampling rule, the matched ingress packets are duplicated
+and sent to port id 2, and each second packets are sent to eswitch

manager.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

+

what is 'E-Switch', or "eswitch manager", isn't the mirror rule generic?

Here E-Switch means 'transfer=1' in flow attribute, I will remove it since

the concept is for Mellanox HW.

Quoted 1 line

Thanks.

#7 lore raw
Quoted 80 lines · Jiawei(Jonny) Wang

Hi Ferruh,

Quoted 53 lines

-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Wednesday, March 31, 2021 5:45 PM
To: Jiawei(Jonny) Wang <[email protected]>; Slava Ovsiienko <[email protected]>; [email protected]; Ori Kam <[email protected]>
Cc: [email protected]; Andrew Rybchenko <[email protected]>; NBU- Contact-Thomas Monjalon <[email protected]>
Subject: Re: [PATCH] doc: add sampling and mirroring in testpmd guide

Quoted 9 lines · Jiawei(Jonny) Wang

Hi Ferruh,

Quoted 7 lines

-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Friday, March 26, 2021 1:11 AM
To: Jiawei(Jonny) Wang <[email protected]>; Slava Ovsiienko <[email protected]>; [email protected]; Ori Kam <[email protected]>
Cc: [email protected]; Andrew Rybchenko <[email protected]>;

NBU-

Quoted 18 lines
Quoted 18 lines

Contact-Thomas Monjalon <[email protected]>
Subject: Re: [PATCH] doc: add sampling and mirroring in testpmd guide

Quoted 3 lines · Jiawei Wang

Update documentation for sample action usage in testpmd and show the command line example.

+1 to document this.

Indeed for all testpmd flow update, it must be mandatory to update "Flow rules management" section for it, Ori what do you think?

Quoted 2 lines

<...>

Quoted 11 lines
Quoted 11 lines

doc/guides/testpmd_app_ug/testpmd_funcs.rst if seid is set):: · line 4870

Quoted 9 lines
doc/guides/testpmd_app_ug/testpmd_funcs.rst +9 -0
+Sample Sampling/Mirroring rules
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Sample/Mirroring rules can be set by the following commands
+
+NIC-RX Sampling rule, the matched ingress packets are duplicated
+and sent to the queue 1, and each second packets are marked with
+0x1234 and sent to queue 0.
+

Also each second packets duplicated to queue 1, isn't it, because of 'ratio

2'?

Quoted 2 lines
Quoted 1 line
Quoted 8 lines
Quoted 2 lines

Yes, 'ratio=2' means that 50% packet will be sampled.

I thought 'sample' action also applies to the "queue index 1" but most probably it only applies to 'sample_actions', so original paragraph is correct, perhaps except the 'duplicated' detail, and my comment "each second packets duplicated to queue 1" is wrong.

Here sample action is 'Queue index 0" and original action is 'Queue index 1", sample action only impact on duplicated packets, so 50% duplicated to queue 0.

Quoted 7 lines

Can you please confirm if below is correct:
Assume 10 packets are received, from 1 to 10, after below rule queue status will be:
Queue0: 2, 4, 6, 8, 10 [All marked with 0x1234, duplicated packets]
Queue1: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 [Original packets]

My description is not correct here.
The Marked 0x1234 and 5 duplicated packet will be sent to queue 0; But the duplicated packet order not strict 'each second packet'. All of the 10 packet will be sent to Queue 1 without mark.

Quoted 6 lines

I will update as below:
"
NIC-RX Sampling rule, the matched ingress packets are sent to the queue 1, and 50% packets are duplicated and marked with 0x1234 and sent to queue 0. "

Above looks good, thanks.

Quoted 20 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

Review

Quoted 9 lines

+::

(quoted diff) +8 -0
+
+ testpmd> set sample_actions 0 mark id  0x1234 / queue index 0 /
+ testpmd> end flow create 0 ingress group 1 pattern eth / end
+ testpmd> actions
+        sample ratio 2 index 0 / queue index 1 / end
+
+E-Switch Sampling rule, the matched ingress packets are duplicated
+and sent to port id 2, and each second packets are sent to eswitch

manager.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

+

what is 'E-Switch', or "eswitch manager", isn't the mirror rule generic?

Here E-Switch means 'transfer=1' in flow attribute, I will remove it since

the concept is for Mellanox HW.

Quoted 1 line

Thanks.

#8 lore raw

PATCH v2 1/1 doc: add sampling and mirroring in testpmd guide

In reply to Jiawei Wang

Update documentation for sample action usage in testpmd and show the command line example.

---
v2:
* Update the description.

---
 doc/guides/testpmd_app_ug/testpmd_funcs.rst | 63 +++++++++++++++++++++++++++++
 1 file changed, 63 insertions(+)
doc/guides/testpmd_app_ug/testpmd_funcs.rst +63 -0
index f59eb8a..6606433 100644
@@ -2003,6 +2003,24 @@ Set fec mode for a specific port::
 
   testpmd> set port (port_id) fec_mode auto|off|rs|baser
 
+Config Sample actions list
+~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Configure the sample actions list to be used when sampling a packet by
+rte_flow_action_sample::
+
+ set sample_actions {index} {action} [/ {action} [...]] / end
+
+There are multiple global buffers for ``sample_actions``, this command will set
+one internal buffer index by ``{index}``.
+
+In order to use different sample actions list, ``index`` must be specified
+during the flow rule creation::
+
+ testpmd> flow create 0 ingress pattern eth / ipv4 / end actions
+        sample ratio 2 index 2 / end
+
+Otherwise the default index ``0`` is used.
 
 Port Functions
 --------------
@@ -4841,6 +4859,51 @@ if seid is set)::
  testpmd> flow create 0 ingress pattern eth / ipv6 / pfcp s_field is 1
         seid is 1 / end actions queue index 3 / end
 
+Sample Sampling/Mirroring rules
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Sample/Mirroring rules can be set by the following commands
+
+NIC-RX Sampling rule, the matched ingress packets and sent to the queue 1,
+also each second packets are duplicated and marked with 0x1234 and sent to
+queue 0.
+
+::
+
+ testpmd> set sample_actions 0 mark id  0x1234 / queue index 0 / end
+ testpmd> flow create 0 ingress group 1 pattern eth / end actions
+        sample ratio 2 index 0 / queue index 1 / end
+
+Sampling rule with port representors (with "transfer" attribute), the matched
+ingress packets are sent to port id 2, also each second packets are sent to
+PF port.
+
+::
+
+ testpmd> set sample_actions 0 / end
+ testpmd> flow create 0 ingress transfer pattern eth / end actions
+        sample ratio 2 index 0 / port_id id 2 / end
+
+Mirroring rule with port representors (with "transfer" attribute), the matched
+ingress packets with encapsulation header are sent to port id 0, and also
+mirrored the packets and sent to port id 2.
+
+::
+
+ testpmd> set sample_actions 0 port_id id 2 / end
+ testpmd> flow create 1 ingress transfer pattern eth / end actions
+        sample ratio 1 index 0  / raw_encap / port_id id 0 / end
+
+Mirroring rule with port representors (with "transfer" attribute), the matched
+ingress packets are sent to port id 2, and also mirrored the packets with
+encapsulation header and sent to port id 0.
+
+::
+
+ testpmd> set sample_actions 0 raw_encap / port_id id 0 / end
+ testpmd> flow create 0 ingress transfer pattern eth / end actions
+        sample ratio 1 index 0  / port_id id 2 / end
+
 BPF Functions
 --------------
 
Signature · 1 line
1.8.3.1
#9 lore raw

PATCH v3 1/1 doc: add sampling and mirroring in testpmd guide

In reply to Jiawei Wang

Update documentation for sample action usage in testpmd and show the command line example.

---
v3:
* Update the description for sampling.

v2:
* Update the description.

---
 doc/guides/testpmd_app_ug/testpmd_funcs.rst | 52 +++++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)
doc/guides/testpmd_app_ug/testpmd_funcs.rst +52 -0
index f59eb8a..2b407a3 100644
@@ -2003,6 +2003,24 @@ Set fec mode for a specific port::
 
   testpmd> set port (port_id) fec_mode auto|off|rs|baser
 
+Config Sample actions list
+~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Configure the sample actions list to be used when sampling a packet by
+rte_flow_action_sample::
+
+ set sample_actions {index} {action} [/ {action} [...]] / end
+
+There are multiple global buffers for ``sample_actions``, this command will set
+one internal buffer index by ``{index}``.
+
+In order to use different sample actions list, ``index`` must be specified
+during the flow rule creation::
+
+ testpmd> flow create 0 ingress pattern eth / ipv4 / end actions
+        sample ratio 2 index 2 / end
+
+Otherwise the default index ``0`` is used.
 
 Port Functions
 --------------
@@ -4841,6 +4859,40 @@ if seid is set)::
  testpmd> flow create 0 ingress pattern eth / ipv6 / pfcp s_field is 1
         seid is 1 / end actions queue index 3 / end
 
+Sample Sampling/Mirroring rules
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Sample/Mirroring rules can be set by the following commands
+
+NIC-RX Sampling rule, the matched ingress packets and sent to the queue 1,
+and 50% packets are duplicated and marked with 0x1234 and sent to queue 0.
+
+::
+
+ testpmd> set sample_actions 0 mark id  0x1234 / queue index 0 / end
+ testpmd> flow create 0 ingress group 1 pattern eth / end actions
+        sample ratio 2 index 0 / queue index 1 / end
+
+Mirroring rule with port representors (with "transfer" attribute), the matched
+ingress packets with encapsulation header are sent to port id 0, and also
+mirrored the packets and sent to port id 2.
+
+::
+
+ testpmd> set sample_actions 0 port_id id 2 / end
+ testpmd> flow create 1 ingress transfer pattern eth / end actions
+        sample ratio 1 index 0  / raw_encap / port_id id 0 / end
+
+Mirroring rule with port representors (with "transfer" attribute), the matched
+ingress packets are sent to port id 2, and also mirrored the packets with
+encapsulation header and sent to port id 0.
+
+::
+
+ testpmd> set sample_actions 0 raw_encap / port_id id 0 / end
+ testpmd> flow create 0 ingress transfer pattern eth / end actions
+        sample ratio 1 index 0  / port_id id 2 / end
+
 BPF Functions
 --------------
 
Signature · 1 line
1.8.3.1