[dpdk-dev,RFC,1/2] app/testpmd: add packet template

Message ID 20171019140649.26668-2-xuemingl@mellanox.com (mailing list archive)
State Superseded, archived
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Xueming Li Oct. 19, 2017, 2:06 p.m. UTC
  Txonly forwarding mode will check templates, if avaialbe, use templates
for each queue.

Signed-off-by: Xueming Li <xuemingl@mellanox.com>
---
 app/test-pmd/testpmd.c |  3 +++
 app/test-pmd/testpmd.h |  1 +
 app/test-pmd/txonly.c  | 42 ++++++++++++++++++++++++++----------------
 3 files changed, 30 insertions(+), 16 deletions(-)
  

Comments

Xueming Li Dec. 5, 2017, 4:43 a.m. UTC | #1
Thiss patch introduces a set of new elements into DPDK:
1. python/scapy as a standard dpdk library, disabled by default.
   Could be used by any application to integrate powerful python features.
2. tx, rx and expect, blocking mode testpmd CLI command
   tx command send packets with scapy syntax template, support range/enum, be able to generate multiple flows in one command and DPDK speed.
   rx command receive packets with timeout, with several choices on how to dump packets and mbuf headers.
   expect command try to send out packet, receive and compare with the packet sent, support mbuf header and packet header comparation, show detail info or hexdiff if anything different. Expect command is suitable for unit test and regression test by saving batch expect scripts into a file and use 'load' command to invoke them together.
3. pktgen - new testpmd forwarding engine
   Used to support tx, rx and expect blocking command.
   Also support rxonly/loopback/forward/macswap non-blocking idle modes with several packet dump choice.
4. py command - new testpmd CLI
   Run and evaluate python clause in a global context, samples:
    - py a = 123; b=0xaaa; hex(a+b)
    - py eth=Ether();ip=IP();
    - py hexdump(eth/ip/UDP());
    - tx 0 eth/ip
   py shell: sneak into python shell

The purpose of this scapy/python integration is to help programmers to speed up unit test w/o writing complex c code, verify features with batch expect scripts. Testpmd already a widely used platform for people to setup PMD and verify features with rich CLI command, that's why I choose to make new CLI on this familier tool instead of creating a new one.

I made hundreds of expect test cases when developing rte_flow vxlan and GRE features, that makes me pretty confident to touch any code, hope this tool help you as well.

quick guide document:
	https://github.com/steevenlee/dpdk/blob/master_scapy/doc/guides/howto/scapy.rst
github branch:
        https://github.com/steevenlee/dpdk/tree/master_scapy


v1:
* make scapy standard lib, default to disabled
* introduce pktgen forwarding engine for tx, rx and expect command
* py command to evaluate python clause or invoke python shell in testpmd
* batch expect sample file

v0:
* basic scapy lib
* scapy command

Xueming Li (11):
  lib/cmdline: support backspace key
  lib/cmdline: init parse result memeory
  lib/cmdline: add echo support in batch loading from file
  app/testpmd: support command echo in CLI batch loading
  test: update batch loading test
  lib/python: add embedded python lib
  app/testpmd: add python command
  app/testpmd: add pktgen forwarding engine
  app/testpmd: add pktgen engine scapy commands
  test/expect: add expect test scripts
  doc/scapy: add scapy how-to guide

 app/test-pmd/Makefile                    |    6 +
 app/test-pmd/cmdline.c                   |   80 ++-
 app/test-pmd/pktgen.c                    | 1092 ++++++++++++++++++++++++++++++
 app/test-pmd/testpmd.c                   |    1 +
 app/test-pmd/testpmd.h                   |    5 +
 config/common_base                       |    6 +
 doc/guides/howto/scapy.rst               |  300 ++++++++
 lib/Makefile                             |    2 +
 lib/librte_cmdline/cmdline_parse.c       |    2 +
 lib/librte_cmdline/cmdline_rdline.c      |    1 +
 lib/librte_cmdline/cmdline_socket.c      |    5 +-
 lib/librte_cmdline/cmdline_socket.h      |    3 +-
 lib/librte_cmdline/cmdline_vt100.c       |    1 +
 lib/librte_cmdline/cmdline_vt100.h       |    1 +
 lib/librte_eal/common/include/rte_log.h  |    1 +
 lib/librte_python/Makefile               |   60 ++
 lib/librte_python/rte_python.c           |  387 +++++++++++
 lib/librte_python/rte_python.h           |   71 ++
 lib/librte_python/rte_python_version.map |   12 +
 mk/rte.app.mk                            |    1 +
 test/expect/init.exp                     |   28 +
 test/expect/rx.exp                       |  134 ++++
 test/test/test_cmdline_lib.c             |   10 +-
 23 files changed, 2199 insertions(+), 10 deletions(-)
 create mode 100644 app/test-pmd/pktgen.c
 create mode 100644 doc/guides/howto/scapy.rst
 create mode 100644 lib/librte_python/Makefile
 create mode 100644 lib/librte_python/rte_python.c
 create mode 100644 lib/librte_python/rte_python.h
 create mode 100644 lib/librte_python/rte_python_version.map
 create mode 100644 test/expect/init.exp
 create mode 100644 test/expect/rx.exp
  
Xueming Li Dec. 5, 2017, 4:45 a.m. UTC | #2
Thiss patch introduces a set of new elements into DPDK:
1. python/scapy as a standard dpdk library, disabled by default.
   Could be used by any application to integrate powerful python features.
2. tx, rx and expect, blocking mode testpmd CLI command
   tx command send packets with scapy syntax template, support range/enum, be able to generate multiple flows in one command and DPDK speed.
   rx command receive packets with timeout, with several choices on how to dump packets and mbuf headers.
   expect command try to send out packet, receive and compare with the packet sent, support mbuf header and packet header comparation, show detail info or hexdiff if anything different. Expect command is suitable for unit test and regression test by saving batch expect scripts into a file and use 'load' command to invoke them together.
3. pktgen - new testpmd forwarding engine
   Used to support tx, rx and expect blocking command.
   Also support rxonly/loopback/forward/macswap non-blocking idle modes with several packet dump choice.
4. py command - new testpmd CLI
   Run and evaluate python clause in a global context, samples:
    - py a = 123; b=0xaaa; hex(a+b)
    - py eth=Ether();ip=IP();
    - py hexdump(eth/ip/UDP());
    - tx 0 eth/ip
   py shell: sneak into python shell

The purpose of this scapy/python integration is to help programmers to speed up unit test w/o writing complex c code, verify features with batch expect scripts. Testpmd already a widely used platform for people to setup PMD and verify features with rich CLI command, that's why I choose to make new CLI on this familier tool instead of creating a new one.

I made hundreds of expect test cases when developing rte_flow vxlan and GRE features, that makes me pretty confident to touch any code, hope this tool help you as well.

quick guide document:
	https://github.com/steevenlee/dpdk/blob/master_scapy/doc/guides/howto/scapy.rst
