From patchwork Sun Apr 8 13:14:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bing Zhao X-Patchwork-Id: 37538 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 0A2441B6AF; Sun, 8 Apr 2018 15:14:27 +0200 (CEST) Received: from m50-132.163.com (m50-132.163.com [123.125.50.132]) by dpdk.org (Postfix) with ESMTP id 16E661B6A3 for ; Sun, 8 Apr 2018 15:14:23 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=IQROjg+RpbEAoLPtsj aYmPYhPW3ktvTi//jzyPQueBA=; b=ZEuJ5IL82cbsdDf7M74tTFe0Vgo8ZkrwoV u6LxaZ8T8yHbNxBEoADUtuPmrecYFrsad0RMCVQST2BlxxHeUhHj55Duo9W+6Ot3 +hhL2kUznXrFikJATylKW54JiMG2E5lsHtGF2aTGz6NA59HKIQuvDIyMIqngimmv dGr5MrrE8= Received: from SHL0405.hxtcorp.net (unknown [101.81.130.12]) by smtp2 (Coremail) with SMTP id DNGowAAnBx2rFcpaG3EHAQ--.22400S2; Sun, 08 Apr 2018 21:14:20 +0800 (CST) From: Bing Zhao To: keith.wiles@intel.com, dev@dpdk.org Cc: bing.zhao@hxt-semitech.com, Bing Zhao Date: Sun, 8 Apr 2018 21:14:19 +0800 Message-Id: <20180408131419.16348-1-ilovethull@163.com> X-Mailer: git-send-email 2.11.0.windows.1 X-CM-TRANSID: DNGowAAnBx2rFcpaG3EHAQ--.22400S2 X-Coremail-Antispam: 1Uf129KBjvJXoW7tF48Cr1xKry7Ww4xKF15Arb_yoW8XF4Dp3 98KFWjgrWktr18Wr17Cw1rGry5AFsYqr4UWr92g34DZw4qyry0qr4SkF4av3WUZr4xW34a qan0gF9Y9F4UZFUanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07b1c_-UUUUU= X-Originating-IP: [101.81.130.12] X-CM-SenderInfo: xlor4vhwkxzzi6rwjhhfrp/1tbiFQwit1WBfsnwHgAAsB Subject: [dpdk-dev] [PATCH] [pktgen] [PATCH] Ignore the enable range cmd when sending packets 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" When using "enable [ports] range" command to enable the range sending feature, the code will only set the "SEND_RANGE_PKTS" without any "CLEAR_FAST_ALLOC_FLAG" (belongs to "start" command). If the enable actiong is done when no packets are sending, everything will be OK. But when sending packets, it will automaticlly switch the bufferpool from tx_mp to range_mp without "pktgen_setup_packets" called to set up and fill some fileds of the buffers. I assume that the sending process will fail and the buffers will get leaked. (Correct me if anything wrong). And the alloc function will return -105 which indicates no free buffer. Then the only thing we can do is to quit the process and restart it. To avoid such wrong operation procedures, a check is added in the enable_range function. Thanks Signed-off-by: Bing Zhao --- app/pktgen-cmds.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/pktgen-cmds.c b/app/pktgen-cmds.c index 66ea98a..cc3a2ec 100644 --- a/app/pktgen-cmds.c +++ b/app/pktgen-cmds.c @@ -2591,6 +2591,10 @@ void enable_range(port_info_t *info, uint32_t state) { if (state == ENABLE_STATE) { + if (SENDING_PACKETS & rte_atomic32_read(&info->port_flags)) { + pktgen_log_warning("Cannot enable the range settings while sending packets!"); + return; + } pktgen_clr_port_flags(info, SEND_SEQ_PKTS); pktgen_clr_port_flags(info, SEND_PCAP_PKTS); pktgen_set_port_flags(info, SEND_RANGE_PKTS);