From patchwork Thu Jun 2 07:45:47 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Elo, Matias \(Nokia - FI/Espoo\)" X-Patchwork-Id: 69130 Delivered-To: patch@linaro.org Received: by 10.140.23.41 with SMTP id 38csp193406qgo; Thu, 2 Jun 2016 00:46:01 -0700 (PDT) X-Received: by 10.107.59.18 with SMTP id i18mr1607678ioa.161.1464853561015; Thu, 02 Jun 2016 00:46:01 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id l194si24752602iol.136.2016.06.02.00.46.00; Thu, 02 Jun 2016 00:46:00 -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; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE dis=NONE) header.from=nokia.com Received: by lists.linaro.org (Postfix, from userid 109) id 70FB461766; Thu, 2 Jun 2016 07:46: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=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, URIBL_BLOCKED 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 EF19061714; Thu, 2 Jun 2016 07:45:56 +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 ACFF961740; Thu, 2 Jun 2016 07:45:54 +0000 (UTC) Received: from demumfd001.nsn-inter.net (demumfd001.nsn-inter.net [93.183.12.32]) by lists.linaro.org (Postfix) with ESMTPS id 92E9A61714 for ; Thu, 2 Jun 2016 07:45:53 +0000 (UTC) Received: from demuprx016.emea.nsn-intra.net ([10.150.129.55]) by demumfd001.nsn-inter.net (8.15.2/8.15.2) with ESMTPS id u527jqWA019207 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 2 Jun 2016 07:45:52 GMT Received: from 10.144.19.15 ([10.144.104.109]) by demuprx016.emea.nsn-intra.net (8.12.11.20060308/8.12.11) with ESMTP id u527jpOI016092 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO) for ; Thu, 2 Jun 2016 09:45:51 +0200 From: Matias Elo To: lng-odp@lists.linaro.org Date: Thu, 2 Jun 2016 10:45:47 +0300 Message-Id: <1464853550-9104-1-git-send-email-matias.elo@nokia.com> X-Mailer: git-send-email 1.9.1 X-purgate-type: clean X-purgate-Ad: Categorized by eleven eXpurgate (R) http://www.eleven.de X-purgate: clean X-purgate: This mail is considered clean (visit http://www.eleven.de for further information) X-purgate-size: 1924 X-purgate-ID: 151667::1464853552-00004C87-0B84215E/0/0 X-Topics: patch Subject: [lng-odp] [PATCH v2 1/4] linux-gen: netmap: handle modified _odp_packet_cls_enq() return values correctly 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: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" Do not increase the count of received packets if classifier already handled the packet. Fixes odp_classifier example crashing with netmap pktio. Signed-off-by: Matias Elo Reviewed-and-tested-by: Bill Fischofer --- platform/linux-generic/pktio/netmap.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/platform/linux-generic/pktio/netmap.c b/platform/linux-generic/pktio/netmap.c index 1042fd1..820629c 100644 --- a/platform/linux-generic/pktio/netmap.c +++ b/platform/linux-generic/pktio/netmap.c @@ -585,7 +585,7 @@ static int netmap_stop(pktio_entry_t *pktio_entry ODP_UNUSED) * @param len Netmap buffer length * @param ts Pointer to pktin timestamp * - * @retval 0 on success + * @retval Number of created packets * @retval <0 on failure */ static inline int netmap_pkt_to_odp(pktio_entry_t *pktio_entry, @@ -637,7 +637,7 @@ static inline int netmap_pkt_to_odp(pktio_entry_t *pktio_entry, *pkt_out = pkt; } - return 0; + return 1; } static inline int netmap_recv_desc(pktio_entry_t *pktio_entry, @@ -650,6 +650,7 @@ static inline int netmap_recv_desc(pktio_entry_t *pktio_entry, char *buf; uint32_t slot_id; int i; + int ret; int ring_id = desc->cur_rx_ring; int num_rx = 0; int num_rings = desc->last_rx_ring - desc->first_rx_ring + 1; @@ -674,10 +675,11 @@ static inline int netmap_recv_desc(pktio_entry_t *pktio_entry, odp_prefetch(buf); - if (!netmap_pkt_to_odp(pktio_entry, &pkt_table[num_rx], - buf, ring->slot[slot_id].len, - ts)) - num_rx++; + ret = netmap_pkt_to_odp(pktio_entry, &pkt_table[num_rx], + buf, ring->slot[slot_id].len, + ts); + if (ret > 0) + num_rx += ret; ring->cur = nm_ring_next(ring, slot_id); ring->head = ring->cur;