github branch:
        https://github.com/steevenlee/dpdk/tree/master_scapy


v1:
* make scapy standard lib, default to disabled
* introduce pktgen forwarding engine for tx, rx and expect command
* py command to evaluate python clause or invoke python shell in testpmd
* batch expect sample file

v0:
* basic scapy lib
* scapy command

Xueming Li (11):
  lib/cmdline: support backspace key
  lib/cmdline: init parse result memeory
  lib/cmdline: add echo support in batch loading from file
  app/testpmd: support command echo in CLI batch loading
  test: update batch loading test
  lib/python: add embedded python lib
  app/testpmd: add python command
  app/testpmd: add pktgen forwarding engine
  app/testpmd: add pktgen engine scapy commands
  test/expect: add expect test scripts
  doc/scapy: add scapy how-to guide

 app/test-pmd/Makefile                    |    6 +
 app/test-pmd/cmdline.c                   |   80 ++-
 app/test-pmd/pktgen.c                    | 1092 ++++++++++++++++++++++++++++++
 app/test-pmd/testpmd.c                   |    1 +
 app/test-pmd/testpmd.h                   |    5 +
 config/common_base                       |    6 +
 doc/guides/howto/scapy.rst               |  300 ++++++++
 lib/Makefile                             |    2 +
 lib/librte_cmdline/cmdline_parse.c       |    2 +
 lib/librte_cmdline/cmdline_rdline.c      |    1 +
 lib/librte_cmdline/cmdline_socket.c      |    5 +-
 lib/librte_cmdline/cmdline_socket.h      |    3 +-
 lib/librte_cmdline/cmdline_vt100.c       |    1 +
 lib/librte_cmdline/cmdline_vt100.h       |    1 +
 lib/librte_eal/common/include/rte_log.h  |    1 +
 lib/librte_python/Makefile               |   60 ++
 lib/librte_python/rte_python.c           |  387 +++++++++++
 lib/librte_python/rte_python.h           |   71 ++
 lib/librte_python/rte_python_version.map |   12 +
 mk/rte.app.mk                            |    1 +
 test/expect/init.exp                     |   28 +
 test/expect/rx.exp                       |  134 ++++
 test/test/test_cmdline_lib.c             |   10 +-
 23 files changed, 2199 insertions(+), 10 deletions(-)
 create mode 100644 app/test-pmd/pktgen.c
 create mode 100644 doc/guides/howto/scapy.rst
 create mode 100644 lib/librte_python/Makefile
 create mode 100644 lib/librte_python/rte_python.c
 create mode 100644 lib/librte_python/rte_python.h
 create mode 100644 lib/librte_python/rte_python_version.map
 create mode 100644 test/expect/init.exp
 create mode 100644 test/expect/rx.exp
  
Xueming Li Dec. 5, 2017, 4:48 a.m. UTC | #3
This patch introduces a set of new elements into DPDK:
1. python/scapy as a standard dpdk library, disabled by default.
   Could be used by any application to integrate powerful python features.
2. tx, rx and expect, blocking mode testpmd CLI command
   tx command send packets with scapy syntax template, support range/enum, be able to generate multiple flows in one command and DPDK speed.
   rx command receive packets with timeout, with several choices on how to dump packets and mbuf headers.
   expect command try to send out packet, receive and compare with the packet sent, support mbuf header and packet header comparation, show detail info or hexdiff if anything different. Expect command is suitable for unit test and regression test by saving batch expect scripts into a file and use 'load' command to invoke them together.
3. pktgen - new testpmd forwarding engine
   Used to support tx, rx and expect blocking command.
   Also support rxonly/loopback/forward/macswap non-blocking idle modes with several packet dump choice.
4. py command - new testpmd CLI
   Run and evaluate python clause in a global context, samples:
    - py a = 123; b=0xaaa; hex(a+b)
    - py eth=Ether();ip=IP();
    - py hexdump(eth/ip/UDP());
    - tx 0 eth/ip
   py shell: sneak into python shell

The purpose of this scapy/python integration is to help programmers to speed up unit test w/o writing complex c code, verify features with batch expect scripts. Testpmd already a widely used platform for people to setup PMD and verify features with rich CLI command, that's why I choose to make new CLI on this familier tool instead of creating a new one.

I made hundreds of expect test cases when developing rte_flow vxlan and GRE features, that makes me pretty confident to touch any code, hope this tool help you as well.

quick guide document:
	https://github.com/steevenlee/dpdk/blob/master_scapy/doc/guides/howto/scapy.rst
github branch:
        https://github.com/steevenlee/dpdk/tree/master_scapy


v1:
* make scapy standard lib, default to disabled
* introduce pktgen forwarding engine for tx, rx and expect command
* py command to evaluate python clause or invoke python shell in testpmd
* batch expect sample file

v0:
* basic scapy lib
* scapy command

Xueming Li (11):
  lib/cmdline: support backspace key
  lib/cmdline: init parse result memeory
  lib/cmdline: add echo support in batch loading from file
  app/testpmd: support command echo in CLI batch loading
  test: update batch loading test
  lib/python: add embedded python lib
  app/testpmd: add python command
  app/testpmd: add pktgen forwarding engine
  app/testpmd: add pktgen engine scapy commands
  test/expect: add expect test scripts
  doc/scapy: add scapy how-to guide

 app/test-pmd/Makefile                    |    6 +
 app/test-pmd/cmdline.c                   |   80 ++-
 app/test-pmd/pktgen.c                    | 1092 ++++++++++++++++++++++++++++++
 app/test-pmd/testpmd.c                   |    1 +
 app/test-pmd/testpmd.h                   |    5 +
 config/common_base                       |    6 +
 doc/guides/howto/scapy.rst               |  300 ++++++++
 lib/Makefile                             |    2 +
 lib/librte_cmdline/cmdline_parse.c       |    2 +
 lib/librte_cmdline/cmdline_rdline.c      |    1 +
 lib/librte_cmdline/cmdline_socket.c      |    5 +-
 lib/librte_cmdline/cmdline_socket.h      |    3 +-
 lib/librte_cmdline/cmdline_vt100.c       |    1 +
 lib/librte_cmdline/cmdline_vt100.h       |    1 +
 lib/librte_eal/common/include/rte_log.h  |    1 +
 lib/librte_python/Makefile               |   60 ++
 lib/librte_python/rte_python.c           |  387 +++++++++++
 lib/librte_python/rte_python.h           |   71 ++
 lib/librte_python/rte_python_version.map |   12 +
 mk/rte.app.mk                            |    1 +
 test/expect/init.exp                     |   28 +
 test/expect/rx.exp                       |  134 ++++
 test/test/test_cmdline_lib.c             |   10 +-
 23 files changed, 2199 insertions(+), 10 deletions(-)
 create mode 100644 app/test-pmd/pktgen.c
 create mode 100644 doc/guides/howto/scapy.rst
 create mode 100644 lib/librte_python/Makefile
 create mode 100644 lib/librte_python/rte_python.c
 create mode 100644 lib/librte_python/rte_python.h
 create mode 100644 lib/librte_python/rte_python_version.map
 create mode 100644 test/expect/init.exp
 create mode 100644 test/expect/rx.exp
  
