From patchwork Tue Jan 5 08:51:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Balasubramanian Manoharan X-Patchwork-Id: 59169 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp5843401lbb; Tue, 5 Jan 2016 00:51:26 -0800 (PST) X-Received: by 10.140.150.129 with SMTP id 123mr67481885qhw.14.1451983886139; Tue, 05 Jan 2016 00:51:26 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id m65si45054176qhm.84.2016.01.05.00.51.25; Tue, 05 Jan 2016 00:51:26 -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 Received: by lists.linaro.org (Postfix, from userid 109) id 858CD617B6; Tue, 5 Jan 2016 08:51:25 +0000 (UTC) Authentication-Results: lists.linaro.org; dkim=fail reason="verification failed; unprotected key" header.d=linaro.org header.i=@linaro.org header.b=Va72Sxfk; dkim-adsp=none (unprotected policy); dkim-atps=neutral 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_H2,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 751C06175B; Tue, 5 Jan 2016 08:51:21 +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 8AB0561762; Tue, 5 Jan 2016 08:51:18 +0000 (UTC) Received: from mail-pf0-f179.google.com (mail-pf0-f179.google.com [209.85.192.179]) by lists.linaro.org (Postfix) with ESMTPS id A8A1B6172A for ; Tue, 5 Jan 2016 08:51:17 +0000 (UTC) Received: by mail-pf0-f179.google.com with SMTP id q63so181026553pfb.0 for ; Tue, 05 Jan 2016 00:51:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=irjjIZEL05RcKVbii7vkq9O9sO35XNJRkwZZOtdvOr0=; b=Va72SxfkpkcwSsui8vL9T/YVd5lh9JxXITyIXEliwreV5ZZIZ73DJBFfzOiGGCSJ9M PMCPcPh7a4FFcJJscCoe2SBkJStxPqpgIMJBVR30D+e0QNKN/MKeHAVzeL30qKNMMvhu GtWvBBEhzI5m9H7gwpggHviHpjJINhXeDe+iQ= 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=irjjIZEL05RcKVbii7vkq9O9sO35XNJRkwZZOtdvOr0=; b=D9f8TL9pLoZOxSNk7D2op5J/D+0cNgNmT32du/pW9Jlp+gskOUp2l66CFiPbJwY0GG IvMR8f+dhiUTn+gfKVbM29shF+FMjeC6N0Jwi5XuMNBdOMCYUor01GfSeso5cjhPj+4c j7dBcy9/8z/1tUZL2c0g3xTWerIw7jVBA+AI53HxaiwdL53rv9mubyMHOKBpZA4Wiss5 +ztyXB9QfAbjbws2z4FewujgHu8KcaLq6S9x8YwxpbRYt3+OVi95jKP/ArRmSIcxBPJ7 LWlfFxdlLreIc8nEomQPuERCKGaBs8xuh7hUSqrSHMO7kSEEw5Xkflq41C/3uQPUXgOf 1QnA== X-Gm-Message-State: ALoCoQmeUbrXdqVTBvxDR4ENNav9Fwiv0L+MG1p/1t3c8M/pr8PjGdTsVKEpDppZJbaRwq4c6VHEKbglsym3IW1UHL8hKUdmMg== X-Received: by 10.98.89.207 with SMTP id k76mr115764667pfj.36.1451983876971; Tue, 05 Jan 2016 00:51:16 -0800 (PST) Received: from localhost.localdomain ([111.93.218.67]) by smtp.gmail.com with ESMTPSA id dg12sm90437955pac.47.2016.01.05.00.51.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 05 Jan 2016 00:51:16 -0800 (PST) From: Balasubramanian Manoharan To: lng-odp@lists.linaro.org Date: Tue, 5 Jan 2016 14:21:07 +0530 Message-Id: <1451983867-7025-1-git-send-email-bala.manoharan@linaro.org> X-Mailer: git-send-email 1.9.1 X-Topics: patch Subject: [lng-odp] [API-NEXT PATCHv2] api: packet: add detailed packet error flags 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" Additional APIs to get packet error flags for L2, L3 and L4 errors. Signed-off-by: Balasubramanian Manoharan --- v2: Incorporates review comments from Petri include/odp/api/packet_flags.h | 33 +++++++++++++++++++++++++++++++ platform/linux-generic/odp_packet_flags.c | 30 ++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) diff --git a/include/odp/api/packet_flags.h b/include/odp/api/packet_flags.h index 7c3b247..8de0c82 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 errors + * + * check 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 errors + * + * check 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 errors + * + * check for all L4 errors + * + * @param pkt Packet handle + * @retval non-zero packet has L4 errors + * @retval 0 packet has no L4 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 3537aa9..ae9a9ed 100644 --- a/platform/linux-generic/odp_packet_flags.c +++ b/platform/linux-generic/odp_packet_flags.c @@ -38,16 +38,46 @@ 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); + /* L2 parsing is always done by default and hence + no additional check is required */ + 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);