From: Xueming Li <xuemingl@mellanox.com>
To: Jingjing Wu <jingjing.wu@intel.com>
Cc: Xueming Li <xuemingl@mellanox.com>, dev@dpdk.org
Subject: [dpdk-dev] [RFC PATCH 1/2] app/testpmd: add packet template
Date: Thu, 19 Oct 2017 22:06:48 +0800 [thread overview]
Message-ID: <20171019140649.26668-2-xuemingl@mellanox.com> (raw)
In-Reply-To: <20171019140649.26668-1-xuemingl@mellanox.com>
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(-)
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],ð_hdr.d_addr);
- ether_addr_copy(&ports[fs->tx_port].eth_addr, ð_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],
+ ð_hdr.d_addr);
+ ether_addr_copy(&ports[fs->tx_port].eth_addr,
+ ð_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(ð_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(ð_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
--
2.13.3
next prev parent reply other threads:[~2017-10-19 14:07 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-19 14:06 [dpdk-dev] [RFC PATCH 0/2] using scapy to generate packet templates Xueming Li
2017-10-19 14:06 ` Xueming Li [this message]
2017-12-05 4:43 ` [dpdk-dev] [RFC v1 00/11] scapy/python extension Xueming Li
2017-12-05 4:45 ` Xueming Li
2017-12-05 4:48 ` Xueming Li
2017-12-05 4:55 ` Xueming Li
2017-12-05 6:14 ` Xueming(Steven) Li
2017-12-05 5:00 ` Xueming Li
2017-12-05 5:03 ` [dpdk-dev] [RFC v1 00/11] scappy/pythoon extension Xueming Li
2017-12-05 5:04 ` [dpdk-dev] [RFC v1 00/11] scapy/python extension Xueming Li
2017-12-10 23:16 ` Wiles, Keith
2019-01-10 13:06 ` Eelco Chaudron
2019-01-16 13:24 ` Xueming(Steven) Li
2017-12-08 8:22 ` [dpdk-dev] [RFC v1 0/9] " Xueming Li
2017-12-08 8:22 ` [dpdk-dev] [RFC v1 1/9] lib/cmdline: add echo support in batch loading from file Xueming Li
2017-12-08 8:22 ` [dpdk-dev] [RFC v1 2/9] app/testpmd: support command echo in CLI batch loading Xueming Li
2017-12-08 8:22 ` [dpdk-dev] [RFC v1 3/9] test: update batch loading test Xueming Li
2017-12-08 8:22 ` [dpdk-dev] [RFC v1 4/9] lib/python: add embedded python lib Xueming Li
2017-12-08 8:22 ` [dpdk-dev] [RFC v1 5/9] app/testpmd: add python command Xueming Li
2017-12-08 8:22 ` [dpdk-dev] [RFC v1 6/9] app/testpmd: add pktgen forwarding engine Xueming Li
2017-12-08 8:22 ` [dpdk-dev] [RFC v1 7/9] app/testpmd: add pktgen engine scapy commands Xueming Li
2017-12-08 8:22 ` [dpdk-dev] [RFC v1 8/9] test/expect: add expect test scripts Xueming Li
2017-12-08 8:22 ` [dpdk-dev] [RFC v1 9/9] doc/scapy: add scapy how-to guide Xueming Li
2017-10-19 14:06 ` [dpdk-dev] [RFC PATCH 2/2] app/testpmd: add scapy command as pkt template Xueming Li
2017-10-19 15:21 ` [dpdk-dev] [RFC PATCH 0/2] using scapy to generate packet templates Van Haaren, Harry
2017-10-21 16:04 ` Xueming(Steven) Li
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171019140649.26668-2-xuemingl@mellanox.com \
--to=xuemingl@mellanox.com \
--cc=dev@dpdk.org \
--cc=jingjing.wu@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).