Xueming Li Dec. 5, 2017, 4:55 a.m. UTC | #4
This patch introduced a set of new elements into DPDK:
1. python/scapy as a standard dpdk library, disabled by default.
   Could be used by any application to integrate powerful python features.
2. tx, rx and expect, blocking mode testpmd CLI command
   tx command send packets with scapy syntax template, support range/enum, be able to generate multiple flows in one command and DPDK speed.
   rx command receive packets with timeout, with several choices on how to dump packets and mbuf headers.
   expect command try to send out packet, receive and compare with the packet sent, support mbuf header and packet header comparation, show detail info or hexdiff if anything different. Expect command is suitable for unit test and regression test by saving batch expect scripts into a file and use 'load' command to invoke them together.
3. pktgen - new testpmd forwarding engine
  Used to support tx, rx and expect blocking command.
  Also support rxonly/loopback/forward/macswap non-blocking idle modes with several packet dump choice.
4. py command - new testpmd CLI
   Run and evaluate python clause in a global context, samples:
    - py a = 123; b=0xaaa; hex(a+b)
    - py eth=Ether();ip=IP();
    - py hexdump(eth/ip/UDP());
    - tx 0 eth/ip
   py shell: sneak into python shell

The purpose of this scapy/python integration is to help programmers to speed up unit test w/o writing complex c code, verify features with batch expect scripts. Testpmd already a widely used platform for people to setup PMD and verify features with rich CLI command, that's why I choose to make new CLI on this familier tool instead of creating a new one.

I made hundreds of expect test cases when developing rte_flow vxlan and GRE features, that makes me pretty confident to touch any code, hope this tool help you as well.

quick guide document:
	https://github.com/steevenlee/dpdk/blob/master_scapy/doc/guides/howto/scapy.rst
github branch:
        https://github.com/steevenlee/dpdk/tree/master_scapy



Xueming Li (11):
  lib/cmdline: support backspace key
  lib/cmdline: init parse result memeory
  lib/cmdline: add echo support in batch loading from file
  app/testpmd: support command echo in CLI batch loading
  test: update batch loading test
  lib/python: add embedded python lib
  app/testpmd: add python command
  app/testpmd: add pktgen forwarding engine
  app/testpmd: add pktgen engine scapy commands
  test/expect: add expect test scripts
  doc/scapy: add scapy how-to guide

 app/test-pmd/Makefile                    |    6 +
 app/test-pmd/cmdline.c                   |   80 ++-
 app/test-pmd/pktgen.c                    | 1092 ++++++++++++++++++++++++++++++
 app/test-pmd/testpmd.c                   |    1 +
 app/test-pmd/testpmd.h                   |    5 +
 config/common_base                       |    6 +
 doc/guides/howto/scapy.rst               |  300 ++++++++
 lib/Makefile                             |    2 +
 lib/librte_cmdline/cmdline_parse.c       |    2 +
 lib/librte_cmdline/cmdline_rdline.c      |    1 +
 lib/librte_cmdline/cmdline_socket.c      |    5 +-
 lib/librte_cmdline/cmdline_socket.h      |    3 +-
 lib/librte_cmdline/cmdline_vt100.c       |    1 +
 lib/librte_cmdline/cmdline_vt100.h       |    1 +
 lib/librte_eal/common/include/rte_log.h  |    1 +
 lib/librte_python/Makefile               |   60 ++
 lib/librte_python/rte_python.c           |  387 +++++++++++
 lib/librte_python/rte_python.h           |   71 ++
 lib/librte_python/rte_python_version.map |   12 +
 mk/rte.app.mk                            |    1 +
 test/expect/init.exp                     |   28 +
 test/expect/rx.exp                       |  134 ++++
 test/test/test_cmdline_lib.c             |   10 +-
 23 files changed, 2199 insertions(+), 10 deletions(-)
 create mode 100644 app/test-pmd/pktgen.c
 create mode 100644 doc/guides/howto/scapy.rst
 create mode 100644 lib/librte_python/Makefile
 create mode 100644 lib/librte_python/rte_python.c
 create mode 100644 lib/librte_python/rte_python.h
 create mode 100644 lib/librte_python/rte_python_version.map
 create mode 100644 test/expect/init.exp
 create mode 100644 test/expect/rx.exp
  
Xueming Li Dec. 5, 2017, 5 a.m. UTC | #5
This patch introduced a set of new elements into DPDK:
1. python/scapy as a standard dpdk library, disabled by default.
   Could be used by any application to integrate powerful python features.
2. tx, rx and expect, blocking mode testpmd CLI command
   tx command send packets with scapy syntax template, support range/enum, be
      able to generate multiple flows in one command and DPDK speed.
   rx command receive packets with timeout, with several choices on how to dump
      packets and mbuf headers.
   expect command try to send out packet, receive and compare with the packet
      sent, support mbuf header and packet header comparation, show detail info
      or hexdiff if anything different. Expect command is suitable for unit test
      and regression test by saving batch expect scripts into a file and use
      'load' command to invoke them together.
3. pktgen - new testpmd forwarding engine
   Used to support tx, rx and expect blocking command.
   Also support rxonly/loopback/forward/macswap non-blocking idle modes with 
       several packet dump choice.
4. py command - new testpmd CLI
   Run and evaluate python clause in a global context, samples:
    - py a = 123; b=0xaaa; hex(a+b)
    - py eth=Ether();ip=IP();
    - py hexdump(eth/ip/UDP());
    - tx 0 eth/ip
   py shell: sneak into python shell

The purpose of this scapy/python integration is to help programmers to speed up
unit test w/o writing complex c code, verify features with batch expect scripts.
Testpmd already a widely used platform for people to setup PMD and verify 
features with rich CLI command, that's why I choose to make new CLI on this 
familier tool instead of creating a new one.

I made hundreds of expect test cases when developing rte_flow vxlan and GRE 
features, that makes me pretty confident to touch any code, hope this tool 
help you as well.

quick guide document:
https://github.com/steevenlee/dpdk/blob/master_scapy/doc/guides/howto/scapy.rst
github branch:
https://github.com/steevenlee/dpdk/tree/master_scapy


