From patchwork Tue Nov 17 07:06:15 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Balasubramanian Manoharan X-Patchwork-Id: 56708 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp1759505lbb; Mon, 16 Nov 2015 23:06:35 -0800 (PST) X-Received: by 10.140.178.146 with SMTP id y140mr12849619qhy.100.1447743995274; Mon, 16 Nov 2015 23:06:35 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id e8si1860860qgf.2.2015.11.16.23.06.34; Mon, 16 Nov 2015 23:06:35 -0800 (PST) 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; dkim=neutral (body hash did not verify) header.i=@linaro_org.20150623.gappssmtp.com Received: by lists.linaro.org (Postfix, from userid 109) id 9C3FA61CE0; Tue, 17 Nov 2015 07:06:34 +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.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID, 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 6807C61CD4; Tue, 17 Nov 2015 07:06:30 +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 34FA861CDE; Tue, 17 Nov 2015 07:06:28 +0000 (UTC) Received: from mail-pa0-f52.google.com (mail-pa0-f52.google.com [209.85.220.52]) by lists.linaro.org (Postfix) with ESMTPS id 2E28E61B43 for ; Tue, 17 Nov 2015 07:06:27 +0000 (UTC) Received: by padhx2 with SMTP id hx2so202254879pad.1 for ; Mon, 16 Nov 2015 23:06:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro_org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=0UI5VK8m54qUCkpW3JSbAIwsXFVdiuUhRPW1H7BLxmM=; b=UYW4Nq+CfQtn9XfEa5wb23LNqG5PIbAuKWFuu3OdLa5J3tkrpXZ9q3mk+Q5MYRMwKn 5l1xbf/vwxIB4mmQev3G1fmsj3b6f6Geooeb4Q0HP4eIkgv6/JtWkjSkNjcRJaX92ndG 7ub8l/aP9+vXu5L2TxZ7iZUTHAvIWpC96Wn/FmWm82HwHIXmt/XvIPWo5vqv6WdT5lVe iHV9kreGijrUYM3MjLSHNdW9fl8NuERVPH8hC3PW0+WcHM50ncdF0bdvp6mYZ7ZTfROs sHlDqTrhA0V0L8PYlbrj7lchPsUOpo45NpDMaz0L12juXmKA1xPEuyZW0Qqpu8r7vfO0 uhSA== 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; bh=0UI5VK8m54qUCkpW3JSbAIwsXFVdiuUhRPW1H7BLxmM=; b=CC23XPIgqNIPTAEbnbwIr4qkJ2eWXG9NA0b7Ri2YdBPMqFsgMsRZpnnzzv2YUugHZx CDgnH+p2IQdO4DG5gCnnL7wxH5smz/VDMfcM2euBAeraQgxi19V42KrzpgBlgG5jtUcS 3apR8skhlVE8jGJNJcP0wJr6d3UzbW3ziCUnNdAuUbK48UXIYry7LVrrlQ0RRCrYKmB5 Yul6AWHcwvo9+BFV44ORvJwd7nhmkF+llFJyRlceQpPbYsnhsbX2d1Qn7CuQ0z5TlNBU I5NV4+g3fUe06tTmxaWHSD8cHu0J4GDdVyi2TnYSmrlZPifTDgWMskJTiPrgUWBCENQ2 dFoQ== X-Gm-Message-State: ALoCoQntzSVowIRVwKbWwjy4VwcIIbkTYetoVCW106Hu4IlbwYxFEQqkuckUTIudLRs2oAk2QJvq X-Received: by 10.66.160.229 with SMTP id xn5mr60898029pab.0.1447743986405; Mon, 16 Nov 2015 23:06:26 -0800 (PST) Received: from localhost.localdomain ([122.166.219.57]) by smtp.gmail.com with ESMTPSA id f5sm32045752pas.8.2015.11.16.23.06.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 16 Nov 2015 23:06:25 -0800 (PST) From: Balasubramanian Manoharan To: lng-odp@lists.linaro.org Date: Tue, 17 Nov 2015 12:36:15 +0530 Message-Id: <1447743975-12255-1-git-send-email-bala.manoharan@linaro.org> X-Mailer: git-send-email 1.9.1 X-Topics: patch Subject: [lng-odp] [PATCH] api: packet: add detailed packet error api 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" Adds api to get packet error flags for L2, L3 and L4 errors. Signed-off-by: Balasubramanian Manoharan --- include/odp/api/packet_flags.h | 33 +++++++++++++++++++++++++++++++ platform/linux-generic/odp_packet_flags.c | 32 ++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) diff --git a/include/odp/api/packet_flags.h b/include/odp/api/packet_flags.h index 7c3b247..c4a6832 100644 --- a/include/odp/api/packet_flags.h +++ b/include/odp/api/packet_flags.h @@ -38,6 +38,17 @@ extern "C" { int odp_packet_has_error(odp_packet_t pkt); /** + * check for packet L2 error + * + * checks for all L2 errors + * + * @param pkt Packet handle + * @retval non-zero packet has L2 errors + * @retval 0 packet has no L2 error + */ +int odp_packet_has_l2_error(odp_packet_t pkt); + +/** * Check for L2 header, e.g. ethernet * * @param pkt Packet handle @@ -47,6 +58,17 @@ int odp_packet_has_error(odp_packet_t pkt); int odp_packet_has_l2(odp_packet_t pkt); /** + * check for packet L3 error + * + * checks for all L3 errors + * + * @param pkt Packet handle + * @retval non-zero packet has L3 errors + * @retval 0 packet has no L3 error + */ +int odp_packet_has_l3_error(odp_packet_t pkt); + +/** * Check for L3 header, e.g. IPv4, IPv6 * * @param pkt Packet handle @@ -56,6 +78,17 @@ int odp_packet_has_l2(odp_packet_t pkt); int odp_packet_has_l3(odp_packet_t pkt); /** + * check for packet L4 error + * + * checks for all L4 errors + * + * @param pkt Packet handle + * @retval non-zero packet has L4 errors + * @retval 0 packet has no L2 error + */ +int odp_packet_has_l4_error(odp_packet_t pkt); + +/** * Check for L4 header, e.g. UDP, TCP, SCTP (also ICMP) * * @param pkt Packet handle diff --git a/platform/linux-generic/odp_packet_flags.c b/platform/linux-generic/odp_packet_flags.c index dbc3137..68a79bc 100644 --- a/platform/linux-generic/odp_packet_flags.c +++ b/platform/linux-generic/odp_packet_flags.c @@ -38,16 +38,48 @@ int odp_packet_has_l2(odp_packet_t pkt) return pkt_hdr->input_flags.l2; } +int odp_packet_has_l2_error(odp_packet_t pkt) +{ + odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); + + if (packet_parse_not_complete(pkt_hdr)) + packet_parse_full(pkt_hdr); + + return pkt_hdr->error_flags.frame_len + | pkt_hdr->error_flags.snap_len + | pkt_hdr->error_flags.l2_chksum; +} + int odp_packet_has_l3(odp_packet_t pkt) { retflag(pkt, input_flags.l3); } +int odp_packet_has_l3_error(odp_packet_t pkt) +{ + odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); + + if (packet_parse_not_complete(pkt_hdr)) + packet_parse_full(pkt_hdr); + + return pkt_hdr->error_flags.ip_err; +} + int odp_packet_has_l4(odp_packet_t pkt) { retflag(pkt, input_flags.l4); } +int odp_packet_has_l4_error(odp_packet_t pkt) +{ + odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); + + if (packet_parse_not_complete(pkt_hdr)) + packet_parse_full(pkt_hdr); + + return pkt_hdr->error_flags.tcp_err | pkt_hdr->error_flags.udp_err; +} + int odp_packet_has_eth(odp_packet_t pkt) { odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt);