[3/5,pktgen] use constants for PCAP creation

Message ID 1547136846-23319-4-git-send-email-rk@semihalf.com (mailing list archive)
State Not Applicable, archived
Headers
Series fixes and minor features |

Checks

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

Commit Message

Rafal Kozik Jan. 10, 2019, 4:14 p.m. UTC
  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(-)
  

Patch

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++;