Xueming Li (11):
  lib/cmdline: support backspace key
  lib/cmdline: init parse result memeory
  lib/cmdline: add echo support in batch loading from file
  app/testpmd: support command echo in CLI batch loading
  test: update batch loading test
  lib/python: add embedded python lib
  app/testpmd: add python command
  app/testpmd: add pktgen forwarding engine
  app/testpmd: add pktgen engine scapy commands
  test/expect: add expect test scripts
  doc/scapy: add scapy how-to guide

 app/test-pmd/Makefile                    |    6 +
 app/test-pmd/cmdline.c                   |   80 ++-
 app/test-pmd/pktgen.c                    | 1092 ++++++++++++++++++++++++++++++
 app/test-pmd/testpmd.c                   |    1 +
 app/test-pmd/testpmd.h                   |    5 +
 config/common_base                       |    6 +
 doc/guides/howto/scapy.rst               |  300 ++++++++
 lib/Makefile                             |    2 +
 lib/librte_cmdline/cmdline_parse.c       |    2 +
 lib/librte_cmdline/cmdline_rdline.c      |    1 +
 lib/librte_cmdline/cmdline_socket.c      |    5 +-
 lib/librte_cmdline/cmdline_socket.h      |    3 +-
 lib/librte_cmdline/cmdline_vt100.c       |    1 +
 lib/librte_cmdline/cmdline_vt100.h       |    1 +
 lib/librte_eal/common/include/rte_log.h  |    1 +
 lib/librte_python/Makefile               |   60 ++
 lib/librte_python/rte_python.c           |  387 +++++++++++
 lib/librte_python/rte_python.h           |   71 ++
 lib/librte_python/rte_python_version.map |   12 +
 mk/rte.app.mk                            |    1 +
 test/expect/init.exp                     |   28 +
 test/expect/rx.exp                       |  134 ++++
 test/test/test_cmdline_lib.c             |   10 +-
 23 files changed, 2199 insertions(+), 10 deletions(-)
 create mode 100644 app/test-pmd/pktgen.c
 create mode 100644 doc/guides/howto/scapy.rst
 create mode 100644 lib/librte_python/Makefile
 create mode 100644 lib/librte_python/rte_python.c
 create mode 100644 lib/librte_python/rte_python.h
 create mode 100644 lib/librte_python/rte_python_version.map
 create mode 100644 test/expect/init.exp
 create mode 100644 test/expect/rx.exp
  
Xueming Li Dec. 5, 2017, 5:03 a.m. UTC | #6
This patch introduced a set of new elements into DPDK:
1. python/scapy as a standard dpdk library, disabled by default.
   Could be used by any application to integrate powerful python features.
2. tx, rx and expect, blocking mode testpmd CLI command
   tx command send packets with scapy syntax template, support range/enum, be
      able to generate multiple flows in one command and DPDK speed.
   rx command receive packets with timeout, with several choices on how to dump
      packets and mbuf headers.
   expect command try to send out packet, receive and compare with the packet
      sent, support mbuf header and packet header comparation, show detail info
      or hexdiff if anything different. Expect command is suitable for unit test
      and regression test by saving batch expect scripts into a file and use
      'load' command to invoke them together.
3. pktgen - new testpmd forwarding engine
   Used to support tx, rx and expect blocking command.
   Also support rxonly/loopback/forward/macswap non-blocking idle modes with 
       several packet dump choice.
4. py command - new testpmd CLI
   Run and evaluate python clause in a global context, samples:
    - py a = 123; b=0xaaa; hex(a+b)
    - py eth=Ether();ip=IP();
    - py hexdump(eth/ip/UDP());
    - tx 0 eth/ip
   py shell: sneak into python shell

The purpose of this scapy/python integration is to help programmers to speed up
unit test w/o writing complex c code, verify features with batch expect scripts.
Testpmd already a widely used platform for people to setup PMD and verify 
features with rich CLI command, that's why I choose to make new CLI on this 
familier tool instead of creating a new one.

I made hundreds of expect test cases when developing rte_flow vxlan and GRE 
features, that makes me pretty confident to touch any code, hope this tool 
help you as well.

quick guide document:
https://github.com/steevenlee/dpdk/blob/master_scapy/doc/guides/howto/scapy.rst
github branch:
https://github.com/steevenlee/dpdk/tree/master_scapy


Xueming Li (11):
  lib/cmdline: support backspace key
  lib/cmdline: init parse result memeory
  lib/cmdline: add echo support in batch loading from file
  app/testpmd: support command echo in CLI batch loading
  test: update batch loading test
  lib/python: add embedded python lib
  app/testpmd: add python command
  app/testpmd: add pktgen forwarding engine
  app/testpmd: add pktgen engine scapy commands
  test/expect: add expect test scripts
  doc/scapy: add scapy how-to guide

 app/test-pmd/Makefile                    |    6 +
 app/test-pmd/cmdline.c                   |   80 ++-
 app/test-pmd/pktgen.c                    | 1092 ++++++++++++++++++++++++++++++
 app/test-pmd/testpmd.c                   |    1 +
 app/test-pmd/testpmd.h                   |    5 +
 config/common_base                       |    6 +
 doc/guides/howto/scapy.rst               |  300 ++++++++
 lib/Makefile                             |    2 +
 lib/librte_cmdline/cmdline_parse.c       |    2 +
 lib/librte_cmdline/cmdline_rdline.c      |    1 +
 lib/librte_cmdline/cmdline_socket.c      |    5 +-
 lib/librte_cmdline/cmdline_socket.h      |    3 +-
 lib/librte_cmdline/cmdline_vt100.c       |    1 +
 lib/librte_cmdline/cmdline_vt100.h       |    1 +
 lib/librte_eal/common/include/rte_log.h  |    1 +
 lib/librte_python/Makefile               |   60 ++
 lib/librte_python/rte_python.c           |  387 +++++++++++
 lib/librte_python/rte_python.h           |   71 ++
 lib/librte_python/rte_python_version.map |   12 +
 mk/rte.app.mk                            |    1 +
 test/expect/init.exp                     |   28 +
 test/expect/rx.exp                       |  134 ++++
 test/test/test_cmdline_lib.c             |   10 +-
 23 files changed, 2199 insertions(+), 10 deletions(-)
 create mode 100644 app/test-pmd/pktgen.c
 create mode 100644 doc/guides/howto/scapy.rst
 create mode 100644 lib/librte_python/Makefile
 create mode 100644 lib/librte_python/rte_python.c
 create mode 100644 lib/librte_python/rte_python.h
 create mode 100644 lib/librte_python/rte_python_version.map
 create mode 100644 test/expect/init.exp
 create mode 100644 test/expect/rx.exp
  
Xueming Li Dec. 5, 2017, 5:04 a.m. UTC | #7
quick guide document:
https://github.com/steevenlee/dpdk/blob/master_scapy/doc/guides/howto/scapy.rst
github branch:
https://github.com/steevenlee/dpdk/tree/master_scapy


