DPDK patches and discussions
 help / color / mirror / Atom feed
From: Rafal Kozik <rk@semihalf.com>
To: dev@dpdk.org, keith.wiles@intel.com
Cc: mw@semihalf.com, mk@semihalf.com, gtzalik@amazon.com,
	evgenys@amazon.com, matua@amazon.com, igorch@amazon.com,
	Rafal Kozik <rk@semihalf.com>
Subject: [dpdk-dev] [PATCH 3/5] [pktgen] use constants for PCAP creation
Date: Thu, 10 Jan 2019 17:14:04 +0100	[thread overview]
Message-ID: <1547136846-23319-4-git-send-email-rk@semihalf.com> (raw)
In-Reply-To: <1547136846-23319-1-git-send-email-rk@semihalf.com>

Instead of magic number and DPDK constants use, constants defined
in PKTGEN. It allows to easily adjust packets size for users needs.
For example jumbo packets could be supported by just increasing
DEFAULT_MBUF_SIZE and MAX_PKT_SIZE.

Signed-off-by: Rafal Kozik <rk@semihalf.com>
---
 app/pktgen-pcap.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/app/pktgen-pcap.c b/app/pktgen-pcap.c
index e7ef9a2..7f380f6 100644
--- a/app/pktgen-pcap.c
+++ b/app/pktgen-pcap.c
@@ -43,7 +43,7 @@ pktgen_print_pcap(uint16_t pid)
 	pcap_info_t *pcap;
 	pcaprec_hdr_t pcap_hdr;
 	char buff[64];
-	char pkt_buff[2048];
+	char pkt_buff[DEFAULT_MBUF_SIZE];
 
 	pktgen_display_set_color("top.page");
 	display_topline("<PCAP Page>");
@@ -216,7 +216,7 @@ pktgen_pcap_mbuf_ctor(struct rte_mempool *mp,
 	uint32_t mbuf_size, buf_len, priv_size = 0;
 	pcaprec_hdr_t hdr;
 	ssize_t len = -1;
-	char buffer[2048];
+	char buffer[DEFAULT_MBUF_SIZE];
 	pcap_info_t *pcap = (pcap_info_t *)opaque_arg;
 
 #if RTE_VERSION >= RTE_VERSION_NUM(16, 7, 0, 0)
@@ -274,10 +274,10 @@ pktgen_pcap_mbuf_ctor(struct rte_mempool *mp,
 		len = hdr.incl_len;
 
 		/* Adjust the packet length if not a valid size. */
-		if (len < (ETHER_MIN_LEN - 4) )
-			len = (ETHER_MIN_LEN - 4);
-		else if (len > (ETHER_MAX_LEN - 4) )
-			len = (ETHER_MAX_LEN - 4);
+		if (len < MIN_PKT_SIZE)
+			len = MIN_PKT_SIZE;
+		else if (len > MAX_PKT_SIZE)
+			len = MAX_PKT_SIZE;
 
 		m->data_len = len;
 		m->pkt_len  = len;
@@ -309,7 +309,7 @@ pktgen_pcap_parse(pcap_info_t *pcap, port_info_t *info, unsigned qid)
 	pcaprec_hdr_t hdr;
 	uint32_t elt_count, data_size, len, i;
 	uint64_t pkt_sizes = 0;
-	char buffer[2048];
+	char buffer[DEFAULT_MBUF_SIZE];
 	char name[RTE_MEMZONE_NAMESIZE];
 
 	if ( (pcap == NULL) || (info == NULL) )
@@ -327,10 +327,10 @@ pktgen_pcap_parse(pcap_info_t *pcap, port_info_t *info, unsigned qid)
 		/* Skip any jumbo packets or packets that are too small */
 		len = hdr.incl_len;
 
-		if (len < (ETHER_MIN_LEN - 4) )
-			len = (ETHER_MIN_LEN - 4);
-		else if (len > (ETHER_MAX_LEN - 4) )
-			len = (ETHER_MAX_LEN - 4);
+		if (len < MIN_PKT_SIZE)
+			len = MIN_PKT_SIZE;
+		else if (len > MAX_PKT_SIZE)
+			len = MAX_PKT_SIZE;
 
 		elt_count++;
 
-- 
2.7.4

  parent reply	other threads:[~2019-01-10 16:14 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-10 16:14 [dpdk-dev] [PATCH 0/5][pktgen] fixes and minor features Rafal Kozik
2019-01-10 16:14 ` [dpdk-dev] [PATCH 1/5] [pktgen] fix race condition in start Rafal Kozik
2019-01-10 16:14 ` [dpdk-dev] [PATCH 2/5] [pktgen] different PCAP per each queue Rafal Kozik
2019-01-10 16:14 ` Rafal Kozik [this message]
2019-01-10 16:14 ` [dpdk-dev] [PATCH 4/5] [pktgen] expose number of missed Rx packets Rafal Kozik
2019-01-10 16:14 ` [dpdk-dev] [PATCH 5/5] [pktgen] fix cleanup of not sent packets Rafal Kozik

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=1547136846-23319-4-git-send-email-rk@semihalf.com \
    --to=rk@semihalf.com \
    --cc=dev@dpdk.org \
    --cc=evgenys@amazon.com \
    --cc=gtzalik@amazon.com \
    --cc=igorch@amazon.com \
    --cc=keith.wiles@intel.com \
    --cc=matua@amazon.com \
    --cc=mk@semihalf.com \
    --cc=mw@semihalf.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).