From patchwork Wed Jun 3 16:44:19 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zoltan Kiss X-Patchwork-Id: 49485 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f198.google.com (mail-wi0-f198.google.com [209.85.212.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 89D8524612 for ; Wed, 3 Jun 2015 16:45:15 +0000 (UTC) Received: by wifx6 with SMTP id x6sf6852711wif.1 for ; Wed, 03 Jun 2015 09:45:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:delivered-to:from:to:date :message-id:in-reply-to:references:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :mime-version:content-type:content-transfer-encoding:errors-to :sender:x-original-sender:x-original-authentication-results :mailing-list; bh=iGzp6yGwkcZLpASBO0SBgNJjq674yTafr7SdHSaaH/4=; b=FZVhPRfwwGZUhqI0L9UIKJ5IsAOQy3GXlQw8qIL+kHnXcIBQtinyprP1dcSnTZo/DA tNLpd0qRw3upeewS+O300XYxy3XNqaI5dFjBfMO+5PpsQRRHDOlZjLgFKotPTeq9L2AB 0rK5Gnq3WsFFpybvx1kDQ0vsR4s6xWYrFamwmXZsnaOOB+4ylcyPzUXn3tiCe9YGm8mm KiuKcMVvzNc0tQc46fKj5MRTxY0Vzae+L2R9xSjjV71r51qKmnddw2ft15OnJHO/e269 35UEdnomaOvHacN4nX291k7GM/Ma/IpdiTOjvdLTgGxb5wVVAWWFECdN+Flxu8ayOhSj xK8g== X-Gm-Message-State: ALoCoQmx6eyjsLYTki6SP+ZbRG1IglFTPQSb1IMtUfF3wLWtyuhwmp/dShQIzCd0lLgxvixN9rCD X-Received: by 10.112.161.105 with SMTP id xr9mr31531772lbb.20.1433349914809; Wed, 03 Jun 2015 09:45:14 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.36.7 with SMTP id m7ls92883laj.70.gmail; Wed, 03 Jun 2015 09:45:14 -0700 (PDT) X-Received: by 10.152.204.7 with SMTP id ku7mr32899298lac.38.1433349914482; Wed, 03 Jun 2015 09:45:14 -0700 (PDT) Received: from mail-la0-f42.google.com (mail-la0-f42.google.com. [209.85.215.42]) by mx.google.com with ESMTPS id ba16si18452132lab.113.2015.06.03.09.45.14 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Jun 2015 09:45:14 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.42 as permitted sender) client-ip=209.85.215.42; Received: by laew7 with SMTP id w7so12838070lae.1 for ; Wed, 03 Jun 2015 09:45:14 -0700 (PDT) X-Received: by 10.112.220.7 with SMTP id ps7mr32471529lbc.72.1433349914370; Wed, 03 Jun 2015 09:45:14 -0700 (PDT) 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.108.230 with SMTP id hn6csp3999856lbb; Wed, 3 Jun 2015 09:45:13 -0700 (PDT) X-Received: by 10.55.21.211 with SMTP id 80mr59423648qkv.11.1433349913182; Wed, 03 Jun 2015 09:45:13 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id k109si1144323qgf.32.2015.06.03.09.45.12; Wed, 03 Jun 2015 09:45:13 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Received: by lists.linaro.org (Postfix, from userid 109) id 420A661F93; Wed, 3 Jun 2015 16:45:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from ip-10-142-244-252.ec2.internal (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id A1BE261F95; Wed, 3 Jun 2015 16:44:46 +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 CDB1261F93; Wed, 3 Jun 2015 16:44:43 +0000 (UTC) Received: from mail-wg0-f49.google.com (mail-wg0-f49.google.com [74.125.82.49]) by lists.linaro.org (Postfix) with ESMTPS id C04CB61F37 for ; Wed, 3 Jun 2015 16:44:42 +0000 (UTC) Received: by wgv5 with SMTP id 5so14213239wgv.1 for ; Wed, 03 Jun 2015 09:44:42 -0700 (PDT) X-Received: by 10.194.192.98 with SMTP id hf2mr63448994wjc.23.1433349882025; Wed, 03 Jun 2015 09:44:42 -0700 (PDT) Received: from localhost.localdomain ([90.152.119.35]) by mx.google.com with ESMTPSA id b20sm1843263wjb.46.2015.06.03.09.44.40 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 03 Jun 2015 09:44:41 -0700 (PDT) From: Zoltan Kiss To: lng-odp@lists.linaro.org Date: Wed, 3 Jun 2015 17:44:19 +0100 Message-Id: <1433349859-28565-2-git-send-email-zoltan.kiss@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1433349859-28565-1-git-send-email-zoltan.kiss@linaro.org> References: <1433349859-28565-1-git-send-email-zoltan.kiss@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCH 2/2] packet_io: release unsent packets after odp_pktio_send() X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 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" X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: zoltan.kiss@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.42 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 And change the behaviour in linux-generic implementation, where it's releasing it during the call. Signed-off-by: Zoltan Kiss --- example/packet/odp_pktio.c | 9 ++++++++- platform/linux-generic/odp_packet_io.c | 10 +++++++++- platform/linux-generic/odp_packet_socket.c | 6 ------ test/performance/odp_l2fwd.c | 11 +++++++++-- 4 files changed, 26 insertions(+), 10 deletions(-) diff --git a/example/packet/odp_pktio.c b/example/packet/odp_pktio.c index f08d9f4..4242caa 100644 --- a/example/packet/odp_pktio.c +++ b/example/packet/odp_pktio.c @@ -282,9 +282,16 @@ static void *pktio_ifburst_thread(void *arg) /* Drop packets with errors */ pkts_ok = drop_err_pkts(pkt_tbl, pkts); if (pkts_ok > 0) { + int sent; /* Swap Eth MACs and IP-addrs */ swap_pkt_addrs(pkt_tbl, pkts_ok); - odp_pktio_send(pktio, pkt_tbl, pkts_ok); + sent = odp_pktio_send(pktio, pkt_tbl, pkts_ok); + if (odp_unlikely(sent < pkts_ok)) { + err_cnt += pkts_ok - sent; + do + odp_packet_free(pkt_tbl[sent++]); + while (++sent < pkts_ok); + } } if (odp_unlikely(pkts_ok != pkts)) diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c index 5ae24b9..6e7db41 100644 --- a/platform/linux-generic/odp_packet_io.c +++ b/platform/linux-generic/odp_packet_io.c @@ -564,6 +564,9 @@ int pktout_enqueue(queue_entry_t *qentry, odp_buffer_hdr_t *buf_hdr) int nbr; nbr = odp_pktio_send(qentry->s.pktout, &pkt, len); + if (odp_unlikely(nbr == 0)) + odp_packet_free(pkt); + return (nbr == len ? 0 : -1); } @@ -583,7 +586,12 @@ int pktout_enq_multi(queue_entry_t *qentry, odp_buffer_hdr_t *buf_hdr[], for (i = 0; i < num; ++i) pkt_tbl[i] = _odp_packet_from_buffer(buf_hdr[i]->handle.handle); - nbr = odp_pktio_send(qentry->s.pktout, pkt_tbl, num); + i = nbr = odp_pktio_send(qentry->s.pktout, pkt_tbl, num); + if (odp_unlikely(i < num)) + do + odp_packet_free(pkt_tbl[i]); + while (++i < num); + return nbr; } diff --git a/platform/linux-generic/odp_packet_socket.c b/platform/linux-generic/odp_packet_socket.c index 9272146..309980d 100644 --- a/platform/linux-generic/odp_packet_socket.c +++ b/platform/linux-generic/odp_packet_socket.c @@ -301,9 +301,6 @@ int send_pkt_sock_basic(pkt_sock_t *const pkt_sock, } /* end while */ nb_tx = i; - for (i = 0; i < len; i++) - odp_packet_free(pkt_table[i]); - return nb_tx; } @@ -408,9 +405,6 @@ int send_pkt_sock_mmsg(pkt_sock_t *const pkt_sock, flags = 0; /* blocking for next rounds */ } - for (i = 0; i < len; i++) - odp_packet_free(pkt_table[i]); - return len; } diff --git a/test/performance/odp_l2fwd.c b/test/performance/odp_l2fwd.c index 5d4b833..8c64a9c 100644 --- a/test/performance/odp_l2fwd.c +++ b/test/performance/odp_l2fwd.c @@ -224,8 +224,15 @@ static void *pktio_ifburst_thread(void *arg) /* Drop packets with errors */ pkts_ok = drop_err_pkts(pkt_tbl, pkts); - if (pkts_ok > 0) - odp_pktio_send(pktio_dst, pkt_tbl, pkts_ok); + if (pkts_ok > 0) { + int sent = odp_pktio_send(pktio_dst, pkt_tbl, pkts_ok); + if (odp_unlikely(sent < pkts_ok)) { + stats->drops += pkts_ok - sent; + do + odp_packet_free(pkt_tbl[sent]); + while (++sent < pkts_ok); + } + } if (odp_unlikely(pkts_ok != pkts)) stats->drops += pkts - pkts_ok;