From patchwork Sat Nov 15 21:32:38 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 40876 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f69.google.com (mail-wg0-f69.google.com [74.125.82.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 7D477244FC for ; Sat, 15 Nov 2014 21:33:03 +0000 (UTC) Received: by mail-wg0-f69.google.com with SMTP id k14sf1153618wgh.8 for ; Sat, 15 Nov 2014 13:33:02 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:subject :precedence:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:mime-version:errors-to:sender :x-original-sender:x-original-authentication-results:mailing-list :content-type:content-transfer-encoding; bh=f4Od5MEJ0lNMnzm5q/1yir8eiQ+hRIDM6sfnRoFlOk4=; b=G3HC7CW5w/r8VOL/tXc+ne1QzKMdy6WNKMp9zAfFUV/HIVy1HBiJXcjYhlRinYr5vG 1RR1PuQAEnX/qhDn0hMmO7WK8MiwQ7io4gnVwBSrZis1iSbI4vA+oQtNGLxEesBcU6wi xvsgMCUT0A3oDYXw1iH2KZClWf3xEM/E30L3NsDwAq6QPb8g5DZAkrkQBCz+jlpeoMZ/ WZJR/8Pcu1FBWvRlhej7R3ue0gEXb5uGjw6QuWisvxk/JOBz7Qs7lBIGSaZR00HUQIvt KTz1eYcVYw6SEZwEXCESFfSVh7A0MVOz6yyUjw+4hiLom3xA3TDaGGgD8P7BmXzjj7Uz dkfA== X-Gm-Message-State: ALoCoQlLuqPDdiUyZXq0tRR3XV6mQbJkxaMgHKkYqVbvBiUd1q3+6gYJM3DdITuWm1MkP8M3LuCp X-Received: by 10.180.85.97 with SMTP id g1mr492495wiz.0.1416087182810; Sat, 15 Nov 2014 13:33:02 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.228.140 with SMTP id si12ls1005852lac.25.gmail; Sat, 15 Nov 2014 13:33:02 -0800 (PST) X-Received: by 10.112.199.227 with SMTP id jn3mr3585995lbc.86.1416087182576; Sat, 15 Nov 2014 13:33:02 -0800 (PST) Received: from mail-la0-f41.google.com (mail-la0-f41.google.com. [209.85.215.41]) by mx.google.com with ESMTPS id r8si12919062laj.68.2014.11.15.13.33.02 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 15 Nov 2014 13:33:02 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.41 as permitted sender) client-ip=209.85.215.41; Received: by mail-la0-f41.google.com with SMTP id gf13so4786862lab.28 for ; Sat, 15 Nov 2014 13:33:02 -0800 (PST) X-Received: by 10.153.7.72 with SMTP id da8mr2246354lad.90.1416087182206; Sat, 15 Nov 2014 13:33:02 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.184.201 with SMTP id ew9csp969308lbc; Sat, 15 Nov 2014 13:33:01 -0800 (PST) X-Received: by 10.140.22.201 with SMTP id 67mr21626239qgn.16.1416087180818; Sat, 15 Nov 2014 13:33:00 -0800 (PST) Received: from ip-10-35-177-41.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id 6si45706088qaw.77.2014.11.15.13.32.58 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Sat, 15 Nov 2014 13:33:00 -0800 (PST) Received-SPF: none (google.com: lng-odp-bounces@lists.linaro.org does not designate permitted sender hosts) client-ip=54.225.227.206; Received: from localhost ([127.0.0.1] helo=ip-10-35-177-41.ec2.internal) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1Xpkxl-0001tP-Hf; Sat, 15 Nov 2014 21:32:57 +0000 Received: from mail-lb0-f181.google.com ([209.85.217.181]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1Xpkxf-0001tK-Ga for lng-odp@lists.linaro.org; Sat, 15 Nov 2014 21:32:51 +0000 Received: by mail-lb0-f181.google.com with SMTP id l4so14256287lbv.26 for ; Sat, 15 Nov 2014 13:32:45 -0800 (PST) X-Received: by 10.112.159.129 with SMTP id xc1mr16033351lbb.24.1416087165525; Sat, 15 Nov 2014 13:32:45 -0800 (PST) Received: from localhost.localdomain (broadband-46-188-125-121.2com.net. [46.188.125.121]) by mx.google.com with ESMTPSA id c5sm537835laa.34.2014.11.15.13.32.43 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 15 Nov 2014 13:32:44 -0800 (PST) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Sun, 16 Nov 2014 00:32:38 +0300 Message-Id: <1416087158-6149-1-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 1.8.5.1.163.gd7aced9 X-Topics: patch Subject: [lng-odp] [PATCH] simplify pktin_dequeue/pktin_deq_multi functions X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: lng-odp-bounces@lists.linaro.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: maxim.uvarov@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.41 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Keep original logic but make function more clear. Signed-off-by: Maxim Uvarov --- platform/linux-generic/odp_packet_io.c | 62 +++++++++++++++------------------- 1 file changed, 27 insertions(+), 35 deletions(-) diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c index f35193f..d4af13e 100644 --- a/platform/linux-generic/odp_packet_io.c +++ b/platform/linux-generic/odp_packet_io.c @@ -416,31 +416,24 @@ int pktin_enqueue(queue_entry_t *qentry, odp_buffer_hdr_t *buf_hdr) odp_buffer_hdr_t *pktin_dequeue(queue_entry_t *qentry) { odp_buffer_hdr_t *buf_hdr; + odp_buffer_t buf; + odp_packet_t pkt_tbl[QUEUE_MULTI_MAX]; + odp_buffer_hdr_t *tmp_hdr_tbl[QUEUE_MULTI_MAX]; + int pkts, i; buf_hdr = queue_deq(qentry); + if (buf_hdr != NULL) + return buf_hdr; - if (buf_hdr == NULL) { - odp_packet_t pkt; - odp_buffer_t buf; - odp_packet_t pkt_tbl[QUEUE_MULTI_MAX]; - odp_buffer_hdr_t *tmp_hdr_tbl[QUEUE_MULTI_MAX]; - int pkts, i, j; - - pkts = odp_pktio_recv(qentry->s.pktin, pkt_tbl, - QUEUE_MULTI_MAX); - - if (pkts > 0) { - pkt = pkt_tbl[0]; - buf = odp_packet_to_buffer(pkt); - buf_hdr = odp_buf_to_hdr(buf); + pkts = odp_pktio_recv(qentry->s.pktin, pkt_tbl, QUEUE_MULTI_MAX); + if (pkts <= 0) + return buf_hdr; - for (i = 1, j = 0; i < pkts; ++i) { - buf = odp_packet_to_buffer(pkt_tbl[i]); - tmp_hdr_tbl[j++] = odp_buf_to_hdr(buf); - } - queue_enq_multi(qentry, tmp_hdr_tbl, j); - } + for (i = 0; i < pkts; ++i) { + buf = odp_packet_to_buffer(pkt_tbl[i]); + tmp_hdr_tbl[i] = odp_buf_to_hdr(buf); } + queue_enq_multi(qentry, tmp_hdr_tbl, i); return buf_hdr; } @@ -454,25 +447,24 @@ int pktin_enq_multi(queue_entry_t *qentry, odp_buffer_hdr_t *buf_hdr[], int num) int pktin_deq_multi(queue_entry_t *qentry, odp_buffer_hdr_t *buf_hdr[], int num) { int nbr; + odp_packet_t pkt_tbl[QUEUE_MULTI_MAX]; + odp_buffer_hdr_t *tmp_hdr_tbl[QUEUE_MULTI_MAX]; + odp_buffer_t buf; + int pkts, i; nbr = queue_deq_multi(qentry, buf_hdr, num); + if (nbr >= num) + return nbr; - if (nbr < num) { - odp_packet_t pkt_tbl[QUEUE_MULTI_MAX]; - odp_buffer_hdr_t *tmp_hdr_tbl[QUEUE_MULTI_MAX]; - odp_buffer_t buf; - int pkts, i; - - pkts = odp_pktio_recv(qentry->s.pktin, pkt_tbl, - QUEUE_MULTI_MAX); - if (pkts > 0) { - for (i = 0; i < pkts; ++i) { - buf = odp_packet_to_buffer(pkt_tbl[i]); - tmp_hdr_tbl[i] = odp_buf_to_hdr(buf); - } - queue_enq_multi(qentry, tmp_hdr_tbl, pkts); - } + pkts = odp_pktio_recv(qentry->s.pktin, pkt_tbl, QUEUE_MULTI_MAX); + if (pkts <= 0) + return nbr; + + for (i = 0; i < pkts; ++i) { + buf = odp_packet_to_buffer(pkt_tbl[i]); + tmp_hdr_tbl[i] = odp_buf_to_hdr(buf); } + queue_enq_multi(qentry, tmp_hdr_tbl, pkts); return nbr; }