From patchwork Tue Jan 9 12:00:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 123900 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp3939897qgn; Tue, 9 Jan 2018 04:08:00 -0800 (PST) X-Google-Smtp-Source: ACJfBotPGD/mPNf4Pl2OjoCabORGalixTLW181r+LuCQWfxTlPBzmnmqzvfuCKflkV83WGHRWb0P X-Received: by 10.200.57.129 with SMTP id v1mr21306834qte.50.1515499680715; Tue, 09 Jan 2018 04:08:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515499680; cv=none; d=google.com; s=arc-20160816; b=wUp3oMMwNuMyUmOAVs+J2dgZVHk6hPiqYCvjhcuJmTmaYO//XSRNQ9DHGlWDRUOfgn HJzJFSzMPIjlH+5SmKvmHaPLrvywORneuZ6OnHzDeClGJ1PYdSDxuIbDvkI6TgAEPEKf p8RXpgZI78tcimZXgQdqlzLLPQM73u8V4MAZ+h2Vk+QfTKqsNq/LP+XsdVfrntjXEX1p P0CS9ZTG/6a9nS4j+NtlClwmFLc+1tHdOzWmwk6fuzK1vlS0wToe8Fgu5RyA1E+Yz0oq wT1iyupZCL9WHx9Zo0s+QUnuqr7b0yRbHjg41Kg4wsIIcRN9mxVsMmTxVvNY8pv4ySvX i0Og== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=fMFf8DZ4k7+k4j/iqoZjYpvZPf55OdZSlNXJbo0Xa08=; b=bhbF4nDeFlXyE7BV5JzLRFPK60rNC4VhG4Leo4VnjPmrooUxGyaaqmGeF6x8sBS2mP YwKfDWICZMlW+msdTpM5t4SykVefTCq3SlvJ20gxkcycWK22hLgX9E+2MiuawPRFRxwN uQjlJ0XccELcIMrZ81ZfFbFsuoPZKEaATMeejkcLclnSwwUu9InkOWwu/JijZnP2MKzW ZM2daYWMfrRwt0OdluHxsflinJdKe3shxoMEDuqBgWlTIXhQK24qKHAkAPjsOSTGqfE/ S5yrCzfOP8BTpSoNViLqCAmMxN3xK3RBdVJXha4QBLV+cQgZPbei2wj3ejMm7SiF0WZ4 sYTg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id w140si4302317qkb.333.2018.01.09.04.08.00; Tue, 09 Jan 2018 04:08:00 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 5D4F461706; Tue, 9 Jan 2018 12:08:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2 autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id A9A2961735; Tue, 9 Jan 2018 12:03:41 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id A808261706; Tue, 9 Jan 2018 12:03:23 +0000 (UTC) Received: from forward100o.mail.yandex.net (forward100o.mail.yandex.net [37.140.190.180]) by lists.linaro.org (Postfix) with ESMTPS id 614B56171F for ; Tue, 9 Jan 2018 12:00:30 +0000 (UTC) Received: from mxback3o.mail.yandex.net (mxback3o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::1d]) by forward100o.mail.yandex.net (Yandex) with ESMTP id F3C4F2A22BF4 for ; Tue, 9 Jan 2018 15:00:28 +0300 (MSK) Received: from smtp2o.mail.yandex.net (smtp2o.mail.yandex.net [2a02:6b8:0:1a2d::26]) by mxback3o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id fy69rokexj-0MQ4pReH; Tue, 09 Jan 2018 15:00:22 +0300 Received: by smtp2o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id 0CYWcrRWVI-0M58rCAJ; Tue, 09 Jan 2018 15:00:22 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Tue, 9 Jan 2018 15:00:16 +0300 Message-Id: <1515499216-4272-6-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1515499216-4272-1-git-send-email-odpbot@yandex.ru> References: <1515499216-4272-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 343 Subject: [lng-odp] [PATCH v3 5/5] example: generator: replace L3/L4 packet parsing with a simple one X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" From: Bogdan Pricope Platform packet parsing is providing information not needed by this application while consuming cycles. Replacing platform packet parsing with a limited parsing may increase performance on RX side. Signed-off-by: Bogdan Pricope --- /** Email created from pull request 343 (bogdanPricope:generator_rx_direct_pr) ** https://github.com/Linaro/odp/pull/343 ** Patch: https://github.com/Linaro/odp/pull/343.patch ** Base sha: 49ebafae0edebbc750742d8874ad0a7588286dea ** Merge commit sha: 2eefe24f19e219515f14085c88dda09761f71845 **/ example/generator/odp_generator.c | 49 ++++++++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 16 deletions(-) diff --git a/example/generator/odp_generator.c b/example/generator/odp_generator.c index e3a523843..537ee7388 100644 --- a/example/generator/odp_generator.c +++ b/example/generator/odp_generator.c @@ -572,6 +572,12 @@ static int create_pktio(const char *dev, odp_pool_t pool, itf->config.pktout.bit.udp_chksum = 0; } + itf->config.parser.layer = ODP_PROTO_LAYER_L2; + if (itf->config.pktin.bit.udp_chksum) + itf->config.parser.layer = ODP_PROTO_LAYER_L4; + else if (itf->config.pktin.bit.ipv4_chksum) + itf->config.parser.layer = ODP_PROTO_LAYER_L3; + if (odp_pktio_config(itf->pktio, &itf->config)) { EXAMPLE_ERR("Error: Failed to set interface configuration %s\n", dev); @@ -781,11 +787,12 @@ static int gen_send_thread(void *arg) */ static void process_icmp_pkt(int thr, thread_args_t *thr_args, - odph_icmphdr_t *icmp) + uint8_t *_icmp) { uint64_t trecv; uint64_t tsend; uint64_t rtt_ms, rtt_us; + odph_icmphdr_t *icmp = (odph_icmphdr_t *)_icmp; if (icmp->type == ICMP_ECHOREPLY) { thr_args->counters.ctr_icmp_reply_rcv++; @@ -818,18 +825,12 @@ static void process_pkts(int thr, thread_args_t *thr_args, { odp_packet_t pkt; odp_packet_chksum_status_t csum_status; - char *buf; + uint32_t left, offset, i; odph_ipv4hdr_t *ip; - odph_icmphdr_t *icmp; - unsigned i; for (i = 0; i < len; ++i) { pkt = pkt_tbl[i]; - /* only ip pkts */ - if (!odp_packet_has_ipv4(pkt)) - continue; - csum_status = odp_packet_l3_chksum_status(pkt); if (csum_status == ODP_PACKET_CHKSUM_BAD) printf("L3 checksum error detected.\n"); @@ -842,20 +843,36 @@ static void process_pkts(int thr, thread_args_t *thr_args, if (odp_unlikely(odp_packet_has_error(pkt))) continue; + offset = odp_packet_l3_offset(pkt); + left = odp_packet_len(pkt) - offset; + + if (left < sizeof(odph_ipv4hdr_t)) + continue; + + ip = (odph_ipv4hdr_t *)((uint8_t *)odp_packet_data(pkt) + + offset); + + /* only ip pkts */ + if (ODPH_IPV4HDR_VER(ip->ver_ihl) != ODPH_IPV4) + continue; + thr_args->counters.ctr_pkt_rcv++; - buf = odp_packet_data(pkt); - ip = (odph_ipv4hdr_t *)(buf + odp_packet_l3_offset(pkt)); /* udp */ - if (ip->proto == ODPH_IPPROTO_UDP) + if (ip->proto == ODPH_IPPROTO_UDP) { thr_args->counters.ctr_udp_rcv++; + } else if (ip->proto == ODPH_IPPROTO_ICMPv4) { + uint32_t l3_size = ODPH_IPV4HDR_IHL(ip->ver_ihl) * 4; + + offset += l3_size; + left -= l3_size; - /* icmp */ - if (ip->proto == ODPH_IPPROTO_ICMPv4) { - icmp = (odph_icmphdr_t *)(buf + - odp_packet_l4_offset(pkt)); + if (left < sizeof(odph_icmphdr_t)) + continue; - process_icmp_pkt(thr, thr_args, icmp); + process_icmp_pkt(thr, thr_args, + (uint8_t *)odp_packet_data(pkt) + + offset); } } }