Xueming Li (11):
  lib/cmdline: support backspace key
  lib/cmdline: init parse result memeory
  lib/cmdline: add echo support in batch loading from file
  app/testpmd: support command echo in CLI batch loading
  test: update batch loading test
  lib/python: add embedded python lib
  app/testpmd: add python command
  app/testpmd: add pktgen forwarding engine
  app/testpmd: add pktgen engine scapy commands
  test/expect: add expect test scripts
  doc/scapy: add scapy how-to guide

 app/test-pmd/Makefile                    |    6 +
 app/test-pmd/cmdline.c                   |   80 ++-
 app/test-pmd/pktgen.c                    | 1092 ++++++++++++++++++++++++++++++
 app/test-pmd/testpmd.c                   |    1 +
 app/test-pmd/testpmd.h                   |    5 +
 config/common_base                       |    6 +
 doc/guides/howto/scapy.rst               |  300 ++++++++
 lib/Makefile                             |    2 +
 lib/librte_cmdline/cmdline_parse.c       |    2 +
 lib/librte_cmdline/cmdline_rdline.c      |    1 +
 lib/librte_cmdline/cmdline_socket.c      |    5 +-
 lib/librte_cmdline/cmdline_socket.h      |    3 +-
 lib/librte_cmdline/cmdline_vt100.c       |    1 +
 lib/librte_cmdline/cmdline_vt100.h       |    1 +
 lib/librte_eal/common/include/rte_log.h  |    1 +
 lib/librte_python/Makefile               |   60 ++
 lib/librte_python/rte_python.c           |  387 +++++++++++
 lib/librte_python/rte_python.h           |   71 ++
 lib/librte_python/rte_python_version.map |   12 +
 mk/rte.app.mk                            |    1 +
 test/expect/init.exp                     |   28 +
 test/expect/rx.exp                       |  134 ++++
 test/test/test_cmdline_lib.c             |   10 +-
 23 files changed, 2199 insertions(+), 10 deletions(-)
 create mode 100644 app/test-pmd/pktgen.c
 create mode 100644 doc/guides/howto/scapy.rst
 create mode 100644 lib/librte_python/Makefile
 create mode 100644 lib/librte_python/rte_python.c
 create mode 100644 lib/librte_python/rte_python.h
 create mode 100644 lib/librte_python/rte_python_version.map
 create mode 100644 test/expect/init.exp
 create mode 100644 test/expect/rx.exp
  
Xueming Li Dec. 5, 2017, 6:14 a.m. UTC | #8
Sorry for spamming, something wrong to post patches.
Please refer to https://github.com/steevenlee/dpdk/tree/master_scapy for code detail.

> -----Original Message-----

> From: Xueming Li [mailto:xuemingl@mellanox.com]

> Sent: Tuesday, December 5, 2017 12:55 PM

> To: Wu@dev-r630-06.mtbc.labs.mlnx; Jingjing <jingjing.wu@intel.com>; Harry

> van Haaren <harry.van.haaren@intel.com>

> Cc: Xueming(Steven) Li <xuemingl@mellanox.com>; dev@dpdk.org

> Subject: [RFC v1 00/11] scapy/python extension

> 

> This patch introduced a set of new elements into DPDK:

> 1. python/scapy as a standard dpdk library, disabled by default.

>    Could be used by any application to integrate powerful python features.

> 2. tx, rx and expect, blocking mode testpmd CLI command

>    tx command send packets with scapy syntax template, support range/enum,

> be able to generate multiple flows in one command and DPDK speed.

>    rx command receive packets with timeout, with several choices on how to

> dump packets and mbuf headers.

>    expect command try to send out packet, receive and compare with the

> packet sent, support mbuf header and packet header comparation, show

> detail info or hexdiff if anything different. Expect command is suitable

> for unit test and regression test by saving batch expect scripts into a

> file and use 'load' command to invoke them together.

> 3. pktgen - new testpmd forwarding engine

>   Used to support tx, rx and expect blocking command.

>   Also support rxonly/loopback/forward/macswap non-blocking idle modes

> with several packet dump choice.

> 4. py command - new testpmd CLI

>    Run and evaluate python clause in a global context, samples:

>     - py a = 123; b=0xaaa; hex(a+b)

>     - py eth=Ether();ip=IP();

>     - py hexdump(eth/ip/UDP());

>     - tx 0 eth/ip

>    py shell: sneak into python shell

> 

> The purpose of this scapy/python integration is to help programmers to

> speed up unit test w/o writing complex c code, verify features with batch

> expect scripts. Testpmd already a widely used platform for people to setup

> PMD and verify features with rich CLI command, that's why I choose to make

> new CLI on this familier tool instead of creating a new one.

> 

> I made hundreds of expect test cases when developing rte_flow vxlan and

> GRE features, that makes me pretty confident to touch any code, hope this

> tool help you as well.

> 

> quick guide document:

> 	https://github.com/steevenlee/dpdk/blob/master_scapy/doc/guides/howt

> o/scapy.rst

> github branch:

>         https://github.com/steevenlee/dpdk/tree/master_scapy

> 

> 

> 

> Xueming Li (11):

>   lib/cmdline: support backspace key

>   lib/cmdline: init parse result memeory

>   lib/cmdline: add echo support in batch loading from file

>   app/testpmd: support command echo in CLI batch loading

>   test: update batch loading test

>   lib/python: add embedded python lib

>   app/testpmd: add python command

>   app/testpmd: add pktgen forwarding engine

>   app/testpmd: add pktgen engine scapy commands

>   test/expect: add expect test scripts

>   doc/scapy: add scapy how-to guide

> 

>  app/test-pmd/Makefile                    |    6 +

>  app/test-pmd/cmdline.c                   |   80 ++-

>  app/test-pmd/pktgen.c                    | 1092

> ++++++++++++++++++++++++++++++

>  app/test-pmd/testpmd.c                   |    1 +

>  app/test-pmd/testpmd.h                   |    5 +

>  config/common_base                       |    6 +

>  doc/guides/howto/scapy.rst               |  300 ++++++++

>  lib/Makefile                             |    2 +

>  lib/librte_cmdline/cmdline_parse.c       |    2 +

>  lib/librte_cmdline/cmdline_rdline.c      |    1 +

>  lib/librte_cmdline/cmdline_socket.c      |    5 +-

>  lib/librte_cmdline/cmdline_socket.h      |    3 +-

>  lib/librte_cmdline/cmdline_vt100.c       |    1 +

>  lib/librte_cmdline/cmdline_vt100.h       |    1 +

>  lib/librte_eal/common/include/rte_log.h  |    1 +

>  lib/librte_python/Makefile               |   60 ++

>  lib/librte_python/rte_python.c           |  387 +++++++++++

>  lib/librte_python/rte_python.h           |   71 ++

>  lib/librte_python/rte_python_version.map |   12 +

>  mk/rte.app.mk                            |    1 +

>  test/expect/init.exp                     |   28 +

>  test/expect/rx.exp                       |  134 ++++

>  test/test/test_cmdline_lib.c             |   10 +-

>  23 files changed, 2199 insertions(+), 10 deletions(-)  create mode 100644

> app/test-pmd/pktgen.c  create mode 100644 doc/guides/howto/scapy.rst

> create mode 100644 lib/librte_python/Makefile  create mode 100644

