From patchwork Thu Jan 10 16:14:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rafal Kozik X-Patchwork-Id: 49621 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 157811B912; Thu, 10 Jan 2019 17:14:22 +0100 (CET) Received: from mail-lj1-f196.google.com (mail-lj1-f196.google.com [209.85.208.196]) by dpdk.org (Postfix) with ESMTP id AD05E1B90C for ; Thu, 10 Jan 2019 17:14:20 +0100 (CET) Received: by mail-lj1-f196.google.com with SMTP id l15-v6so10185713lja.9 for ; Thu, 10 Jan 2019 08:14:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=T6czS1TrkWpSZlZ5dBrUkN3HApCQD1NUAzQlIyLhtFI=; b=dP3dj7zgwzkrmKFUD2+rFHlJQ10M8YnAeDKFyokt8GBf4lbe1hvtGsUByjNHI6Ym7w snECLWRytkdECNk6rJ1xqGCBsRpSMi69neSkQpOmcorRb/CiR87xrZ7BXB1IV2aJZvsz iV0NqRP1sVNzYYNb6a93HpBXxd/+hGJ1ARCn9V9p0UYOI6nROrWsRn1gY2/uji72ASEL VOUVYYdLBg8axnQAtB1vrxonDfsdWU/T1Bzo6+DXAdYzRmAi6X4elnJfUqYNsDMysZm2 YTDrQS1KtOh6eHa5F8wdpaH8GzcWBMzIjhc/yFkKa61AO0CigUoKsgVcZnd/Xn4vkQJk NZ5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=T6czS1TrkWpSZlZ5dBrUkN3HApCQD1NUAzQlIyLhtFI=; b=eZ8WFe0hyIZNDs2vkhUUoxTThGyILUucloLvkp8ZfFVK6reX7PgY4v1c/ASSteGWkB Q4GrjKLLnumk38w58DtTLUZcdIrri0aYU1UUH+m5/PvM+HoW4FqUhuQeOvidBBC/B4mH 6/MbLwfFAFIExYPzQ+ocWfo74+V4ZdwBknSFoHvWBLEVwhk1odAashq9q1vSVspbzu1l ONjZ/i6GNPcaN9lMmYZjzkiy5kb5V0TDFRkdIMqd7Bp9yKoI9E++WOwQwYqmhiageoPJ /paqLr7N+o2lZ5HkmGyN1lCRFjdoH6wgQyTt+wLANO6/GW28QB/0zda+y/hG2+JFk0sE uQGQ== X-Gm-Message-State: AJcUukeEMmq0RLOzrg6b+3QcJ08Z3Q1tvAwtDEztUiuNSZ8LCgLc+gCm AjclSk8fsT2F56OReJyqqUBnUO101ek= X-Google-Smtp-Source: ALg8bN5BIUG50Z09L5lEscbSaa18dqCkQUptGIVrJpKbH6jdGVx8ZTpQh/f6g3SuevRHFJAq5P5nwA== X-Received: by 2002:a2e:6503:: with SMTP id z3-v6mr6191340ljb.153.1547136859948; Thu, 10 Jan 2019 08:14:19 -0800 (PST) Received: from rafalkozik.semihalf.local (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id y81-v6sm15558112lje.30.2019.01.10.08.14.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 10 Jan 2019 08:14:19 -0800 (PST) From: Rafal Kozik 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 Date: Thu, 10 Jan 2019 17:14:03 +0100 Message-Id: <1547136846-23319-3-git-send-email-rk@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1547136846-23319-1-git-send-email-rk@semihalf.com> References: <1547136846-23319-1-git-send-email-rk@semihalf.com> Subject: [dpdk-dev] [PATCH 2/5] [pktgen] different PCAP per each queue X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" In some test scenario it is necessary to configure different flow per each Tx queue. This patch adds possibility to provide list of PCAPs files. If number of files is smaller than number of queues, first PCAP file is used for the queues which number is above the number of files. To achieve uniform throughput, average length of packets in each PCAP needs to be the same. Signed-off-by: Rafal Kozik --- app/pktgen-main.c | 40 ++++++++++++++++++++++++++++++---------- app/pktgen-pcap.c | 12 ++++++------ app/pktgen-port-cfg.c | 8 +++++++- app/pktgen-port-cfg.h | 1 + 4 files changed, 44 insertions(+), 17 deletions(-) diff --git a/app/pktgen-main.c b/app/pktgen-main.c index b90da0c..68ffa13 100644 --- a/app/pktgen-main.c +++ b/app/pktgen-main.c @@ -81,6 +81,7 @@ pktgen_usage(const char *prgname) printf( "Usage: %s [EAL options] -- [-h] [-v] [-P] [-G] [-T] [-f cmd_file] [-l log_file] [-s P:PCAP_file] [-m ]\n" " -s P:file PCAP packet stream file, 'P' is the port number\n" + " -s P:file0,file1,... list of PCAP packet stream files per queue, 'P' is the port number\n" " -f filename Command file (.pkt) to execute or a Lua script (.lua) file\n" " -l filename Write log to filename\n" " -P Enable PROMISCUOUS mode on all ports\n" @@ -142,10 +143,10 @@ pktgen_usage(const char *prgname) static int pktgen_parse_args(int argc, char **argv) { - int opt, ret, port; + int opt, ret, port, q; char **argvopt; int option_index; - char *prgname = argv[0], *p; + char *prgname = argv[0], *p, *pc; static struct option lgopts[] = { {"crc-strip", 0, 0, 0}, {NULL, 0, 0, 0} @@ -187,14 +188,27 @@ pktgen_parse_args(int argc, char **argv) case 's': /* Read a PCAP packet capture file (stream) */ port = strtol(optarg, NULL, 10); p = strchr(optarg, ':'); - if ( (p == NULL) || - (pktgen.info[port].pcap = - _pcap_open(++p, port)) == NULL) { - pktgen_log_error( - "Invalid PCAP filename (%s) must include port number as P:filename", - optarg); - pktgen_usage(prgname); - return -1; + pc = strchr(optarg, ','); + if (p == NULL) + goto pcap_err; + if (pc == NULL) { + pktgen.info[port].pcap = _pcap_open(++p, port); + if (pktgen.info[port].pcap == NULL) + goto pcap_err; + } else { + q = 0; + while (p != NULL && q < NUM_Q) { + p++; + pc = strchr(p, ','); + if (pc != NULL) + *pc = '\0'; + pktgen.info[port].pcaps[q] = _pcap_open(p, port); + if (pktgen.info[port].pcaps[q] == NULL) + goto pcap_err; + p = pc; + q++; + } + pktgen.info[port].pcap = pktgen.info[port].pcaps[0]; } break; case 'P': /* Enable promiscuous mode on the ports */ @@ -257,6 +271,12 @@ pktgen_parse_args(int argc, char **argv) ret = optind - 1; optind = 1; /* reset getopt lib */ return ret; + +pcap_err: + pktgen_log_error("Invalid PCAP filename (%s) must include port number as P:filename", + optarg); + pktgen_usage(prgname); + return -1; } #define MAX_BACKTRACE 32 diff --git a/app/pktgen-pcap.c b/app/pktgen-pcap.c index dffdd13..e7ef9a2 100644 --- a/app/pktgen-pcap.c +++ b/app/pktgen-pcap.c @@ -343,9 +343,9 @@ pktgen_pcap_parse(pcap_info_t *pcap, port_info_t *info, unsigned qid) /* If count is greater then zero then we allocate and create the PCAP mbuf pool. */ if (elt_count > 0) { /* Create the average size packet */ - info->pcap->pkt_size = (pkt_sizes / elt_count); - info->pcap->pkt_count = elt_count; - info->pcap->pkt_idx = 0; + pcap->pkt_size = (pkt_sizes / elt_count); + pcap->pkt_count = elt_count; + pcap->pkt_idx = 0; _pcap_rewind(pcap); @@ -374,15 +374,15 @@ pktgen_pcap_parse(pcap_info_t *pcap, port_info_t *info, unsigned qid) scrn_printf(0, 0, "\r"); if (info->q[qid].pcap_mp == NULL) pktgen_log_panic("Cannot init port %d for %d PCAP packets", - info->pid, info->pcap->pkt_count); + info->pid, pcap->pkt_count); - data_size = (info->pcap->pkt_count * DEFAULT_MBUF_SIZE); + data_size = (pcap->pkt_count * DEFAULT_MBUF_SIZE); scrn_printf(0, 0, " Create: %-*s - Number of MBUFs %6u for %5d packets = %6u KB\n", 16, name, elt_count, - info->pcap->pkt_count, + pcap->pkt_count, (data_size + 1023) / 1024); pktgen.mem_used += data_size; pktgen.total_mem_used += data_size; diff --git a/app/pktgen-port-cfg.c b/app/pktgen-port-cfg.c index a1da13c..91ce694 100644 --- a/app/pktgen-port-cfg.c +++ b/app/pktgen-port-cfg.c @@ -318,7 +318,13 @@ pktgen_config_ports(void) pktgen_log_panic("Cannot init port %d for Special TX mbufs", pid); /* Setup the PCAP file for each port */ - if (pktgen.info[pid].pcap != NULL) + if (pktgen.info[pid].pcaps[q] != NULL) { + if (pktgen_pcap_parse(pktgen.info[pid].pcaps[q], info, q) == -1) { + pktgen_log_panic( + "Cannot load PCAP file for port %d queue %d", + pid, q); + } + } else if (pktgen.info[pid].pcap != NULL) if (pktgen_pcap_parse(pktgen.info[pid].pcap, info, q) == -1) pktgen_log_panic("Cannot load PCAP file for port %d", pid); diff --git a/app/pktgen-port-cfg.h b/app/pktgen-port-cfg.h index 89019e4..381ddfe 100644 --- a/app/pktgen-port-cfg.h +++ b/app/pktgen-port-cfg.h @@ -214,6 +214,7 @@ typedef struct port_info_s { int32_t rx_tapfd; /**< Rx Tap file descriptor */ int32_t tx_tapfd; /**< Tx Tap file descriptor */ pcap_info_t *pcap; /**< PCAP information header */ + pcap_info_t *pcaps[NUM_Q]; /**< Per Tx queue PCAP information headers */ uint64_t pcap_cycles; /**< number of cycles for pcap sending */ int32_t pcap_result; /**< PCAP result of filter compile */