From patchwork Tue Sep 13 14:30:11 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: 76074 Delivered-To: patch@linaro.org Received: by 10.140.106.72 with SMTP id d66csp1391783qgf; Tue, 13 Sep 2016 07:31:32 -0700 (PDT) X-Received: by 10.55.165.195 with SMTP id o186mr1301719qke.24.1473777092308; Tue, 13 Sep 2016 07:31:32 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id n75si12853072qki.21.2016.09.13.07.31.31; Tue, 13 Sep 2016 07:31:32 -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 0AC2860F21; Tue, 13 Sep 2016 14:31:31 +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=-1.9 required=5.0 tests=BAD_ENC_HEADER,BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS 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 DA544615B2; Tue, 13 Sep 2016 14:30:53 +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 0A606615B2; Tue, 13 Sep 2016 14:30:43 +0000 (UTC) Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on0128.outbound.protection.outlook.com [104.47.0.128]) by lists.linaro.org (Postfix) with ESMTPS id CA18F609AA for ; Tue, 13 Sep 2016 14:30:38 +0000 (UTC) Received: from DB4PR07CA009.eurprd07.prod.outlook.com (10.242.229.19) by VI1PR07MB1088.eurprd07.prod.outlook.com (10.163.168.24) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.609.9; Tue, 13 Sep 2016 14:30:36 +0000 Received: from DB3FFO11FD050.protection.gbl (2a01:111:f400:7e04::130) by DB4PR07CA009.outlook.office365.com (2a01:111:e400:9828::19) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.619.10 via Frontend Transport; Tue, 13 Sep 2016 14:30:36 +0000 Received-SPF: Pass (protection.outlook.com: domain of nokia.com designates 131.228.2.240 as permitted sender) receiver=protection.outlook.com; client-ip=131.228.2.240; helo=fihe3nok0734.emea.nsn-net.net; Received: from fihe3nok0734.emea.nsn-net.net (131.228.2.240) by DB3FFO11FD050.mail.protection.outlook.com (10.47.217.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.619.6 via Frontend Transport; Tue, 13 Sep 2016 14:30:36 +0000 Received: from fihe3nok0734.emea.nsn-net.net (localhost [127.0.0.1]) by fihe3nok0734.emea.nsn-net.net (8.14.9/8.14.5) with ESMTP id u8DEUCps003568 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 13 Sep 2016 17:30:12 +0300 Received: from 10.144.19.15 ([10.144.104.92]) by fihe3nok0734.emea.nsn-net.net (8.14.9/8.14.5) with ESMTP id u8DEUCG4003526 (version=TLSv1/SSLv3 cipher=AES128-SHA256 bits=128 verify=NOT) for ; Tue, 13 Sep 2016 17:30:12 +0300 X-HPESVCS-Source-Ip: 10.144.104.92 From: Matias Elo To: Date: Tue, 13 Sep 2016 17:30:11 +0300 Message-ID: <1473777012-21850-2-git-send-email-matias.elo@nokia.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1473777012-21850-1-git-send-email-matias.elo@nokia.com> References: <1473777012-21850-1-git-send-email-matias.elo@nokia.com> X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:131.228.2.240; IPV:NLI; CTRY:FI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(7916002)(2980300002)(438002)(199003)(189002)(50986999)(19580405001)(106466001)(19580395003)(76176999)(356003)(87936001)(110136003)(305945005)(450100001)(2906002)(7846002)(107886002)(97736004)(5003940100001)(16796002)(48376002)(586003)(33646002)(92566002)(11100500001)(47776003)(189998001)(36756003)(50226002)(2351001)(8676002)(5660300001)(81156014)(81166006)(77096005)(229853001)(8936002)(626004)(2950100001)(68736007)(50466002)(42882005); DIR:OUT; SFP:1102; SCL:1; SRVR:VI1PR07MB1088; H:fihe3nok0734.emea.nsn-net.net; FPR:; SPF:Pass; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; DB3FFO11FD050; 1:zBHemWXe3w4u6FXwkOIVym71YwtXqhRxoAby863I0Z9jb4DgfwTNfHALpHzCTunOmIidY+oMpvh/Sjcfrex7NxiXtmP+X7qP9J6jLCWWCcm5eV3fB0LHK3Kxx3JC1n71mLYuZjiga4ZhibNhp+RPDOZo+3PFao61CMA6NMm74VwGiNGr7wPSI+FURAEWX2U+XCeOhm4/5fPfw4Wh07VPhIJBs66y6bJ5sjZgKLuFTa2qKAR/3Asph4EOMSJcuv6mRZcSa/+7usYfHcVgxCS70pV2qBLj1CuN8YNF8O0boGcOBB4izYth+1trBGkcmrA0XehVsxK4p7/58pERb3xwj5XGG8iZpx3QHISwitvHdQC7qWYmNWvNGdEvPnIqeXs9ULnh1MN4UHaV6YWhIKZ+xe7p50Fx0aUaPlkaZVZQr8jo/I8K2RW9M8fsJveWYUGDac4kK76Cq15T4SXJQW5TIic1Y8TdSKJQLmYuoDidAwA= MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 618f93dd-37b9-464d-181a-08d3dbe28728 X-Microsoft-Exchange-Diagnostics: 1; VI1PR07MB1088; 2:KQJQtyx4KN9XBRALrvFtrLcwsB9p08n7lw3e63fbD2Cjjl48mCR4drGv3r6lxr0UjdHF1lQioSO3FWNjnOVM4FntGDFLvoY7qOyDv7ujPl9q7nxPjq92aA2uaBW5qEFk1S9FW7pPpD7YEPNoc7Fdy6OFfhX8PBTzxgbTZpd8mA1rsSpk9m74FUHcAbYbMoGa; 3:K7CuJ3cdk17wtaE2eSXG6uBg8+gJ3dgt9cAlKv6lA3oz2JgnqNv31SSURXH9rdU1crUZYqTmzpMkdYTmuAoSM73pE6UV6DV04VK8ephqIFzCwpcXEnyWxMNfYjQ+tDYIvPPzJas8dAsL6JN/qNrJLC61Uj8XXvIUElZSu/yMpDa7r8jRPLuVmEo/+h/x9eHDH4WqS3G1KUwge99T5VayujNzjWYmD81jBtISktY/gQwR8JQ3VgRg+Cxuk7OiTIZ8ozUDZ6f2fSIjgVSPJAl4SA== X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(8251501002); SRVR:VI1PR07MB1088; X-Microsoft-Exchange-Diagnostics: 1; VI1PR07MB1088; 25:uCqWRYKZSUS6kh4IhpytzRblCFpWDNJwOO8cXcvGsJL6cwRn0U8W7QYC/BjeGd0NSPOVnuYWXADdhBEhFAw9EkPVllGF73rT5poni3/wuwQDeD+ER2V/bVxHJgsX69oD31UY+3K6LnxCZFeVYV/woL4fAPrYMGLu4+QsN/NzuMuwwFl9F5gZHu4kJ7u3mjuW05yZmswRRC7Zfs0cc7kn5s+d749IZFtXOrqO76xrc/xUv6jusAshUy0iMc4fH+6t2icfllC+D7SAnTOeRq5HI3Pa/XKygKn5f6STCL8+YW0MzXG6stNpGUyttxlnbYnGZROZCx7CqACSZgt1LE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GBBMn/jw28y69WSSSkphjaSl8S6tn0NZr1ZzYNqFJCRgTJBKdJOdoPCINp6Oe+qLsNl1UFD0ZIj15rvQsP/GmaUq0za0kGcipZke4zRlAGMZJ+x7hWUIg+pG/5mZDmwh8rNSSSmRlSHET5qlDlSWQgY57WmEfeGIkmFI5PjYuK7nik15SNLnwETSklc0JxEO3E24vhgaRP40oNaQy0EM6Hd/CKzBS6UWHzcDYPjHuUZ5BYruQXxSi4= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(82608151540597); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(13016025)(13018025)(8121501046)(5005006)(10201501046)(3002001)(6055026); SRVR:VI1PR07MB1088; BCL:0; PCL:0; RULEID:; SRVR:VI1PR07MB1088; X-Microsoft-Exchange-Diagnostics: 1; VI1PR07MB1088; 4:N7cTr1z79KPwv5X2MXuGZoAKmpFXbFdQN5mYFSPUvwDqKXJRte7shgNYJ0DtfrtvmR6mOmRVJ99F57eUjLaS8TBDktTMgs0UiyPuuHJdYAlw91s/H9JdbpKXcPuXEaiIAMuvbT9zxYOKziWPvtMDHymau9PB+15jG6ZU//lutN4wg8nF/0v2+H9c+4rn66Cu/LD/cdlNOQvwDiekHoHMmP8enJIV3JE47HYKxB36q9uMzrRO2OWH1EwW0IKrt8mdveMSmW1jw4SoU7SNlhBoZEh8fD3+GA1devuyhFsbGELAj+E8gzfowt4+Vep6SOreq/OcBL7QIYX7kyOs2M6Ds9WmZz8IJNOWsLkfQFylu8DYdhz7rhr9zsaDOQikvuno65JhsGbA0IMTyU0gQcX6o4nLBtlzvXX4Tcldy/N+JRH0d1kg+KaZ/uZqj1qOdD7ACZZYAX0fCJydBlsy9iihkYdSx60wLktPYfvy2LxccM0= X-Forefront-PRVS: 0064B3273C X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR07MB1088; 23:NL6x5UWrQi551XyuXC0vps4b8146KmiqtNXRr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EJb4bNScCISk8AhEdmmtfx6GsKDp5kMuQkks8EPkhrAbF42xQzLZHtpjXP+xBqPh2LiqNRZlDFZGQpMBli0KFlFCYId16wJQOykOz9NXkxFCs9HO5GzZgbiA SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: nokia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Sep 2016 14:30:36.4143 (UTC) X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5d471751-9675-428d-917b-70f44f9630b0; Ip=[131.228.2.240]; Helo=[fihe3nok0734.emea.nsn-net.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR07MB1088 X-Topics: patch Subject: [lng-odp] [PATCH 2/3] linux-gen: packet: parse only required packet header layers 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: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" Improve performance by parsing only the required protocol layers. Signed-off-by: Matias Elo --- .../linux-generic/include/odp_packet_internal.h | 3 - platform/linux-generic/odp_classification.c | 2 +- platform/linux-generic/odp_packet.c | 36 +++---- platform/linux-generic/odp_packet_flags.c | 112 ++++++++++----------- 4 files changed, 69 insertions(+), 84 deletions(-) -- 2.7.4 diff --git a/platform/linux-generic/include/odp_packet_internal.h b/platform/linux-generic/include/odp_packet_internal.h index 9b4f59e..b23ad9c 100644 --- a/platform/linux-generic/include/odp_packet_internal.h +++ b/platform/linux-generic/include/odp_packet_internal.h @@ -328,9 +328,6 @@ int packet_alloc_multi(odp_pool_t pool_hdl, uint32_t len, /* Fill in parser metadata for L2 */ void packet_parse_l2(packet_parser_t *prs, uint32_t frame_len); -/* Perform full packet parse */ -int packet_parse_full(odp_packet_hdr_t *pkt_hdr); - /* Perform packet parse up to a given protocol layer */ int packet_parse_layer(odp_packet_hdr_t *pkt_hdr, layer_t layer); diff --git a/platform/linux-generic/odp_classification.c b/platform/linux-generic/odp_classification.c index 868058d..82760e8 100644 --- a/platform/linux-generic/odp_classification.c +++ b/platform/linux-generic/odp_classification.c @@ -775,7 +775,7 @@ static inline cos_t *cls_select_cos(pktio_entry_t *entry, /* Check for lazy parse needed */ if (packet_parse_not_complete(pkt_hdr)) - packet_parse_full(pkt_hdr); + packet_parse_layer(pkt_hdr, LAYER_ALL); /* Return error cos for error packet */ if (pkt_hdr->p.error_flags.all) diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c index 5f84869..df6fd1e 100644 --- a/platform/linux-generic/odp_packet.c +++ b/platform/linux-generic/odp_packet.c @@ -476,8 +476,8 @@ void *odp_packet_l3_ptr(odp_packet_t pkt, uint32_t *len) { odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); - if (packet_parse_not_complete(pkt_hdr)) - packet_parse_full(pkt_hdr); + if (pkt_hdr->p.parsed_layers < LAYER_L3) + packet_parse_layer(pkt_hdr, LAYER_L3); return packet_map(pkt_hdr, pkt_hdr->p.l3_offset, len); } @@ -485,8 +485,8 @@ uint32_t odp_packet_l3_offset(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); + if (pkt_hdr->p.parsed_layers < LAYER_L3) + packet_parse_layer(pkt_hdr, LAYER_L3); return pkt_hdr->p.l3_offset; } @@ -497,8 +497,8 @@ int odp_packet_l3_offset_set(odp_packet_t pkt, uint32_t offset) if (offset >= pkt_hdr->frame_len) return -1; - if (packet_parse_not_complete(pkt_hdr)) - packet_parse_full(pkt_hdr); + if (pkt_hdr->p.parsed_layers < LAYER_L3) + packet_parse_layer(pkt_hdr, LAYER_L3); pkt_hdr->p.l3_offset = offset; return 0; } @@ -507,8 +507,8 @@ void *odp_packet_l4_ptr(odp_packet_t pkt, uint32_t *len) { odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); - if (packet_parse_not_complete(pkt_hdr)) - packet_parse_full(pkt_hdr); + if (pkt_hdr->p.parsed_layers < LAYER_L4) + packet_parse_layer(pkt_hdr, LAYER_L4); return packet_map(pkt_hdr, pkt_hdr->p.l4_offset, len); } @@ -516,8 +516,8 @@ uint32_t odp_packet_l4_offset(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); + if (pkt_hdr->p.parsed_layers < LAYER_L4) + packet_parse_layer(pkt_hdr, LAYER_L4); return pkt_hdr->p.l4_offset; } @@ -528,8 +528,8 @@ int odp_packet_l4_offset_set(odp_packet_t pkt, uint32_t offset) if (offset >= pkt_hdr->frame_len) return -1; - if (packet_parse_not_complete(pkt_hdr)) - packet_parse_full(pkt_hdr); + if (pkt_hdr->p.parsed_layers < LAYER_L4) + packet_parse_layer(pkt_hdr, LAYER_L4); pkt_hdr->p.l4_offset = offset; return 0; } @@ -1354,18 +1354,6 @@ parse_exit: /** * Simple packet parser */ -int packet_parse_full(odp_packet_hdr_t *pkt_hdr) -{ - uint32_t seg_len; - void *base = packet_map(pkt_hdr, 0, &seg_len); - - return packet_parse_common(&pkt_hdr->p, base, pkt_hdr->frame_len, - seg_len, LAYER_ALL); -} - -/** - * Simple packet parser - */ int packet_parse_layer(odp_packet_hdr_t *pkt_hdr, layer_t layer) { uint32_t seg_len; diff --git a/platform/linux-generic/odp_packet_flags.c b/platform/linux-generic/odp_packet_flags.c index b88324c..798fa11 100644 --- a/platform/linux-generic/odp_packet_flags.c +++ b/platform/linux-generic/odp_packet_flags.c @@ -7,17 +7,17 @@ #include #include -#define retflag(pkt, x) do { \ +#define retflag(pkt, x, layer) do { \ odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); \ - if (packet_parse_not_complete(pkt_hdr)) \ - packet_parse_full(pkt_hdr); \ + if (pkt_hdr->p.parsed_layers < layer) \ + packet_parse_layer(pkt_hdr, layer); \ return pkt_hdr->p.x; \ } while (0) -#define setflag(pkt, x, v) do { \ +#define setflag(pkt, x, v, layer) do { \ odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); \ - if (packet_parse_not_complete(pkt_hdr)) \ - packet_parse_full(pkt_hdr); \ + if (pkt_hdr->p.parsed_layers < layer) \ + packet_parse_layer(pkt_hdr, layer); \ pkt_hdr->p.x = v & 1; \ } while (0) @@ -26,7 +26,7 @@ int odp_packet_has_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); + packet_parse_layer(pkt_hdr, LAYER_ALL); return odp_packet_hdr(pkt)->p.error_flags.all != 0; } @@ -51,30 +51,30 @@ int odp_packet_has_l2_error(odp_packet_t pkt) int odp_packet_has_l3(odp_packet_t pkt) { - retflag(pkt, input_flags.l3); + retflag(pkt, input_flags.l3, LAYER_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); + if (pkt_hdr->p.parsed_layers < LAYER_L3) + packet_parse_layer(pkt_hdr, LAYER_L3); return pkt_hdr->p.error_flags.ip_err; } int odp_packet_has_l4(odp_packet_t pkt) { - retflag(pkt, input_flags.l4); + retflag(pkt, input_flags.l4, LAYER_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); + if (pkt_hdr->p.parsed_layers < LAYER_L4) + packet_parse_layer(pkt_hdr, LAYER_L4); return pkt_hdr->p.error_flags.tcp_err | pkt_hdr->p.error_flags.udp_err; } @@ -88,12 +88,12 @@ int odp_packet_has_eth(odp_packet_t pkt) int odp_packet_has_eth_bcast(odp_packet_t pkt) { - retflag(pkt, input_flags.eth_bcast); + retflag(pkt, input_flags.eth_bcast, LAYER_L2); } int odp_packet_has_eth_mcast(odp_packet_t pkt) { - retflag(pkt, input_flags.eth_mcast); + retflag(pkt, input_flags.eth_mcast, LAYER_L2); } int odp_packet_has_jumbo(odp_packet_t pkt) @@ -105,72 +105,72 @@ int odp_packet_has_jumbo(odp_packet_t pkt) int odp_packet_has_vlan(odp_packet_t pkt) { - retflag(pkt, input_flags.vlan); + retflag(pkt, input_flags.vlan, LAYER_L2); } int odp_packet_has_vlan_qinq(odp_packet_t pkt) { - retflag(pkt, input_flags.vlan_qinq); + retflag(pkt, input_flags.vlan_qinq, LAYER_L2); } int odp_packet_has_arp(odp_packet_t pkt) { - retflag(pkt, input_flags.arp); + retflag(pkt, input_flags.arp, LAYER_L3); } int odp_packet_has_ipv4(odp_packet_t pkt) { - retflag(pkt, input_flags.ipv4); + retflag(pkt, input_flags.ipv4, LAYER_L3); } int odp_packet_has_ipv6(odp_packet_t pkt) { - retflag(pkt, input_flags.ipv6); + retflag(pkt, input_flags.ipv6, LAYER_L3); } int odp_packet_has_ip_bcast(odp_packet_t pkt) { - retflag(pkt, input_flags.ip_bcast); + retflag(pkt, input_flags.ip_bcast, LAYER_L3); } int odp_packet_has_ip_mcast(odp_packet_t pkt) { - retflag(pkt, input_flags.ip_mcast); + retflag(pkt, input_flags.ip_mcast, LAYER_L3); } int odp_packet_has_ipfrag(odp_packet_t pkt) { - retflag(pkt, input_flags.ipfrag); + retflag(pkt, input_flags.ipfrag, LAYER_L3); } int odp_packet_has_ipopt(odp_packet_t pkt) { - retflag(pkt, input_flags.ipopt); + retflag(pkt, input_flags.ipopt, LAYER_L3); } int odp_packet_has_ipsec(odp_packet_t pkt) { - retflag(pkt, input_flags.ipsec); + retflag(pkt, input_flags.ipsec, LAYER_L4); } int odp_packet_has_udp(odp_packet_t pkt) { - retflag(pkt, input_flags.udp); + retflag(pkt, input_flags.udp, LAYER_L4); } int odp_packet_has_tcp(odp_packet_t pkt) { - retflag(pkt, input_flags.tcp); + retflag(pkt, input_flags.tcp, LAYER_L4); } int odp_packet_has_sctp(odp_packet_t pkt) { - retflag(pkt, input_flags.sctp); + retflag(pkt, input_flags.sctp, LAYER_L4); } int odp_packet_has_icmp(odp_packet_t pkt) { - retflag(pkt, input_flags.icmp); + retflag(pkt, input_flags.icmp, LAYER_L4); } int odp_packet_has_flow_hash(odp_packet_t pkt) @@ -189,7 +189,7 @@ int odp_packet_has_ts(odp_packet_t pkt) odp_packet_color_t odp_packet_color(odp_packet_t pkt) { - retflag(pkt, input_flags.color); + retflag(pkt, input_flags.color, LAYER_ALL); } void odp_packet_color_set(odp_packet_t pkt, odp_packet_color_t color) @@ -197,7 +197,7 @@ void odp_packet_color_set(odp_packet_t pkt, odp_packet_color_t color) odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); if (packet_parse_not_complete(pkt_hdr)) - packet_parse_full(pkt_hdr); + packet_parse_layer(pkt_hdr, LAYER_ALL); pkt_hdr->p.input_flags.color = color; } @@ -207,19 +207,19 @@ odp_bool_t odp_packet_drop_eligible(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); + packet_parse_layer(pkt_hdr, LAYER_ALL); return !pkt_hdr->p.input_flags.nodrop; } void odp_packet_drop_eligible_set(odp_packet_t pkt, odp_bool_t drop) { - setflag(pkt, input_flags.nodrop, !drop); + setflag(pkt, input_flags.nodrop, !drop, LAYER_ALL); } int8_t odp_packet_shaper_len_adjust(odp_packet_t pkt) { - retflag(pkt, output_flags.shaper_len_adj); + retflag(pkt, output_flags.shaper_len_adj, LAYER_ALL); } void odp_packet_shaper_len_adjust_set(odp_packet_t pkt, int8_t adj) @@ -227,7 +227,7 @@ void odp_packet_shaper_len_adjust_set(odp_packet_t pkt, int8_t adj) odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); if (packet_parse_not_complete(pkt_hdr)) - packet_parse_full(pkt_hdr); + packet_parse_layer(pkt_hdr, LAYER_ALL); pkt_hdr->p.output_flags.shaper_len_adj = adj; } @@ -236,107 +236,107 @@ void odp_packet_shaper_len_adjust_set(odp_packet_t pkt, int8_t adj) void odp_packet_has_l2_set(odp_packet_t pkt, int val) { - setflag(pkt, input_flags.l2, val); + setflag(pkt, input_flags.l2, val, LAYER_L2); } void odp_packet_has_l3_set(odp_packet_t pkt, int val) { - setflag(pkt, input_flags.l3, val); + setflag(pkt, input_flags.l3, val, LAYER_L3); } void odp_packet_has_l4_set(odp_packet_t pkt, int val) { - setflag(pkt, input_flags.l4, val); + setflag(pkt, input_flags.l4, val, LAYER_L4); } void odp_packet_has_eth_set(odp_packet_t pkt, int val) { - setflag(pkt, input_flags.eth, val); + setflag(pkt, input_flags.eth, val, LAYER_L2); } void odp_packet_has_eth_bcast_set(odp_packet_t pkt, int val) { - setflag(pkt, input_flags.eth_bcast, val); + setflag(pkt, input_flags.eth_bcast, val, LAYER_L2); } void odp_packet_has_eth_mcast_set(odp_packet_t pkt, int val) { - setflag(pkt, input_flags.eth_mcast, val); + setflag(pkt, input_flags.eth_mcast, val, LAYER_L2); } void odp_packet_has_jumbo_set(odp_packet_t pkt, int val) { - setflag(pkt, input_flags.jumbo, val); + setflag(pkt, input_flags.jumbo, val, LAYER_L2); } void odp_packet_has_vlan_set(odp_packet_t pkt, int val) { - setflag(pkt, input_flags.vlan, val); + setflag(pkt, input_flags.vlan, val, LAYER_L2); } void odp_packet_has_vlan_qinq_set(odp_packet_t pkt, int val) { - setflag(pkt, input_flags.vlan_qinq, val); + setflag(pkt, input_flags.vlan_qinq, val, LAYER_L2); } void odp_packet_has_arp_set(odp_packet_t pkt, int val) { - setflag(pkt, input_flags.arp, val); + setflag(pkt, input_flags.arp, val, LAYER_L3); } void odp_packet_has_ipv4_set(odp_packet_t pkt, int val) { - setflag(pkt, input_flags.ipv4, val); + setflag(pkt, input_flags.ipv4, val, LAYER_L3); } void odp_packet_has_ipv6_set(odp_packet_t pkt, int val) { - setflag(pkt, input_flags.ipv6, val); + setflag(pkt, input_flags.ipv6, val, LAYER_L3); } void odp_packet_has_ip_bcast_set(odp_packet_t pkt, int val) { - setflag(pkt, input_flags.ip_bcast, val); + setflag(pkt, input_flags.ip_bcast, val, LAYER_L3); } void odp_packet_has_ip_mcast_set(odp_packet_t pkt, int val) { - setflag(pkt, input_flags.ip_mcast, val); + setflag(pkt, input_flags.ip_mcast, val, LAYER_L3); } void odp_packet_has_ipfrag_set(odp_packet_t pkt, int val) { - setflag(pkt, input_flags.ipfrag, val); + setflag(pkt, input_flags.ipfrag, val, LAYER_L3); } void odp_packet_has_ipopt_set(odp_packet_t pkt, int val) { - setflag(pkt, input_flags.ipopt, val); + setflag(pkt, input_flags.ipopt, val, LAYER_L3); } void odp_packet_has_ipsec_set(odp_packet_t pkt, int val) { - setflag(pkt, input_flags.ipsec, val); + setflag(pkt, input_flags.ipsec, val, LAYER_L4); } void odp_packet_has_udp_set(odp_packet_t pkt, int val) { - setflag(pkt, input_flags.udp, val); + setflag(pkt, input_flags.udp, val, LAYER_L4); } void odp_packet_has_tcp_set(odp_packet_t pkt, int val) { - setflag(pkt, input_flags.tcp, val); + setflag(pkt, input_flags.tcp, val, LAYER_L4); } void odp_packet_has_sctp_set(odp_packet_t pkt, int val) { - setflag(pkt, input_flags.sctp, val); + setflag(pkt, input_flags.sctp, val, LAYER_L4); } void odp_packet_has_icmp_set(odp_packet_t pkt, int val) { - setflag(pkt, input_flags.icmp, val); + setflag(pkt, input_flags.icmp, val, LAYER_L4); } void odp_packet_has_flow_hash_clr(odp_packet_t pkt)