> lib/librte_python/rte_python.c  create mode 100644

> lib/librte_python/rte_python.h  create mode 100644

> lib/librte_python/rte_python_version.map

>  create mode 100644 test/expect/init.exp  create mode 100644

> test/expect/rx.exp

> 

> --

> 2.13.3
  
Xueming Li Dec. 8, 2017, 8:22 a.m. UTC | #9
This patch introduced a set of new elements into DPDK:
1. python/scapy as a standard dpdk library, disabled by default.
   Could be used by any application to integrate powerful python features.
2. tx, rx and expect, blocking mode testpmd CLI command
   tx command send packets with scapy syntax template, support range/enum, be able to generate multiple flows in one command and DPDK speed.
   rx command receive packets with timeout, with several choices on how to dump packets and mbuf headers.
   expect command try to send out packet, receive and compare with the packet sent, support mbuf header and packet header comparation, show detail info or hexdiff if anything different. Expect command is suitable for unit test and regression test by saving batch expect scripts into a file and use 'load' command to invoke them together.
3. pktgen - new testpmd forwarding engine
  Used to support tx, rx and expect blocking command.
  Also support rxonly/loopback/forward/macswap non-blocking idle modes with several packet dump choice.
4. py command - new testpmd CLI
   Run and evaluate python clause in a global context, samples:
    - py a = 123; b=0xaaa; hex(a+b)
    - py eth=Ether();ip=IP();
    - py hexdump(eth/ip/UDP());
    - tx 0 eth/ip
   py shell: sneak into python shell

The purpose of this scapy/python integration is to help programmers to speed up unit test w/o writing complex c code, verify features with batch expect scripts. Testpmd already a widely used platform for people to setup PMD and verify features with rich CLI command, that's why I choose to make new CLI on this familier tool instead of creating a new one.

I made hundreds of expect test cases when developing rte_flow vxlan and GRE features, that makes me pretty confident to touch any code, hope this tool help you as well.

quick guide document:
	https://github.com/steevenlee/dpdk/blob/master_scapy/doc/guides/howto/scapy.rst
github branch:
        https://github.com/steevenlee/dpdk/tree/master_scapy

v2:
* Introduced rx, tx, expect command
* Introduced pktgen engine idle mode
* Introduced python to dpdk as a std library

Xueming Li (9):
  lib/cmdline: add echo support in batch loading from file
  app/testpmd: support command echo in CLI batch loading
  test: update batch loading test
  lib/python: add embedded python lib
  app/testpmd: add python command
  app/testpmd: add pktgen forwarding engine
  app/testpmd: add pktgen engine scapy commands
  test/expect: add expect test scripts
  doc/scapy: add scapy how-to guide

 app/test-pmd/Makefile                    |    6 +
 app/test-pmd/cmdline.c                   |   80 ++-
 app/test-pmd/pktgen.c                    | 1092 ++++++++++++++++++++++++++++++
 app/test-pmd/testpmd.c                   |    1 +
 app/test-pmd/testpmd.h                   |    5 +
 config/common_base                       |    6 +
 doc/guides/howto/scapy.rst               |  300 ++++++++
 lib/Makefile                             |    2 +
 lib/librte_cmdline/cmdline_socket.c      |    5 +-
 lib/librte_cmdline/cmdline_socket.h      |    3 +-
 lib/librte_eal/common/include/rte_log.h  |    1 +
 lib/librte_python/Makefile               |   60 ++
 lib/librte_python/rte_python.c           |  387 +++++++++++
 lib/librte_python/rte_python.h           |   71 ++
 lib/librte_python/rte_python_version.map |   12 +
 mk/rte.app.mk                            |    1 +
 test/expect/init.exp                     |   28 +
 test/expect/rx.exp                       |  134 ++++
 test/test/test_cmdline_lib.c             |   10 +-
 19 files changed, 2194 insertions(+), 10 deletions(-)
 create mode 100644 app/test-pmd/pktgen.c
 create mode 100644 doc/guides/howto/scapy.rst
 create mode 100644 lib/librte_python/Makefile
 create mode 100644 lib/librte_python/rte_python.c
 create mode 100644 lib/librte_python/rte_python.h
 create mode 100644 lib/librte_python/rte_python_version.map
 create mode 100644 test/expect/init.exp
 create mode 100644 test/expect/rx.exp
  
Wiles, Keith Dec. 10, 2017, 11:16 p.m. UTC | #10
> On Dec 5, 2017, at 12:04 AM, Xueming Li <xuemingl@mellanox.com> wrote:

> 

> quick guide document:

> https://github.com/steevenlee/dpdk/blob/master_scapy/doc/guides/howto/scapy.rst

> github branch:

> https://github.com/steevenlee/dpdk/tree/master_scapy

> 

> 

> Xueming Li (11):

>  lib/cmdline: support backspace key

>  lib/cmdline: init parse result memeory

>  lib/cmdline: add echo support in batch loading from file

>  app/testpmd: support command echo in CLI batch loading

>  test: update batch loading test

>  lib/python: add embedded python lib

>  app/testpmd: add python command

>  app/testpmd: add pktgen forwarding engine

>  app/testpmd: add pktgen engine scapy commands

>  test/expect: add expect test scripts

>  doc/scapy: add scapy how-to guide

> 


Not to be a pain, but using the name pktgen is going to cause a bit of confusion with my Pktgen-DPDK application. Could you change the name to something else like trafficgen or whatever you like? I believe the naming of this feature is going to cause a lot of people to think this ‘pktgen’ is mine and I already have some confusion with the linux kernel traffic generator called ‘pktgen’ which is why I try to make sure everyone uses Pktgen-DPDK for the name of mine.

It would be very helpful if you would change the name from pktgen to something else, thanks.

> app/test-pmd/Makefile                    |    6 +

> app/test-pmd/cmdline.c                   |   80 ++-

> app/test-pmd/pktgen.c                    | 1092 ++++++++++++++++++++++++++++++

> app/test-pmd/testpmd.c                   |    1 +

> app/test-pmd/testpmd.h                   |    5 +

> config/common_base                       |    6 +

> doc/guides/howto/scapy.rst               |  300 ++++++++

> lib/Makefile                             |    2 +

> lib/librte_cmdline/cmdline_parse.c       |    2 +

> lib/librte_cmdline/cmdline_rdline.c      |    1 +

> lib/librte_cmdline/cmdline_socket.c      |    5 +-

> lib/librte_cmdline/cmdline_socket.h      |    3 +-

> lib/librte_cmdline/cmdline_vt100.c       |    1 +

> lib/librte_cmdline/cmdline_vt100.h       |    1 +

> lib/librte_eal/common/include/rte_log.h  |    1 +

> lib/librte_python/Makefile               |   60 ++

> lib/librte_python/rte_python.c           |  387 +++++++++++

> lib/librte_python/rte_python.h           |   71 ++

