From patchwork Thu May 5 15:35:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zoltan Kiss X-Patchwork-Id: 67211 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp816059qge; Thu, 5 May 2016 08:37:28 -0700 (PDT) X-Received: by 10.50.223.148 with SMTP id qu20mr4674541igc.34.1462462647933; Thu, 05 May 2016 08:37:27 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id 6si10955160ioo.169.2016.05.05.08.37.27; Thu, 05 May 2016 08:37:27 -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=pass (p=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 34109615E5; Thu, 5 May 2016 15:37:27 +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, RCVD_IN_DNSWL_LOW, 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 5DBC1615F2; Thu, 5 May 2016 15:36:17 +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 9E45561617; Thu, 5 May 2016 15:36:13 +0000 (UTC) Received: from mail-wm0-f42.google.com (mail-wm0-f42.google.com [74.125.82.42]) by lists.linaro.org (Postfix) with ESMTPS id 2D6C2615E3 for ; Thu, 5 May 2016 15:35:49 +0000 (UTC) Received: by mail-wm0-f42.google.com with SMTP id n129so25395507wmn.1 for ; Thu, 05 May 2016 08:35:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=7wPHrRF2pFtKQ3qMQEITbLKOTxI9boX3WKAEHFBHPzE=; b=PQeLn/m/6XEmaTlNoQVLBYxhnt3w6yyi2WNp2Q7wjF7KJ/1WTIXHHX98Dpz/jQfFaf TKH/RVJRHFlAEkcIYqQL1WhAYjfDha927Euz3AQd41ofWXf/1aL/sdIEX/b9ZQAIG4dR D0++YQEPH6+tCtCGJ/XcK3J3j3tLipqHWjYemm5nlYKToP/W8YCnjeAkkPOklSKWCB1N 9851yDklRYvsdZHQM7pgS5QPSsCb6QOkP9E6/cxUWNHOLqhxgLWNr/TVLC/x7DQ6vNcY +DuHa1HtIewjksuLX5nJyRDjmj6T5t6RsWr7IKc2//gY+F6FjpmjwF7nFRSNBGgOvdU0 CNEQ== X-Gm-Message-State: AOPr4FU8QMwIUdbepn/u8QDwK0UGY8F1tudxeMkSLBwPXMICH5tm5WXvjTz3vcbqDrFg0Xhdgrw= X-Received: by 10.194.171.194 with SMTP id aw2mr17013032wjc.113.1462462548374; Thu, 05 May 2016 08:35:48 -0700 (PDT) Received: from localhost.localdomain ([195.11.233.227]) by smtp.googlemail.com with ESMTPSA id f8sm10302731wjm.13.2016.05.05.08.35.47 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 05 May 2016 08:35:47 -0700 (PDT) From: Zoltan Kiss To: lng-odp@lists.linaro.org Date: Thu, 5 May 2016 16:35:09 +0100 Message-Id: <1462462509-13337-4-git-send-email-zoltan.kiss@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1462462509-13337-1-git-send-email-zoltan.kiss@linaro.org> References: <1462462509-13337-1-git-send-email-zoltan.kiss@linaro.org> X-Topics: patch Cc: petri.savolainen@nokia.com Subject: [lng-odp] [PATCH v2 3/3] linux-generic: pktio: don't return packet after failed enqueue 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" If queue_enq() fails, there is a serious internal error, the packet should be released instead of passing it back to pktin_poll() for enqueueing on an another one. Also return the error if there is any, not just the queue_enq() ones. If CoS drops the packet, doesn't report it as an error Signed-off-by: Zoltan Kiss --- v2: - rebase - don't report discards as failure - add comment .../linux-generic/include/odp_packet_io_internal.h | 3 +- platform/linux-generic/pktio/dpdk.c | 10 +++--- platform/linux-generic/pktio/netmap.c | 8 ++--- platform/linux-generic/pktio/pktio_common.c | 36 +++++++++++++++++----- platform/linux-generic/pktio/socket.c | 9 +++--- platform/linux-generic/pktio/socket_mmap.c | 7 ++--- 6 files changed, 46 insertions(+), 27 deletions(-) diff --git a/platform/linux-generic/include/odp_packet_io_internal.h b/platform/linux-generic/include/odp_packet_io_internal.h index de6dab6..7dd578b 100644 --- a/platform/linux-generic/include/odp_packet_io_internal.h +++ b/platform/linux-generic/include/odp_packet_io_internal.h @@ -211,8 +211,7 @@ typedef struct pktio_if_ops { } pktio_if_ops_t; int _odp_packet_cls_enq(pktio_entry_t *pktio_entry, const uint8_t *base, - uint16_t buf_len, odp_time_t *ts, - odp_packet_t *pkt_ret); + uint16_t buf_len, odp_time_t *ts); extern void *pktio_entry_ptr[]; diff --git a/platform/linux-generic/pktio/dpdk.c b/platform/linux-generic/pktio/dpdk.c index 5315297..57c7d6e 100644 --- a/platform/linux-generic/pktio/dpdk.c +++ b/platform/linux-generic/pktio/dpdk.c @@ -712,10 +712,12 @@ static inline int mbuf_to_pkt(pktio_entry_t *pktio_entry, pkt_len = rte_pktmbuf_pkt_len(mbuf); if (pktio_cls_enabled(pktio_entry)) { - if (_odp_packet_cls_enq(pktio_entry, - (const uint8_t *)buf, pkt_len, - ts, &pkt_table[nb_pkts])) - nb_pkts++; + int ret; + ret = _odp_packet_cls_enq(pktio_entry, + (const uint8_t *)buf, + pkt_len, ts); + if (ret && ret != -ENOENT) + nb_pkts = ret; } else { pkt = packet_alloc(pktio_entry->s.pkt_dpdk.pool, pkt_len, 1); diff --git a/platform/linux-generic/pktio/netmap.c b/platform/linux-generic/pktio/netmap.c index 6065922..3e6a4f0 100644 --- a/platform/linux-generic/pktio/netmap.c +++ b/platform/linux-generic/pktio/netmap.c @@ -608,10 +608,10 @@ static inline int netmap_pkt_to_odp(pktio_entry_t *pktio_entry, if (pktio_cls_enabled(pktio_entry)) { ret = _odp_packet_cls_enq(pktio_entry, (const uint8_t *)buf, - len, ts, pkt_out); - if (ret) - return 0; - return -1; + len, ts); + if (ret && ret != -ENOENT) + return ret; + return 0; } else { odp_packet_hdr_t *pkt_hdr; diff --git a/platform/linux-generic/pktio/pktio_common.c b/platform/linux-generic/pktio/pktio_common.c index 942ea8c..8a01477 100644 --- a/platform/linux-generic/pktio/pktio_common.c +++ b/platform/linux-generic/pktio/pktio_common.c @@ -7,10 +7,27 @@ #include #include +#include +/** + * Classify packet, copy it in a odp_packet_t and enqueue to the right queue + * + * pktio_entry pktio where it arrived + * base packet data + * buf_len packet length + * + * Return values: + * 0 on success, packet is consumed + * -ENOENT CoS dropped the packet + * -EFAULT Bug + * -EINVAL Config error + * -ENOMEM Target CoS pool exhausted + * + * Note: *base is not released, only pkt if there is an error + * + */ int _odp_packet_cls_enq(pktio_entry_t *pktio_entry, - const uint8_t *base, uint16_t buf_len, - odp_time_t *ts, odp_packet_t *pkt_ret) + const uint8_t *base, uint16_t buf_len, odp_time_t *ts) { cos_t *cos; odp_packet_t pkt; @@ -25,14 +42,17 @@ int _odp_packet_cls_enq(pktio_entry_t *pktio_entry, cos = pktio_select_cos(pktio_entry, base, &src_pkt_hdr); /* if No CoS found then drop the packet */ - if (cos == NULL || cos->s.queue == NULL || cos->s.pool == NULL) - return 0; + if (cos == NULL) + return -EINVAL; + + if (cos->s.queue == NULL || cos->s.pool == NULL) + return -EFAULT; pool = cos->s.pool->s.pool_hdl; pkt = odp_packet_alloc(pool, buf_len); if (odp_unlikely(pkt == ODP_PACKET_INVALID)) - return 0; + return -ENOMEM; pkt_hdr = odp_packet_hdr(pkt); copy_packet_parser_metadata(&src_pkt_hdr, pkt_hdr); @@ -40,7 +60,7 @@ int _odp_packet_cls_enq(pktio_entry_t *pktio_entry, if (odp_packet_copy_from_mem(pkt, 0, buf_len, base) != 0) { odp_packet_free(pkt); - return 0; + return -EFAULT; } packet_set_ts(pkt_hdr, ts); @@ -49,8 +69,8 @@ int _odp_packet_cls_enq(pktio_entry_t *pktio_entry, odp_packet_pull_tail(pkt, odp_packet_len(pkt) - buf_len); ret = queue_enq(cos->s.queue, odp_buf_to_hdr((odp_buffer_t)pkt), 0); if (ret < 0) { - *pkt_ret = pkt; - return 1; + odp_packet_free(pkt); + return -EFAULT; } return 0; diff --git a/platform/linux-generic/pktio/socket.c b/platform/linux-generic/pktio/socket.c index 6f06170..a0aa9af 100644 --- a/platform/linux-generic/pktio/socket.c +++ b/platform/linux-generic/pktio/socket.c @@ -659,11 +659,10 @@ static int sock_mmsg_recv(pktio_entry_t *pktio_entry, eth_hdr->h_source))) continue; - ret = _odp_packet_cls_enq(pktio_entry, base, - pkt_len, ts, - &pkt_table[nb_rx]); - if (ret) - nb_rx++; + ret = _odp_packet_cls_enq(pktio_entry, base, pkt_len, + ts); + if (ret && ret != -ENOENT) + nb_rx = ret; } } else { struct iovec iovecs[ODP_PACKET_SOCKET_MAX_BURST_RX] diff --git a/platform/linux-generic/pktio/socket_mmap.c b/platform/linux-generic/pktio/socket_mmap.c index cbd71ba..4170456 100644 --- a/platform/linux-generic/pktio/socket_mmap.c +++ b/platform/linux-generic/pktio/socket_mmap.c @@ -195,10 +195,9 @@ static inline unsigned pkt_mmap_v2_rx(pktio_entry_t *pktio_entry, if (pktio_cls_enabled(pktio_entry)) { ret = _odp_packet_cls_enq(pktio_entry, pkt_buf, - pkt_len, ts, - &pkt_table[nb_rx]); - if (ret) - nb_rx++; + pkt_len, ts); + if (ret && ret != -ENOENT) + nb_rx = ret; } else { odp_packet_hdr_t *hdr;