> lib/librte_python/rte_python_version.map |   12 +

> mk/rte.app.mk                            |    1 +

> test/expect/init.exp                     |   28 +

> test/expect/rx.exp                       |  134 ++++

> test/test/test_cmdline_lib.c             |   10 +-

> 23 files changed, 2199 insertions(+), 10 deletions(-)

> create mode 100644 app/test-pmd/pktgen.c

> create mode 100644 doc/guides/howto/scapy.rst

> create mode 100644 lib/librte_python/Makefile

> create mode 100644 lib/librte_python/rte_python.c

> create mode 100644 lib/librte_python/rte_python.h

> create mode 100644 lib/librte_python/rte_python_version.map

> create mode 100644 test/expect/init.exp

> create mode 100644 test/expect/rx.exp

> 

> -- 

> 2.13.3

> 


Regards,
Keith
  
Eelco Chaudron Jan. 10, 2019, 1:06 p.m. UTC | #11
Hi Xueming,

I was wondering if this patch went anywhere, could not find anything in 
the list archive?

I like the idea, as it’s useful for quick unit testing, without 
relying on Trex or trafgen.

Cheers,

Eelco


> quick guide document:
> https://github.com/steevenlee/dpdk/blob/master_scapy/doc/guides/howto/scapy.rst
> github branch:
> https://github.com/steevenlee/dpdk/tree/master_scapy
>
>
> Xueming Li (11):
>   lib/cmdline: support backspace key
>   lib/cmdline: init parse result memeory
>   lib/cmdline: add echo support in batch loading from file
>   app/testpmd: support command echo in CLI batch loading
>   test: update batch loading test
>   lib/python: add embedded python lib
>   app/testpmd: add python command
>   app/testpmd: add pktgen forwarding engine
>   app/testpmd: add pktgen engine scapy commands
>   test/expect: add expect test scripts
>   doc/scapy: add scapy how-to guide
>
>  app/test-pmd/Makefile                    |    6 +
>  app/test-pmd/cmdline.c                   |   80 ++-
>  app/test-pmd/pktgen.c                    | 1092 
> ++++++++++++++++++++++++++++++
>  app/test-pmd/testpmd.c                   |    1 +
>  app/test-pmd/testpmd.h                   |    5 +
>  config/common_base                       |    6 +
>  doc/guides/howto/scapy.rst               |  300 ++++++++
>  lib/Makefile                             |    2 +
>  lib/librte_cmdline/cmdline_parse.c       |    2 +
>  lib/librte_cmdline/cmdline_rdline.c      |    1 +
>  lib/librte_cmdline/cmdline_socket.c      |    5 +-
>  lib/librte_cmdline/cmdline_socket.h      |    3 +-
>  lib/librte_cmdline/cmdline_vt100.c       |    1 +
>  lib/librte_cmdline/cmdline_vt100.h       |    1 +
>  lib/librte_eal/common/include/rte_log.h  |    1 +
>  lib/librte_python/Makefile               |   60 ++
>  lib/librte_python/rte_python.c           |  387 +++++++++++
>  lib/librte_python/rte_python.h           |   71 ++
>  lib/librte_python/rte_python_version.map |   12 +
>  mk/rte.app.mk                            |    1 +
>  test/expect/init.exp                     |   28 +
>  test/expect/rx.exp                       |  134 ++++
>  test/test/test_cmdline_lib.c             |   10 +-
>  23 files changed, 2199 insertions(+), 10 deletions(-)
>  create mode 100644 app/test-pmd/pktgen.c
>  create mode 100644 doc/guides/howto/scapy.rst
>  create mode 100644 lib/librte_python/Makefile
>  create mode 100644 lib/librte_python/rte_python.c
>  create mode 100644 lib/librte_python/rte_python.h
>  create mode 100644 lib/librte_python/rte_python_version.map
>  create mode 100644 test/expect/init.exp
>  create mode 100644 test/expect/rx.exp
>
> -- 
> 2.13.3
  
Xueming Li Jan. 16, 2019, 1:24 p.m. UTC | #12
Thanks for interesting on this, I'm using it for my daily development and so on some of my customer.

There is a version here, almost my latest code, welcome for pushes.
https://github.com/steevenlee/dpdk/tree/master_scapy


> -----Original Message-----
> From: Eelco Chaudron <echaudro@redhat.com>
> Sent: Thursday, January 10, 2019 9:07 PM
> To: Xueming(Steven) Li <xuemingl@mellanox.com>
> Cc: dev@dpdk.org
> Subject: Re: [dpdk-dev] [RFC v1 00/11] scapy/python extension
> 
> Hi Xueming,
> 
> I was wondering if this patch went anywhere, could not find anything in the list archive?
> 
> I like the idea, as it’s useful for quick unit testing, without relying on Trex or trafgen.
> 
> Cheers,
> 
> Eelco
> 
> 
> > quick guide document:
> > https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit
> > hub.com%2Fsteevenlee%2Fdpdk%2Fblob%2Fmaster_scapy%2Fdoc%2Fguides%2Fhow
> > to%2Fscapy.rst&amp;data=02%7C01%7Cxuemingl%40mellanox.com%7Cb189685338
> > d84a05990b08d676fc7a82%7Ca652971c7d2e4d9ba6a4d149256f461b%7C0%7C0%7C63
> > 6827224097402827&amp;sdata=WPOdvHM%2BA3x1r2ihqqI2buNmiWCJUEx6Tf1GxSZqW
> > %2F4%3D&amp;reserved=0
> > github branch:
> > https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit
> > hub.com%2Fsteevenlee%2Fdpdk%2Ftree%2Fmaster_scapy&amp;data=02%7C01%7Cx
> > uemingl%40mellanox.com%7Cb189685338d84a05990b08d676fc7a82%7Ca652971c7d
> > 2e4d9ba6a4d149256f461b%7C0%7C0%7C636827224097402827&amp;sdata=M%2FAqZ3
> > zbehCwLQNKZCm0seUzWs3mIdBrVwv0%2B5NWmk8%3D&amp;reserved=0
> >
> >
> > Xueming Li (11):
> >   lib/cmdline: support backspace key
> >   lib/cmdline: init parse result memeory
> >   lib/cmdline: add echo support in batch loading from file
> >   app/testpmd: support command echo in CLI batch loading
> >   test: update batch loading test
> >   lib/python: add embedded python lib
> >   app/testpmd: add python command
> >   app/testpmd: add pktgen forwarding engine
> >   app/testpmd: add pktgen engine scapy commands
> >   test/expect: add expect test scripts
> >   doc/scapy: add scapy how-to guide
> >
> >  app/test-pmd/Makefile                    |    6 +
> >  app/test-pmd/cmdline.c                   |   80 ++-
> >  app/test-pmd/pktgen.c                    | 1092
> > ++++++++++++++++++++++++++++++
> >  app/test-pmd/testpmd.c                   |    1 +
> >  app/test-pmd/testpmd.h                   |    5 +
> >  config/common_base                       |    6 +
> >  doc/guides/howto/scapy.rst               |  300 ++++++++
> >  lib/Makefile                             |    2 +
> >  lib/librte_cmdline/cmdline_parse.c       |    2 +
> >  lib/librte_cmdline/cmdline_rdline.c      |    1 +
> >  lib/librte_cmdline/cmdline_socket.c      |    5 +-
> >  lib/librte_cmdline/cmdline_socket.h      |    3 +-
> >  lib/librte_cmdline/cmdline_vt100.c       |    1 +
> >  lib/librte_cmdline/cmdline_vt100.h       |    1 +
> >  lib/librte_eal/common/include/rte_log.h  |    1 +
> >  lib/librte_python/Makefile               |   60 ++
> >  lib/librte_python/rte_python.c           |  387 +++++++++++
> >  lib/librte_python/rte_python.h           |   71 ++
> >  lib/librte_python/rte_python_version.map |   12 +
> >  mk/rte.app.mk                            |    1 +
> >  test/expect/init.exp                     |   28 +
> >  test/expect/rx.exp                       |  134 ++++
> >  test/test/test_cmdline_lib.c             |   10 +-
> >  23 files changed, 2199 insertions(+), 10 deletions(-)  create mode
> > 100644 app/test-pmd/pktgen.c  create mode 100644
> > doc/guides/howto/scapy.rst  create mode 100644
> > lib/librte_python/Makefile  create mode 100644
> > lib/librte_python/rte_python.c  create mode 100644
> > lib/librte_python/rte_python.h  create mode 100644
> > lib/librte_python/rte_python_version.map
> >  create mode 100644 test/expect/init.exp  create mode 100644
> > test/expect/rx.exp
> >
> > --
> > 2.13.3
  

Patch

diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index a4d4a866b..dacb97888 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -128,6 +128,9 @@  uint8_t mp_anon = 0;
 struct ether_addr peer_eth_addrs[RTE_MAX_ETHPORTS];
 portid_t nb_peer_eth_addrs = 0;
 
+/* Template of packet to tx */
+struct rte_mbuf *pkt_templ[RTE_MAX_ETHPORTS][RTE_MAX_QUEUES_PER_PORT];
+
 /*
  * Probed Target Environment.
  */
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index 265b75f9f..4090d1e87 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -480,6 +480,7 @@  extern struct fwd_stream **fwd_streams;
 
 extern portid_t nb_peer_eth_addrs; /**< Number of peer ethernet addresses. */
 extern struct ether_addr peer_eth_addrs[RTE_MAX_ETHPORTS];
+extern struct rte_mbuf *pkt_templ[RTE_MAX_ETHPORTS][RTE_MAX_QUEUES_PER_PORT];
 
 extern uint32_t burst_tx_delay_time; /**< Burst tx delay time(us) for mac-retry. */
 extern uint32_t burst_tx_retry_num;  /**< Burst tx retry number for mac-retry. */
diff --git a/app/test-pmd/txonly.c b/app/test-pmd/txonly.c
index 7070ddc3b..e2b189c60 100644
--- a/app/test-pmd/txonly.c
+++ b/app/test-pmd/txonly.c
@@ -186,6 +186,7 @@  pkt_burst_transmit(struct fwd_stream *fs)
 	struct rte_port *txp;
 	struct rte_mbuf *pkt;
 	struct rte_mbuf *pkt_seg;
+	struct rte_mbuf *tmpl;
 	struct rte_mempool *mbp;
 	struct ether_hdr eth_hdr;
 	uint16_t nb_tx;
@@ -206,6 +207,7 @@  pkt_burst_transmit(struct fwd_stream *fs)
 #endif
 
 	mbp = current_fwd_lcore()->mbp;
+	tmpl = pkt_templ[fs->tx_port][fs->tx_queue];
 	txp = &ports[fs->tx_port];
 	vlan_tci = txp->tx_vlan_id;
 	vlan_tci_outer = txp->tx_vlan_id_outer;
@@ -231,7 +233,7 @@  pkt_burst_transmit(struct fwd_stream *fs)
 		 * reset to default value.
 		 */
 		rte_pktmbuf_reset_headroom(pkt);
-		pkt->data_len = tx_pkt_seg_lengths[0];
+		pkt->data_len = tmpl ? tmpl->data_len : tx_pkt_seg_lengths[0];
 		pkt_seg = pkt;
 		if (tx_pkt_split == TX_PKT_SPLIT_RND)
 			nb_segs = random() % tx_pkt_nb_segs + 1;
@@ -251,22 +253,30 @@  pkt_burst_transmit(struct fwd_stream *fs)
 		}
 		pkt_seg->next = NULL; /* Last segment of packet. */
 
-		/*
-		 * Initialize Ethernet header.
-		 */
-		ether_addr_copy(&peer_eth_addrs[fs->peer_addr],&eth_hdr.d_addr);
-		ether_addr_copy(&ports[fs->tx_port].eth_addr, &eth_hdr.s_addr);
-		eth_hdr.ether_type = rte_cpu_to_be_16(ETHER_TYPE_IPv4);
+		if (tmpl) {
+			copy_buf_to_pkt(
+				rte_pktmbuf_mtod_offset(tmpl, void *, 0),
+				tmpl->data_len, pkt, 0);
+		} else {
+			/*
+			 * Initialize Ethernet header.
+			 */
+			ether_addr_copy(&peer_eth_addrs[fs->peer_addr],
+					&eth_hdr.d_addr);
+			ether_addr_copy(&ports[fs->tx_port].eth_addr,
+					&eth_hdr.s_addr);
+			eth_hdr.ether_type = rte_cpu_to_be_16(ETHER_TYPE_IPv4);
 
-		/*
-		 * Copy headers in first packet segment(s).
-		 */
-		copy_buf_to_pkt(&eth_hdr, sizeof(eth_hdr), pkt, 0);
-		copy_buf_to_pkt(&pkt_ip_hdr, sizeof(pkt_ip_hdr), pkt,
-				sizeof(struct ether_hdr));
-		copy_buf_to_pkt(&pkt_udp_hdr, sizeof(pkt_udp_hdr), pkt,
-				sizeof(struct ether_hdr) +
-				sizeof(struct ipv4_hdr));
+			/*
+			 * Copy headers in first packet segment(s).
+			 */
+			copy_buf_to_pkt(&eth_hdr, sizeof(eth_hdr), pkt, 0);
+			copy_buf_to_pkt(&pkt_ip_hdr, sizeof(pkt_ip_hdr), pkt,
+					sizeof(struct ether_hdr));
+			copy_buf_to_pkt(&pkt_udp_hdr, sizeof(pkt_udp_hdr), pkt,
+					sizeof(struct ether_hdr) +
+					sizeof(struct ipv4_hdr));
+		}
 
 		/*
 		 * Complete first mbuf of packet and append it to the