From patchwork Thu Jun 16 13:07:29 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: 70187 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp254244qgy; Thu, 16 Jun 2016 06:10:40 -0700 (PDT) X-Received: by 10.55.108.2 with SMTP id h2mr4597806qkc.97.1466082640551; Thu, 16 Jun 2016 06:10:40 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id c130si23921782qkb.126.2016.06.16.06.10.40; Thu, 16 Jun 2016 06:10:40 -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 1711A687AE; Thu, 16 Jun 2016 13:10:40 +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_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, 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 D5306687A3; Thu, 16 Jun 2016 13:08:59 +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 7CCD168106; Thu, 16 Jun 2016 13:08:53 +0000 (UTC) Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on0092.outbound.protection.outlook.com [104.47.1.92]) by lists.linaro.org (Postfix) with ESMTPS id 9BBAB687A9 for ; Thu, 16 Jun 2016 13:08:37 +0000 (UTC) Received: from VI1PR07CA0101.eurprd07.prod.outlook.com (10.165.229.155) by VI1PR07MB1069.eurprd07.prod.outlook.com (10.163.168.17) with Microsoft SMTP Server (TLS) id 15.1.517.8; Thu, 16 Jun 2016 13:08:34 +0000 Received: from AM1FFO11FD001.protection.gbl (2a01:111:f400:7e00::187) by VI1PR07CA0101.outlook.office365.com (2a01:111:e400:7a52::27) with Microsoft SMTP Server (TLS) id 15.1.523.12 via Frontend Transport; Thu, 16 Jun 2016 13:08:35 +0000 Received-SPF: Pass (protection.outlook.com: domain of nokia.com designates 131.228.2.241 as permitted sender) receiver=protection.outlook.com; client-ip=131.228.2.241; helo=mailrelay.int.nokia.com; Received: from mailrelay.int.nokia.com (131.228.2.241) by AM1FFO11FD001.mail.protection.outlook.com (10.174.64.83) with Microsoft SMTP Server (TLS) id 15.1.511.7 via Frontend Transport; Thu, 16 Jun 2016 13:08:35 +0000 Received: from fihe3nok0735.emea.nsn-net.net (localhost [127.0.0.1]) by fihe3nok0735.emea.nsn-net.net (8.14.9/8.14.5) with ESMTP id u5GD7VRb028915 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 16 Jun 2016 16:07:31 +0300 Received: from 10.144.19.15 ([10.144.104.92]) by fihe3nok0735.emea.nsn-net.net (8.14.9/8.14.5) with ESMTP id u5GD7Vhd028909 (version=TLSv1/SSLv3 cipher=AES128-SHA256 bits=128 verify=NOT) for ; Thu, 16 Jun 2016 16:07:31 +0300 X-HPESVCS-Source-Ip: 10.144.104.92 From: Matias Elo To: Date: Thu, 16 Jun 2016 16:07:29 +0300 Message-ID: <1466082451-11314-1-git-send-email-matias.elo@nokia.com> X-Mailer: git-send-email 1.9.1 X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:131.228.2.241; IPV:NLI; CTRY:FI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(7916002)(2980300002)(438002)(189002)(199003)(2906002)(450100001)(68736007)(11100500001)(19580395003)(8936002)(5003940100001)(50226002)(19580405001)(36756003)(77096005)(50466002)(48376002)(81156014)(47776003)(5890100001)(229853001)(2351001)(81166006)(189998001)(586003)(8676002)(106466001)(16796002)(107886002)(97736004)(33646002)(92566002)(110136002)(575784001)(6806005)(50986999)(87936001)(22756006)(5008740100001)(356003)(42882005); DIR:OUT; SFP:1102; SCL:1; SRVR:VI1PR07MB1069; H:mailrelay.int.nokia.com; FPR:; SPF:Pass; PTR:InfoDomainNonexistent; MX:1; A:1; CAT:NONE; LANG:en; CAT:NONE; X-Microsoft-Exchange-Diagnostics: 1; AM1FFO11FD001; 1:hOwPCFCbPij+3Pm7woyma+ahNe+ziQ8ut9QY0HXseJkfkXcnLIsAEF4UL5d/Gdz2I2rnNFGfCPGatYbDt6vHOkHiE4T40mxhpYu7vXE6piBLFbt9l8PCuatDi+tgXSTkkAkHFt3sVMB+95wZVph1nKw+iZ2clJIf/69jObUQtZMdMTjDaRl1UvcsU412paWGC4BEecEjV/sghsCBGOUUbPlq2fTTSQF6H5crpvJKnfktWApmI10xmR+80BDeMOH+8UgEY7o3HFK3bZIUS2jxEp1KTUzjCfA7dmgMdIYReQC9mW4Jn/8KLngWYTAvKO7gw9fMF3dX3e5RZW2xYwzgj/CV28xt39YbVRRCSCRA6WqhcaPu7ZgDApOXyzuMYtT8m1V5EYWYu2wDAzd8mX85aj/0fIGQ5wY1i6WXLxPT/cE= MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: ef6e7f6e-27e2-4986-5d6c-08d395e752fc X-Microsoft-Exchange-Diagnostics: 1; VI1PR07MB1069; 2:BnZSFkGhoRhyzdUDTdg3aB0Ue3REzc0GcTmxHNLqYCT3v5ynkk7RXYpjNdt3UCboT0q7VHbyOxlyq5Uq7OXkA/+08wjPF33tmYqZts4KgpCiemc4XfwDkUghz8mIwOr1i3amhiM83KQ9zLHZM6Ss7ufgDX2iZqwexWmSOmKSWs2FthgMGc/6hnpyzfJApw7P; 3:aTEt10MX79kG8Ll6/xmapyOaPvznhM78exUTsXAWjym5hDy1T2D8MHYs6DaVdZr8W7J+6/Rq+25e6jmO5twviREzgMO12zL3LyogVwcjN0UQC3K80NGuiejfDS8zRJGJprTvpDoYHQs9PdvbvGqZc8S5Qb0AM7PfbdIn4Ol6EKmDlPAJEMO7VyKl51kX2FCeT2Eubc2b6Lc+q0MpfLpvlmMjm4AMP+O29NyQf9Ipnz1tFQ67wIQPSwye+4b/5hJbr1aK837Hz6xY7bCrwmiUjQ==; 25:LwTErW2aNijXghBj40nCyeBiqWePpi1RWqmAV4WGOgLpqJlRuITRD9RrAOaCkEiSqUQo3hjPLDWNprIltn2PbJ/5+hBvG044R5t8UQ5uosW4hDcSR9oY7YCl0/vn0KvmLQi58iDY3fw+RGY7wiJurDBjbzvV5qIgi8jygVbI+f6+eklrbzRMKLAML4M7MENkRh4hZx/mFPYCd+6vw36uIkeOqocXzpJ6pcVuB6dIugpid83HYW/fLKJe67y6OhzH8p6bwrwdRS5JPOv47pi8TgEaDm9DkX85WStElt55gEANEtBS7sLWzcMsqwppi7oSfQbUU0uwfgw6h4VbM7W3fjfKKZv1q1ECqTiCSyKGXT1su6BnvMokZ4wty56TYRBcDzKJNS8ABxsAJWPpjoh85O6xTb9Yb6wLRKlXfo4YBx0= X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(8251501002); SRVR:VI1PR07MB1069; X-Microsoft-Exchange-Diagnostics: 1; VI1PR07MB1069; 20:HGY+fjwd+izqMMZFjCbFmrPIxUnakwAJyladMkjeROhpZosyZVa6rqRpgVbAKBX7ahvv+YkGiNmFHrmplLceiLLbqKFIDlMUmuwEvzT6lkr/HQPdoSzzMq1apuE3nP3ykWJVGgFgjN5sAqa5WrAfEHqp0yd8gcyVueSOHmSdMXLYyzo2JmKtIScXFL5Wf9E8+hVFdDnIDGAH3lwpd/QAlxx9LSZOTGTJNloGnHqYcgQA44TGZ6SiZlpLWr2W3ZRC3bTcyFkmJlbIfukqwKG2OqexrBck2hIG1MqeIVUS+duGwKh/QUeHMNpb7YpVNiizFaoqW232bBf6aP3Iy3bCLRppJ1J1iLVtmzs6D3sc4/r67x9S5VTyiAy3xT/56Q8RwZf8uui9CvAewBmtFAC0PaYcc1Md1VdZhtreg2wMMpPuRIF+rVbEuJMW1noPhSBXQoBIloHIhkNojLwQckPrDWewKElQMujzR1Nvc6PYHbAR/JqvuR2I0Qye7yzqy67CkjFUdCn7kovwk/3q/RFM5tgIPZNzMW0hV8THcozFDysT3T+j3tECXp5wQlefVtu5rMIEvE1o7UOL3aMrGm6c7f2iCqKQ6DykubvCKJuqRk0= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(82608151540597)(17755550239193); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(8121501046)(13018025)(13016025)(10201501046)(3002001); SRVR:VI1PR07MB1069; BCL:0; PCL:0; RULEID:; SRVR:VI1PR07MB1069; X-Microsoft-Exchange-Diagnostics: 1; VI1PR07MB1069; 4:L4hC8/3Xj0MFSsBUOI7Q8DhxEQIh8gGtrvQsQ8YZ6wywF/14zC+DyDpJAxmBDUAj9HlcMpiTHgqY/FKfxvHYxh0AHYc5w/jmEGNHIwAPgcxbrC3NwTME6vdIkEfCvjuLM6BYozzX+x8NJQuodnsbFrgVjWu8Un96qO3RP8nljv2z2Bb9+9g8bUyGn+7jGMkk7PEvT/hxPgHH1DvsCk394z8Fbzl5Ci2Y8cauBrh9wPMU4aUXZK61MtY+MOdl8KF8Bqs7VjqQs8TwdlBcRNDfS7HaUDlF/LsjPzcY+bK+1ieULk2UefWtrhGCUkxrEOdSURaughkHUPNTtorr0Vm1g4XxSC94pLBj4P9K051aGvJZoEq+j2NhdDAWh7tBkMQalr5eanUyxVDl9SQmfVObcaqxXu+ocV9siJPH/FqoFRF/+AQSj3g6IlQfR1KL0qWuMCTauHcBCW0blTdOX+uuBsaSEYpF8kZph8AAl/VTYD4= X-Forefront-PRVS: 09752BC779 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR07MB1069; 23:heoRae99/lRL66Aj9cIO6f+1HLaugz7sK6sO8DTMK?= =?us-ascii?Q?owqAgDv10Y6mc6268aBUYBEHPc3iocziYrTEfZRWobethMAx74eZ1J6UiKFK?= =?us-ascii?Q?nQx8wTZ6P3t35EwNPGIx9Sy28Tx1o8B5dgOhBpYPiOeKIxCWxcuIL4J31L05?= =?us-ascii?Q?noEWWYkjokmh0t2RNbyKFQazENiifnByg8fs44fFgzRNHdGsWbnHiVKPMJAU?= =?us-ascii?Q?fg7Ggjvssvb/gkmC3HDMD6aji+pp8GtH5BkSzqQs4DAIQTYOcUNcy14Gf9Po?= =?us-ascii?Q?nBuQeB9Tq+gP1rh2yI869qW0yalow2/RZsK9zDOawRXrZYK2qf03V9uoMUbP?= =?us-ascii?Q?T4GQ+z5JBS1IwfPUruyatrQPntRtGt8Z9WpGTQ11+kxNeYrOtO/GA/ELzzLR?= =?us-ascii?Q?Xp5j/ndlHh+ZLDYZvjhecoG3GMISnhKorRey9wq0oDY3As3wMNEV8IVMmFhY?= =?us-ascii?Q?LHeWa0y+of6UzLSLKs8N8JpePGrglcjgYpc2yzpS778buY77mB/KtkNjZCz/?= =?us-ascii?Q?sgiHpLDjo4idrYvq7ZBkrfuNa1TcIP8I6zb+aUAQS79FsC3nXv6KfuUF9ldX?= =?us-ascii?Q?mGgfpHkkwA5jQcFJ0eK9yWZ3nZWRoOzn1qbF6bwcL7AIu8YGHKzV/oOj+1ff?= =?us-ascii?Q?qljPpHkz/+CPr9mjEnFXH7iz/rk+GcNIyuSso42UQQtFjmq6hKvBbEa50FU7?= =?us-ascii?Q?qEfc/DaEvP3kdwoZqkO28Z0yDdj78uGuOL/c+MXdVRc8tqtny4SDuKaR4k+1?= =?us-ascii?Q?Vup9JhdBJbXUO/d5adFcaafaClCd1X4j2qQtYzwCEr1tDGQlOQkrrIlGag0u?= =?us-ascii?Q?hKLm92tT4nwGC2OdMNbvxYFjD2xsVIKPc1OH584fZkORAWFSNcgiDjIlpJjk?= =?us-ascii?Q?Zz8L+9bxwpXlEyv3nTCCN/j+I5+sbA8IdLRYT/dJM6RoxrNkBrkdlzAiyQGp?= =?us-ascii?Q?oeLG29/WkZM+9uiKqdYIrWlW7ZIbPPZ3rnb1tud74b3tVeM5BVaCFnPiprx1?= =?us-ascii?Q?FVJ0uLap3Nhv0COfMZy0G+AdiV/WrgqunhxBbUK+DpJdQPHzv1V1P/TM7GmR?= =?us-ascii?Q?pIWABFjy+MpGGGf3P8ollXbTdjDfT+OmdHMmo1+m+j9SaXlIg=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; VI1PR07MB1069; 6:TRTWHzCZV++ulNEsAtVAuTS5Ll8ACvbAVV3H4s189Gqlt/+8gGiR8NKkS9wQJoFXEp6lB2DqH4cTRiqupTfSVkpSUFBY1ilBIXqKs6nTrxDL5JitHnlktByqQ0uM+ZdQ0g337PumgeIB/+vTpG3k4J4+dfaNb123eWnbRV/cuMHXspbMrKpj33J03p33TieTC2nOhPOJFWVcf9m7i2TkLFNy0mAKKfpEc1KQYxldjKBcRN7j6QzghsvaJXjHRPksvkO1e3K3bBu8IgGJsxUyhwRekXgQjY3rc8vuh8VX8Mc=; 5:Efcn4Emf8DAhrzycFfLHrTs46rqfRUWaRU+J2JbVNidgaC0oCU7nP3McYjOyTShAVuDiBKqwWOkwenrwycw2YW7LtLEfNGTstOibQNv7xRXNXtWAhnlnk/0wmU8KG00pw09bsKom/TkRuok4ITdj3Q==; 24:UaMFhol/wO5gB4Z0IZRoreqmgtdRvSdiTdNTfFBwMowrTvCkPMhgw5ifbvouiMnSUq72EkzeDxiUtMii7mP5zJQtI0kCEUvPWzJJQJx0Zg4=; 7:elbF6/OWSDDtwZ4bcx6yM9Rs8auKtsotDeJppRq+8ZcuMYxUSZ/HGOyBt4KLbV/35GVFg8eqvA1uCElw+PgJZLUTZVP5fuDM+FpkcBn7Xb69DpuSRZbUexbYeUuyQ72x99j4f2Fd98dOWtsKaaNPwiNjJyiji02+FYAOePl0+aVEAOVIu5VlvMpYYb6fWARZP6vWg/zpv0i7FbDzbLdorA== SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: nokia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jun 2016 13:08:35.0066 (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.241]; Helo=[mailrelay.int.nokia.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR07MB1069 X-Topics: patch Subject: [lng-odp] [PATCH v3 1/3] linux-gen: packet: add packet parser structure 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" Collect odp_packet_hdr_t members set by the packet parser inside a common structure packet_parser_t. Signed-off-by: Matias Elo Reviewed-and-tested-by: Bill Fischofer --- .../include/odp_classification_inlines.h | 36 ++-- .../linux-generic/include/odp_packet_internal.h | 58 ++++--- platform/linux-generic/odp_classification.c | 16 +- platform/linux-generic/odp_packet.c | 183 +++++++++++---------- platform/linux-generic/odp_packet_flags.c | 53 +++--- platform/linux-generic/odp_packet_io.c | 2 +- platform/linux-generic/pktio/dpdk.c | 2 +- platform/linux-generic/pktio/ipc.c | 2 +- platform/linux-generic/pktio/loop.c | 2 +- platform/linux-generic/pktio/netmap.c | 2 +- platform/linux-generic/pktio/socket.c | 2 +- platform/linux-generic/pktio/socket_mmap.c | 2 +- 12 files changed, 183 insertions(+), 177 deletions(-) diff --git a/platform/linux-generic/include/odp_classification_inlines.h b/platform/linux-generic/include/odp_classification_inlines.h index 08300f5..611d706 100644 --- a/platform/linux-generic/include/odp_classification_inlines.h +++ b/platform/linux-generic/include/odp_classification_inlines.h @@ -47,9 +47,9 @@ static inline int verify_pmr_ip_proto(const uint8_t *pkt_addr, { const odph_ipv4hdr_t *ip; uint8_t proto; - if (!pkt_hdr->input_flags.ipv4) + if (!pkt_hdr->p.input_flags.ipv4) return 0; - ip = (const odph_ipv4hdr_t *)(pkt_addr + pkt_hdr->l3_offset); + ip = (const odph_ipv4hdr_t *)(pkt_addr + pkt_hdr->p.l3_offset); proto = ip->proto; if (term_value->match.value == (proto & term_value->match.mask)) return 1; @@ -63,9 +63,9 @@ static inline int verify_pmr_ipv4_saddr(const uint8_t *pkt_addr, { const odph_ipv4hdr_t *ip; uint32_t ipaddr; - if (!pkt_hdr->input_flags.ipv4) + if (!pkt_hdr->p.input_flags.ipv4) return 0; - ip = (const odph_ipv4hdr_t *)(pkt_addr + pkt_hdr->l3_offset); + ip = (const odph_ipv4hdr_t *)(pkt_addr + pkt_hdr->p.l3_offset); ipaddr = odp_be_to_cpu_32(ip->src_addr); if (term_value->match.value == (ipaddr & term_value->match.mask)) return 1; @@ -79,9 +79,9 @@ static inline int verify_pmr_ipv4_daddr(const uint8_t *pkt_addr, { const odph_ipv4hdr_t *ip; uint32_t ipaddr; - if (!pkt_hdr->input_flags.ipv4) + if (!pkt_hdr->p.input_flags.ipv4) return 0; - ip = (const odph_ipv4hdr_t *)(pkt_addr + pkt_hdr->l3_offset); + ip = (const odph_ipv4hdr_t *)(pkt_addr + pkt_hdr->p.l3_offset); ipaddr = odp_be_to_cpu_32(ip->dst_addr); if (term_value->match.value == (ipaddr & term_value->match.mask)) return 1; @@ -95,9 +95,9 @@ static inline int verify_pmr_tcp_sport(const uint8_t *pkt_addr, { uint16_t sport; const odph_tcphdr_t *tcp; - if (!pkt_hdr->input_flags.tcp) + if (!pkt_hdr->p.input_flags.tcp) return 0; - tcp = (const odph_tcphdr_t *)(pkt_addr + pkt_hdr->l4_offset); + tcp = (const odph_tcphdr_t *)(pkt_addr + pkt_hdr->p.l4_offset); sport = odp_be_to_cpu_16(tcp->src_port); if (term_value->match.value == (sport & term_value->match.mask)) return 1; @@ -111,9 +111,9 @@ static inline int verify_pmr_tcp_dport(const uint8_t *pkt_addr, { uint16_t dport; const odph_tcphdr_t *tcp; - if (!pkt_hdr->input_flags.tcp) + if (!pkt_hdr->p.input_flags.tcp) return 0; - tcp = (const odph_tcphdr_t *)(pkt_addr + pkt_hdr->l4_offset); + tcp = (const odph_tcphdr_t *)(pkt_addr + pkt_hdr->p.l4_offset); dport = odp_be_to_cpu_16(tcp->dst_port); if (term_value->match.value == (dport & term_value->match.mask)) return 1; @@ -127,9 +127,9 @@ static inline int verify_pmr_udp_dport(const uint8_t *pkt_addr, { uint16_t dport; const odph_udphdr_t *udp; - if (!pkt_hdr->input_flags.udp) + if (!pkt_hdr->p.input_flags.udp) return 0; - udp = (const odph_udphdr_t *)(pkt_addr + pkt_hdr->l4_offset); + udp = (const odph_udphdr_t *)(pkt_addr + pkt_hdr->p.l4_offset); dport = odp_be_to_cpu_16(udp->dst_port); if (term_value->match.value == (dport & term_value->match.mask)) return 1; @@ -144,9 +144,9 @@ static inline int verify_pmr_udp_sport(const uint8_t *pkt_addr, uint16_t sport; const odph_udphdr_t *udp; - if (!pkt_hdr->input_flags.udp) + if (!pkt_hdr->p.input_flags.udp) return 0; - udp = (const odph_udphdr_t *)(pkt_addr + pkt_hdr->l4_offset); + udp = (const odph_udphdr_t *)(pkt_addr + pkt_hdr->p.l4_offset); sport = odp_be_to_cpu_16(udp->src_port); if (term_value->match.value == (sport & term_value->match.mask)) return 1; @@ -165,7 +165,7 @@ static inline int verify_pmr_dmac(const uint8_t *pkt_addr, if (!packet_hdr_has_eth(pkt_hdr)) return 0; - eth = (const odph_ethhdr_t *)(pkt_addr + pkt_hdr->l2_offset); + eth = (const odph_ethhdr_t *)(pkt_addr + pkt_hdr->p.l2_offset); memcpy(&dmac_be, eth->dst.addr, ODPH_ETHADDR_LEN); dmac = odp_be_to_cpu_64(dmac_be); /* since we are converting a 48 bit ethernet address from BE to cpu @@ -217,13 +217,13 @@ static inline int verify_pmr_ipsec_spi(const uint8_t *pkt_addr, { uint32_t spi; - pkt_addr += pkt_hdr->l4_offset; + pkt_addr += pkt_hdr->p.l4_offset; - if (pkt_hdr->input_flags.ipsec_ah) { + if (pkt_hdr->p.input_flags.ipsec_ah) { const odph_ahhdr_t *ahhdr = (const odph_ahhdr_t *)pkt_addr; spi = odp_be_to_cpu_32(ahhdr->spi); - } else if (pkt_hdr->input_flags.ipsec_esp) { + } else if (pkt_hdr->p.input_flags.ipsec_esp) { const odph_esphdr_t *esphdr = (const odph_esphdr_t *)pkt_addr; spi = odp_be_to_cpu_32(esphdr->spi); diff --git a/platform/linux-generic/include/odp_packet_internal.h b/platform/linux-generic/include/odp_packet_internal.h index a84a6f8..71a2ab1 100644 --- a/platform/linux-generic/include/odp_packet_internal.h +++ b/platform/linux-generic/include/odp_packet_internal.h @@ -128,6 +128,23 @@ ODP_STATIC_ASSERT(sizeof(output_flags_t) == sizeof(uint32_t), "OUTPUT_FLAGS_SIZE_ERROR"); /** + * Packet parser metadata + */ +typedef struct { + input_flags_t input_flags; + error_flags_t error_flags; + output_flags_t output_flags; + + uint32_t l2_offset; /**< offset to L2 hdr, e.g. Eth */ + uint32_t l3_offset; /**< offset to L3 hdr, e.g. IPv4, IPv6 */ + uint32_t l4_offset; /**< offset to L4 hdr (TCP, UDP, SCTP, also ICMP) */ + + uint32_t l3_len; /**< Layer 3 length */ + uint32_t l4_len; /**< Layer 4 length */ + +} packet_parser_t; + +/** * Internal Packet header * * To optimize fast path performance this struct is not initialized to zero in @@ -139,13 +156,7 @@ typedef struct { odp_buffer_hdr_t buf_hdr; /* Following members are initialized by packet_init() */ - input_flags_t input_flags; - error_flags_t error_flags; - output_flags_t output_flags; - - uint32_t l2_offset; /**< offset to L2 hdr, e.g. Eth */ - uint32_t l3_offset; /**< offset to L3 hdr, e.g. IPv4, IPv6 */ - uint32_t l4_offset; /**< offset to L4 hdr (TCP, UDP, SCTP, also ICMP) */ + packet_parser_t p; uint32_t frame_len; uint32_t headroom; @@ -154,9 +165,6 @@ typedef struct { odp_pktio_t input; /* Members below are not initialized by packet_init() */ - uint32_t l3_len; /**< Layer 3 length */ - uint32_t l4_len; /**< Layer 4 length */ - odp_queue_t dst_queue; /**< Classifier destination queue */ uint32_t flow_hash; /**< Flow hash value */ @@ -180,18 +188,14 @@ static inline odp_packet_hdr_t *odp_packet_hdr(odp_packet_t pkt) static inline void copy_packet_parser_metadata(odp_packet_hdr_t *src_hdr, odp_packet_hdr_t *dst_hdr) { - dst_hdr->input_flags = src_hdr->input_flags; - dst_hdr->error_flags = src_hdr->error_flags; - dst_hdr->output_flags = src_hdr->output_flags; + dst_hdr->p = src_hdr->p; +} - dst_hdr->l2_offset = src_hdr->l2_offset; - dst_hdr->l3_offset = src_hdr->l3_offset; - dst_hdr->l4_offset = src_hdr->l4_offset; - - dst_hdr->l3_len = src_hdr->l3_len; - dst_hdr->l4_len = src_hdr->l4_len; - - dst_hdr->dst_queue = src_hdr->dst_queue; +static inline void copy_packet_cls_metadata(odp_packet_hdr_t *src_hdr, + odp_packet_hdr_t *dst_hdr) +{ + dst_hdr->p = src_hdr->p; + dst_hdr->dst_queue = src_hdr->dst_queue; } static inline void *packet_map(odp_packet_hdr_t *pkt_hdr, @@ -285,12 +289,12 @@ static inline void packet_set_len(odp_packet_hdr_t *pkt_hdr, uint32_t len) static inline int packet_parse_l2_not_done(odp_packet_hdr_t *pkt_hdr) { - return !pkt_hdr->input_flags.parsed_l2; + return !pkt_hdr->p.input_flags.parsed_l2; } static inline int packet_parse_not_complete(odp_packet_hdr_t *pkt_hdr) { - return !pkt_hdr->input_flags.parsed_all; + return !pkt_hdr->p.input_flags.parsed_all; } /* Forward declarations */ @@ -315,24 +319,24 @@ odp_packet_t _odp_packet_from_buffer(odp_buffer_t buf); static inline int packet_hdr_has_l2(odp_packet_hdr_t *pkt_hdr) { - return pkt_hdr->input_flags.l2; + return pkt_hdr->p.input_flags.l2; } static inline void packet_hdr_has_l2_set(odp_packet_hdr_t *pkt_hdr, int val) { - pkt_hdr->input_flags.l2 = val; + pkt_hdr->p.input_flags.l2 = val; } static inline int packet_hdr_has_eth(odp_packet_hdr_t *pkt_hdr) { - return pkt_hdr->input_flags.eth; + return pkt_hdr->p.input_flags.eth; } static inline void packet_set_ts(odp_packet_hdr_t *pkt_hdr, odp_time_t *ts) { if (ts != NULL) { pkt_hdr->timestamp = *ts; - pkt_hdr->input_flags.timestamp = 1; + pkt_hdr->p.input_flags.timestamp = 1; } } diff --git a/platform/linux-generic/odp_classification.c b/platform/linux-generic/odp_classification.c index d2cc081..752348c 100644 --- a/platform/linux-generic/odp_classification.c +++ b/platform/linux-generic/odp_classification.c @@ -776,7 +776,7 @@ static inline cos_t *cls_select_cos(pktio_entry_t *entry, packet_parse_full(pkt_hdr); /* Return error cos for error packet */ - if (pkt_hdr->error_flags.all) + if (pkt_hdr->p.error_flags.all) return cls->error_cos; /* Calls all the PMRs attached at the PKTIO level*/ for (i = 0; i < odp_atomic_load_u32(&default_cos->s.num_rule); i++) { @@ -827,7 +827,7 @@ int cls_classify_packet(pktio_entry_t *entry, const uint8_t *base, uint16_t len, return -EFAULT; *pool = cos->s.pool->s.pool_hdl; - pkt_hdr->input_flags.dst_queue = 1; + pkt_hdr->p.input_flags.dst_queue = 1; pkt_hdr->dst_queue = cos->s.queue->s.handle; return 0; @@ -841,12 +841,12 @@ cos_t *match_qos_l3_cos(pmr_l3_cos_t *l3_cos, const uint8_t *pkt_addr, const odph_ipv4hdr_t *ipv4; const odph_ipv6hdr_t *ipv6; - if (hdr->input_flags.l3 && hdr->input_flags.ipv4) { - ipv4 = (const odph_ipv4hdr_t *)(pkt_addr + hdr->l3_offset); + if (hdr->p.input_flags.l3 && hdr->p.input_flags.ipv4) { + ipv4 = (const odph_ipv4hdr_t *)(pkt_addr + hdr->p.l3_offset); dscp = ODPH_IPV4HDR_DSCP(ipv4->tos); cos = l3_cos->cos[dscp]; - } else if (hdr->input_flags.l3 && hdr->input_flags.ipv6) { - ipv6 = (const odph_ipv6hdr_t *)(pkt_addr + hdr->l3_offset); + } else if (hdr->p.input_flags.l3 && hdr->p.input_flags.ipv6) { + ipv6 = (const odph_ipv6hdr_t *)(pkt_addr + hdr->p.l3_offset); dscp = ODPH_IPV6HDR_DSCP(ipv6->ver_tc_flow); cos = l3_cos->cos[dscp]; } @@ -862,9 +862,9 @@ cos_t *match_qos_l2_cos(pmr_l2_cos_t *l2_cos, const uint8_t *pkt_addr, const odph_vlanhdr_t *vlan; uint16_t qos; - if (packet_hdr_has_l2(hdr) && hdr->input_flags.vlan && + if (packet_hdr_has_l2(hdr) && hdr->p.input_flags.vlan && packet_hdr_has_eth(hdr)) { - eth = (const odph_ethhdr_t *)(pkt_addr + hdr->l2_offset); + eth = (const odph_ethhdr_t *)(pkt_addr + hdr->p.l2_offset); vlan = (const odph_vlanhdr_t *)(eth + 1); qos = odp_be_to_cpu_16(vlan->tci); qos = ((qos >> 13) & 0x07); diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c index 2868736..991a648 100644 --- a/platform/linux-generic/odp_packet.c +++ b/platform/linux-generic/odp_packet.c @@ -28,19 +28,19 @@ static inline void packet_parse_disable(odp_packet_hdr_t *pkt_hdr) { - pkt_hdr->input_flags.parsed_l2 = 1; - pkt_hdr->input_flags.parsed_all = 1; + pkt_hdr->p.input_flags.parsed_l2 = 1; + pkt_hdr->p.input_flags.parsed_all = 1; } void packet_parse_reset(odp_packet_hdr_t *pkt_hdr) { /* Reset parser metadata before new parse */ - pkt_hdr->error_flags.all = 0; - pkt_hdr->input_flags.all = 0; - pkt_hdr->output_flags.all = 0; - pkt_hdr->l2_offset = 0; - pkt_hdr->l3_offset = ODP_PACKET_OFFSET_INVALID; - pkt_hdr->l4_offset = ODP_PACKET_OFFSET_INVALID; + pkt_hdr->p.error_flags.all = 0; + pkt_hdr->p.input_flags.all = 0; + pkt_hdr->p.output_flags.all = 0; + pkt_hdr->p.l2_offset = 0; + pkt_hdr->p.l3_offset = ODP_PACKET_OFFSET_INVALID; + pkt_hdr->p.l4_offset = ODP_PACKET_OFFSET_INVALID; } /** @@ -49,13 +49,13 @@ void packet_parse_reset(odp_packet_hdr_t *pkt_hdr) static void packet_init(pool_entry_t *pool, odp_packet_hdr_t *pkt_hdr, size_t size, int parse) { - pkt_hdr->input_flags.all = 0; - pkt_hdr->output_flags.all = 0; - pkt_hdr->error_flags.all = 0; + pkt_hdr->p.input_flags.all = 0; + pkt_hdr->p.output_flags.all = 0; + pkt_hdr->p.error_flags.all = 0; - pkt_hdr->l2_offset = 0; - pkt_hdr->l3_offset = ODP_PACKET_OFFSET_INVALID; - pkt_hdr->l4_offset = ODP_PACKET_OFFSET_INVALID; + pkt_hdr->p.l2_offset = 0; + pkt_hdr->p.l3_offset = ODP_PACKET_OFFSET_INVALID; + pkt_hdr->p.l4_offset = ODP_PACKET_OFFSET_INVALID; /* Disable lazy parsing on user allocated packets */ if (!parse) @@ -431,7 +431,7 @@ void *odp_packet_l2_ptr(odp_packet_t pkt, uint32_t *len) if (!packet_hdr_has_l2(pkt_hdr)) return NULL; - return packet_map(pkt_hdr, pkt_hdr->l2_offset, len); + return packet_map(pkt_hdr, pkt_hdr->p.l2_offset, len); } uint32_t odp_packet_l2_offset(odp_packet_t pkt) @@ -440,7 +440,7 @@ uint32_t odp_packet_l2_offset(odp_packet_t pkt) if (!packet_hdr_has_l2(pkt_hdr)) return ODP_PACKET_OFFSET_INVALID; - return pkt_hdr->l2_offset; + return pkt_hdr->p.l2_offset; } int odp_packet_l2_offset_set(odp_packet_t pkt, uint32_t offset) @@ -451,7 +451,7 @@ int odp_packet_l2_offset_set(odp_packet_t pkt, uint32_t offset) return -1; packet_hdr_has_l2_set(pkt_hdr, 1); - pkt_hdr->l2_offset = offset; + pkt_hdr->p.l2_offset = offset; return 0; } @@ -461,7 +461,7 @@ void *odp_packet_l3_ptr(odp_packet_t pkt, uint32_t *len) if (packet_parse_not_complete(pkt_hdr)) packet_parse_full(pkt_hdr); - return packet_map(pkt_hdr, pkt_hdr->l3_offset, len); + return packet_map(pkt_hdr, pkt_hdr->p.l3_offset, len); } uint32_t odp_packet_l3_offset(odp_packet_t pkt) @@ -470,7 +470,7 @@ uint32_t odp_packet_l3_offset(odp_packet_t pkt) if (packet_parse_not_complete(pkt_hdr)) packet_parse_full(pkt_hdr); - return pkt_hdr->l3_offset; + return pkt_hdr->p.l3_offset; } int odp_packet_l3_offset_set(odp_packet_t pkt, uint32_t offset) @@ -482,7 +482,7 @@ int odp_packet_l3_offset_set(odp_packet_t pkt, uint32_t offset) if (packet_parse_not_complete(pkt_hdr)) packet_parse_full(pkt_hdr); - pkt_hdr->l3_offset = offset; + pkt_hdr->p.l3_offset = offset; return 0; } @@ -492,7 +492,7 @@ void *odp_packet_l4_ptr(odp_packet_t pkt, uint32_t *len) if (packet_parse_not_complete(pkt_hdr)) packet_parse_full(pkt_hdr); - return packet_map(pkt_hdr, pkt_hdr->l4_offset, len); + return packet_map(pkt_hdr, pkt_hdr->p.l4_offset, len); } uint32_t odp_packet_l4_offset(odp_packet_t pkt) @@ -501,7 +501,7 @@ uint32_t odp_packet_l4_offset(odp_packet_t pkt) if (packet_parse_not_complete(pkt_hdr)) packet_parse_full(pkt_hdr); - return pkt_hdr->l4_offset; + return pkt_hdr->p.l4_offset; } int odp_packet_l4_offset_set(odp_packet_t pkt, uint32_t offset) @@ -513,7 +513,7 @@ int odp_packet_l4_offset_set(odp_packet_t pkt, uint32_t offset) if (packet_parse_not_complete(pkt_hdr)) packet_parse_full(pkt_hdr); - pkt_hdr->l4_offset = offset; + pkt_hdr->p.l4_offset = offset; return 0; } @@ -529,7 +529,7 @@ void odp_packet_flow_hash_set(odp_packet_t pkt, uint32_t flow_hash) odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); pkt_hdr->flow_hash = flow_hash; - pkt_hdr->input_flags.flow_hash = 1; + pkt_hdr->p.input_flags.flow_hash = 1; } odp_time_t odp_packet_ts(odp_packet_t pkt) @@ -544,7 +544,7 @@ void odp_packet_ts_set(odp_packet_t pkt, odp_time_t timestamp) odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); pkt_hdr->timestamp = timestamp; - pkt_hdr->input_flags.timestamp = 1; + pkt_hdr->p.input_flags.timestamp = 1; } int odp_packet_is_segmented(odp_packet_t pkt) @@ -929,19 +929,19 @@ void odp_packet_print(odp_packet_t pkt) len += snprintf(&str[len], n - len, "Packet "); len += odp_buffer_snprint(&str[len], n - len, (odp_buffer_t)pkt); - len += snprintf(&str[len], n - len, - " input_flags 0x%" PRIx64 "\n", hdr->input_flags.all); - len += snprintf(&str[len], n - len, - " error_flags 0x%" PRIx32 "\n", hdr->error_flags.all); + len += snprintf(&str[len], n - len, " input_flags 0x%" PRIx64 "\n", + hdr->p.input_flags.all); + len += snprintf(&str[len], n - len, " error_flags 0x%" PRIx32 "\n", + hdr->p.error_flags.all); len += snprintf(&str[len], n - len, " output_flags 0x%" PRIx32 "\n", - hdr->output_flags.all); + hdr->p.output_flags.all); len += snprintf(&str[len], n - len, - " l2_offset %" PRIu32 "\n", hdr->l2_offset); + " l2_offset %" PRIu32 "\n", hdr->p.l2_offset); len += snprintf(&str[len], n - len, - " l3_offset %" PRIu32 "\n", hdr->l3_offset); + " l3_offset %" PRIu32 "\n", hdr->p.l3_offset); len += snprintf(&str[len], n - len, - " l4_offset %" PRIu32 "\n", hdr->l4_offset); + " l4_offset %" PRIu32 "\n", hdr->p.l4_offset); len += snprintf(&str[len], n - len, " frame_len %" PRIu32 "\n", hdr->frame_len); len += snprintf(&str[len], n - len, @@ -972,6 +972,7 @@ void _odp_packet_copy_md_to_packet(odp_packet_t srcpkt, odp_packet_t dstpkt) odp_packet_hdr_t *dsthdr = odp_packet_hdr(dstpkt); dsthdr->input = srchdr->input; + dsthdr->dst_queue = srchdr->dst_queue; dsthdr->buf_hdr.buf_u64 = srchdr->buf_hdr.buf_u64; if (dsthdr->buf_hdr.uarea_addr != NULL && srchdr->buf_hdr.uarea_addr != NULL) @@ -1000,12 +1001,12 @@ static inline uint8_t parse_ipv4(odp_packet_hdr_t *pkt_hdr, uint16_t frag_offset; uint32_t dstaddr = odp_be_to_cpu_32(ipv4->dst_addr); - pkt_hdr->l3_len = odp_be_to_cpu_16(ipv4->tot_len); + pkt_hdr->p.l3_len = odp_be_to_cpu_16(ipv4->tot_len); if (odp_unlikely(ihl < ODPH_IPV4HDR_IHL_MIN) || odp_unlikely(ver != 4) || - (pkt_hdr->l3_len > pkt_hdr->frame_len - *offset)) { - pkt_hdr->error_flags.ip_err = 1; + (pkt_hdr->p.l3_len > pkt_hdr->frame_len - *offset)) { + pkt_hdr->p.error_flags.ip_err = 1; return 0; } @@ -1013,7 +1014,7 @@ static inline uint8_t parse_ipv4(odp_packet_hdr_t *pkt_hdr, *parseptr += ihl * 4; if (odp_unlikely(ihl > ODPH_IPV4HDR_IHL_MIN)) - pkt_hdr->input_flags.ipopt = 1; + pkt_hdr->p.input_flags.ipopt = 1; /* A packet is a fragment if: * "more fragments" flag is set (all fragments except the last) @@ -1022,11 +1023,11 @@ static inline uint8_t parse_ipv4(odp_packet_hdr_t *pkt_hdr, */ frag_offset = odp_be_to_cpu_16(ipv4->frag_offset); if (odp_unlikely(ODPH_IPV4HDR_IS_FRAGMENT(frag_offset))) - pkt_hdr->input_flags.ipfrag = 1; + pkt_hdr->p.input_flags.ipfrag = 1; /* Handle IPv4 broadcast / multicast */ - pkt_hdr->input_flags.ip_bcast = (dstaddr == 0xffffffff); - pkt_hdr->input_flags.ip_mcast = (dstaddr >> 28) == 0xd; + pkt_hdr->p.input_flags.ip_bcast = (dstaddr == 0xffffffff); + pkt_hdr->p.input_flags.ip_mcast = (dstaddr >> 28) == 0xd; return ipv4->proto; } @@ -1041,19 +1042,19 @@ static inline uint8_t parse_ipv6(odp_packet_hdr_t *pkt_hdr, const odph_ipv6hdr_ext_t *ipv6ext; uint32_t dstaddr0 = odp_be_to_cpu_32(ipv6->dst_addr[0]); - pkt_hdr->l3_len = odp_be_to_cpu_16(ipv6->payload_len) + + pkt_hdr->p.l3_len = odp_be_to_cpu_16(ipv6->payload_len) + ODPH_IPV6HDR_LEN; /* Basic sanity checks on IPv6 header */ if ((odp_be_to_cpu_32(ipv6->ver_tc_flow) >> 28) != 6 || - pkt_hdr->l3_len > pkt_hdr->frame_len - *offset) { - pkt_hdr->error_flags.ip_err = 1; + pkt_hdr->p.l3_len > pkt_hdr->frame_len - *offset) { + pkt_hdr->p.error_flags.ip_err = 1; return 0; } /* IPv6 broadcast / multicast flags */ - pkt_hdr->input_flags.ip_mcast = (dstaddr0 & 0xff000000) == 0xff000000; - pkt_hdr->input_flags.ip_bcast = 0; + pkt_hdr->p.input_flags.ip_mcast = (dstaddr0 & 0xff000000) == 0xff000000; + pkt_hdr->p.input_flags.ip_bcast = 0; /* Skip past IPv6 header */ *offset += sizeof(odph_ipv6hdr_t); @@ -1062,7 +1063,7 @@ static inline uint8_t parse_ipv6(odp_packet_hdr_t *pkt_hdr, /* Skip past any IPv6 extension headers */ if (ipv6->next_hdr == ODPH_IPPROTO_HOPOPTS || ipv6->next_hdr == ODPH_IPPROTO_ROUTE) { - pkt_hdr->input_flags.ipopt = 1; + pkt_hdr->p.input_flags.ipopt = 1; do { ipv6ext = (const odph_ipv6hdr_ext_t *)*parseptr; @@ -1074,21 +1075,21 @@ static inline uint8_t parse_ipv6(odp_packet_hdr_t *pkt_hdr, ipv6ext->next_hdr == ODPH_IPPROTO_ROUTE) && *offset < pkt_hdr->frame_len); - if (*offset >= pkt_hdr->l3_offset + + if (*offset >= pkt_hdr->p.l3_offset + odp_be_to_cpu_16(ipv6->payload_len)) { - pkt_hdr->error_flags.ip_err = 1; + pkt_hdr->p.error_flags.ip_err = 1; return 0; } if (ipv6ext->next_hdr == ODPH_IPPROTO_FRAG) - pkt_hdr->input_flags.ipfrag = 1; + pkt_hdr->p.input_flags.ipfrag = 1; return ipv6ext->next_hdr; } if (odp_unlikely(ipv6->next_hdr == ODPH_IPPROTO_FRAG)) { - pkt_hdr->input_flags.ipopt = 1; - pkt_hdr->input_flags.ipfrag = 1; + pkt_hdr->p.input_flags.ipopt = 1; + pkt_hdr->p.input_flags.ipfrag = 1; } return ipv6->next_hdr; @@ -1103,12 +1104,12 @@ static inline void parse_tcp(odp_packet_hdr_t *pkt_hdr, const odph_tcphdr_t *tcp = (const odph_tcphdr_t *)*parseptr; if (tcp->hl < sizeof(odph_tcphdr_t) / sizeof(uint32_t)) - pkt_hdr->error_flags.tcp_err = 1; + pkt_hdr->p.error_flags.tcp_err = 1; else if ((uint32_t)tcp->hl * 4 > sizeof(odph_tcphdr_t)) - pkt_hdr->input_flags.tcpopt = 1; + pkt_hdr->p.input_flags.tcpopt = 1; - pkt_hdr->l4_len = pkt_hdr->l3_len + - pkt_hdr->l3_offset - pkt_hdr->l4_offset; + pkt_hdr->p.l4_len = pkt_hdr->p.l3_len + + pkt_hdr->p.l3_offset - pkt_hdr->p.l4_offset; if (offset) *offset += (uint32_t)tcp->hl * 4; @@ -1125,12 +1126,12 @@ static inline void parse_udp(odp_packet_hdr_t *pkt_hdr, uint32_t udplen = odp_be_to_cpu_16(udp->length); if (udplen < sizeof(odph_udphdr_t) || - udplen > (pkt_hdr->l3_len + - pkt_hdr->l4_offset - pkt_hdr->l3_offset)) { - pkt_hdr->error_flags.udp_err = 1; + udplen > (pkt_hdr->p.l3_len + + pkt_hdr->p.l4_offset - pkt_hdr->p.l3_offset)) { + pkt_hdr->p.error_flags.udp_err = 1; } - pkt_hdr->l4_len = udplen; + pkt_hdr->p.l4_len = udplen; if (offset) *offset += sizeof(odph_udphdr_t); @@ -1145,16 +1146,16 @@ void packet_parse_l2(odp_packet_hdr_t *pkt_hdr) /* Packet alloc or reset have already init other offsets and flags */ /* We only support Ethernet for now */ - pkt_hdr->input_flags.eth = 1; + pkt_hdr->p.input_flags.eth = 1; /* Detect jumbo frames */ if (pkt_hdr->frame_len > ODPH_ETH_LEN_MAX) - pkt_hdr->input_flags.jumbo = 1; + pkt_hdr->p.input_flags.jumbo = 1; /* Assume valid L2 header, no CRC/FCS check in SW */ - pkt_hdr->input_flags.l2 = 1; + pkt_hdr->p.input_flags.l2 = 1; - pkt_hdr->input_flags.parsed_l2 = 1; + pkt_hdr->p.input_flags.parsed_l2 = 1; } int _odp_parse_common(odp_packet_hdr_t *pkt_hdr, const uint8_t *ptr) @@ -1176,7 +1177,7 @@ int _odp_parse_common(odp_packet_hdr_t *pkt_hdr, const uint8_t *ptr) /* Handle Ethernet broadcast/multicast addresses */ macaddr0 = odp_be_to_cpu_16(*((const uint16_t *)(const void *)eth)); - pkt_hdr->input_flags.eth_mcast = (macaddr0 & 0x0100) == 0x0100; + pkt_hdr->p.input_flags.eth_mcast = (macaddr0 & 0x0100) == 0x0100; if (macaddr0 == 0xffff) { macaddr2 = @@ -1185,10 +1186,10 @@ int _odp_parse_common(odp_packet_hdr_t *pkt_hdr, const uint8_t *ptr) macaddr4 = odp_be_to_cpu_16(*((const uint16_t *) (const void *)eth + 2)); - pkt_hdr->input_flags.eth_bcast = + pkt_hdr->p.input_flags.eth_bcast = (macaddr2 == 0xffff) && (macaddr4 == 0xffff); } else { - pkt_hdr->input_flags.eth_bcast = 0; + pkt_hdr->p.input_flags.eth_bcast = 0; } /* Get Ethertype */ @@ -1197,9 +1198,9 @@ int _odp_parse_common(odp_packet_hdr_t *pkt_hdr, const uint8_t *ptr) /* Check for SNAP vs. DIX */ if (ethtype < ODPH_ETH_LEN_MAX) { - pkt_hdr->input_flags.snap = 1; + pkt_hdr->p.input_flags.snap = 1; if (ethtype > pkt_hdr->frame_len - offset) { - pkt_hdr->error_flags.snap_len = 1; + pkt_hdr->p.error_flags.snap_len = 1; goto parse_exit; } ethtype = odp_be_to_cpu_16(*((const uint16_t *) @@ -1210,8 +1211,8 @@ int _odp_parse_common(odp_packet_hdr_t *pkt_hdr, const uint8_t *ptr) /* Parse the VLAN header(s), if present */ if (ethtype == ODPH_ETHTYPE_VLAN_OUTER) { - pkt_hdr->input_flags.vlan_qinq = 1; - pkt_hdr->input_flags.vlan = 1; + pkt_hdr->p.input_flags.vlan_qinq = 1; + pkt_hdr->p.input_flags.vlan = 1; vlan = (const odph_vlanhdr_t *)parseptr; ethtype = odp_be_to_cpu_16(vlan->type); @@ -1220,7 +1221,7 @@ int _odp_parse_common(odp_packet_hdr_t *pkt_hdr, const uint8_t *ptr) } if (ethtype == ODPH_ETHTYPE_VLAN) { - pkt_hdr->input_flags.vlan = 1; + pkt_hdr->p.input_flags.vlan = 1; vlan = (const odph_vlanhdr_t *)parseptr; ethtype = odp_be_to_cpu_16(vlan->type); offset += sizeof(odph_vlanhdr_t); @@ -1228,71 +1229,71 @@ int _odp_parse_common(odp_packet_hdr_t *pkt_hdr, const uint8_t *ptr) } /* Set l3_offset+flag only for known ethtypes */ - pkt_hdr->input_flags.l3 = 1; - pkt_hdr->l3_offset = offset; + pkt_hdr->p.input_flags.l3 = 1; + pkt_hdr->p.l3_offset = offset; /* Parse Layer 3 headers */ switch (ethtype) { case ODPH_ETHTYPE_IPV4: - pkt_hdr->input_flags.ipv4 = 1; + pkt_hdr->p.input_flags.ipv4 = 1; ip_proto = parse_ipv4(pkt_hdr, &parseptr, &offset); break; case ODPH_ETHTYPE_IPV6: - pkt_hdr->input_flags.ipv6 = 1; + pkt_hdr->p.input_flags.ipv6 = 1; ip_proto = parse_ipv6(pkt_hdr, &parseptr, &offset); break; case ODPH_ETHTYPE_ARP: - pkt_hdr->input_flags.arp = 1; + pkt_hdr->p.input_flags.arp = 1; ip_proto = 255; /* Reserved invalid by IANA */ break; default: - pkt_hdr->input_flags.l3 = 0; - pkt_hdr->l3_offset = ODP_PACKET_OFFSET_INVALID; + pkt_hdr->p.input_flags.l3 = 0; + pkt_hdr->p.l3_offset = ODP_PACKET_OFFSET_INVALID; ip_proto = 255; /* Reserved invalid by IANA */ } /* Set l4_offset+flag only for known ip_proto */ - pkt_hdr->input_flags.l4 = 1; - pkt_hdr->l4_offset = offset; + pkt_hdr->p.input_flags.l4 = 1; + pkt_hdr->p.l4_offset = offset; /* Parse Layer 4 headers */ switch (ip_proto) { case ODPH_IPPROTO_ICMP: - pkt_hdr->input_flags.icmp = 1; + pkt_hdr->p.input_flags.icmp = 1; break; case ODPH_IPPROTO_TCP: - pkt_hdr->input_flags.tcp = 1; + pkt_hdr->p.input_flags.tcp = 1; parse_tcp(pkt_hdr, &parseptr, NULL); break; case ODPH_IPPROTO_UDP: - pkt_hdr->input_flags.udp = 1; + pkt_hdr->p.input_flags.udp = 1; parse_udp(pkt_hdr, &parseptr, NULL); break; case ODPH_IPPROTO_AH: - pkt_hdr->input_flags.ipsec = 1; - pkt_hdr->input_flags.ipsec_ah = 1; + pkt_hdr->p.input_flags.ipsec = 1; + pkt_hdr->p.input_flags.ipsec_ah = 1; break; case ODPH_IPPROTO_ESP: - pkt_hdr->input_flags.ipsec = 1; - pkt_hdr->input_flags.ipsec_esp = 1; + pkt_hdr->p.input_flags.ipsec = 1; + pkt_hdr->p.input_flags.ipsec_esp = 1; break; default: - pkt_hdr->input_flags.l4 = 0; - pkt_hdr->l4_offset = ODP_PACKET_OFFSET_INVALID; + pkt_hdr->p.input_flags.l4 = 0; + pkt_hdr->p.l4_offset = ODP_PACKET_OFFSET_INVALID; break; } parse_exit: - pkt_hdr->input_flags.parsed_all = 1; - return pkt_hdr->error_flags.all != 0; + pkt_hdr->p.input_flags.parsed_all = 1; + return pkt_hdr->p.error_flags.all != 0; } /** diff --git a/platform/linux-generic/odp_packet_flags.c b/platform/linux-generic/odp_packet_flags.c index 3acdc53..b88324c 100644 --- a/platform/linux-generic/odp_packet_flags.c +++ b/platform/linux-generic/odp_packet_flags.c @@ -7,26 +7,27 @@ #include #include -#define retflag(p, x) do { \ - odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(p); \ - if (packet_parse_not_complete(pkt_hdr)) \ - packet_parse_full(pkt_hdr); \ - return pkt_hdr->x; \ +#define retflag(pkt, x) do { \ + 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->p.x; \ } while (0) -#define setflag(p, x, v) do { \ - odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(p); \ - if (packet_parse_not_complete(pkt_hdr)) \ - packet_parse_full(pkt_hdr); \ - pkt_hdr->x = v & 1; \ +#define setflag(pkt, x, v) do { \ + odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); \ + if (packet_parse_not_complete(pkt_hdr)) \ + packet_parse_full(pkt_hdr); \ + pkt_hdr->p.x = v & 1; \ } while (0) 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); - return odp_packet_hdr(pkt)->error_flags.all != 0; + return odp_packet_hdr(pkt)->p.error_flags.all != 0; } /* Get Input Flags */ @@ -35,7 +36,7 @@ int odp_packet_has_l2(odp_packet_t pkt) { odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); - return pkt_hdr->input_flags.l2; + return pkt_hdr->p.input_flags.l2; } int odp_packet_has_l2_error(odp_packet_t pkt) @@ -43,9 +44,9 @@ 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; + return pkt_hdr->p.error_flags.frame_len + | pkt_hdr->p.error_flags.snap_len + | pkt_hdr->p.error_flags.l2_chksum; } int odp_packet_has_l3(odp_packet_t pkt) @@ -60,7 +61,7 @@ int odp_packet_has_l3_error(odp_packet_t pkt) if (packet_parse_not_complete(pkt_hdr)) packet_parse_full(pkt_hdr); - return pkt_hdr->error_flags.ip_err; + return pkt_hdr->p.error_flags.ip_err; } int odp_packet_has_l4(odp_packet_t pkt) @@ -75,14 +76,14 @@ int odp_packet_has_l4_error(odp_packet_t 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; + return pkt_hdr->p.error_flags.tcp_err | pkt_hdr->p.error_flags.udp_err; } int odp_packet_has_eth(odp_packet_t pkt) { odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); - return pkt_hdr->input_flags.eth; + return pkt_hdr->p.input_flags.eth; } int odp_packet_has_eth_bcast(odp_packet_t pkt) @@ -99,7 +100,7 @@ int odp_packet_has_jumbo(odp_packet_t pkt) { odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); - return pkt_hdr->input_flags.jumbo; + return pkt_hdr->p.input_flags.jumbo; } int odp_packet_has_vlan(odp_packet_t pkt) @@ -176,14 +177,14 @@ int odp_packet_has_flow_hash(odp_packet_t pkt) { odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); - return pkt_hdr->input_flags.flow_hash; + return pkt_hdr->p.input_flags.flow_hash; } int odp_packet_has_ts(odp_packet_t pkt) { odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); - return pkt_hdr->input_flags.timestamp; + return pkt_hdr->p.input_flags.timestamp; } odp_packet_color_t odp_packet_color(odp_packet_t pkt) @@ -198,7 +199,7 @@ void odp_packet_color_set(odp_packet_t pkt, odp_packet_color_t color) if (packet_parse_not_complete(pkt_hdr)) packet_parse_full(pkt_hdr); - pkt_hdr->input_flags.color = color; + pkt_hdr->p.input_flags.color = color; } odp_bool_t odp_packet_drop_eligible(odp_packet_t pkt) @@ -208,7 +209,7 @@ odp_bool_t odp_packet_drop_eligible(odp_packet_t pkt) if (packet_parse_not_complete(pkt_hdr)) packet_parse_full(pkt_hdr); - return !pkt_hdr->input_flags.nodrop; + return !pkt_hdr->p.input_flags.nodrop; } void odp_packet_drop_eligible_set(odp_packet_t pkt, odp_bool_t drop) @@ -228,7 +229,7 @@ void odp_packet_shaper_len_adjust_set(odp_packet_t pkt, int8_t adj) if (packet_parse_not_complete(pkt_hdr)) packet_parse_full(pkt_hdr); - pkt_hdr->output_flags.shaper_len_adj = adj; + pkt_hdr->p.output_flags.shaper_len_adj = adj; } /* Set Input Flags */ @@ -342,12 +343,12 @@ void odp_packet_has_flow_hash_clr(odp_packet_t pkt) { odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); - pkt_hdr->input_flags.flow_hash = 0; + pkt_hdr->p.input_flags.flow_hash = 0; } void odp_packet_has_ts_clr(odp_packet_t pkt) { odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); - pkt_hdr->input_flags.timestamp = 0; + pkt_hdr->p.input_flags.timestamp = 0; } diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c index 8d88aa3..aa754a7 100644 --- a/platform/linux-generic/odp_packet_io.c +++ b/platform/linux-generic/odp_packet_io.c @@ -551,7 +551,7 @@ static inline int pktin_recv_buf(odp_pktin_queue_t queue, buf = _odp_packet_to_buffer(pkt); buf_hdr = odp_buf_to_hdr(buf); - if (pkt_hdr->input_flags.dst_queue) { + if (pkt_hdr->p.input_flags.dst_queue) { queue_entry_t *dst_queue; int ret; diff --git a/platform/linux-generic/pktio/dpdk.c b/platform/linux-generic/pktio/dpdk.c index 2225dfe..e2b3aec 100644 --- a/platform/linux-generic/pktio/dpdk.c +++ b/platform/linux-generic/pktio/dpdk.c @@ -742,7 +742,7 @@ static inline int mbuf_to_pkt(pktio_entry_t *pktio_entry, pkt_hdr->input = pktio_entry->s.handle; if (pktio_cls_enabled(pktio_entry)) - copy_packet_parser_metadata(&parsed_hdr, pkt_hdr); + copy_packet_cls_metadata(&parsed_hdr, pkt_hdr); else packet_parse_l2(pkt_hdr); diff --git a/platform/linux-generic/pktio/ipc.c b/platform/linux-generic/pktio/ipc.c index bd74f11..e0d4ab9 100644 --- a/platform/linux-generic/pktio/ipc.c +++ b/platform/linux-generic/pktio/ipc.c @@ -571,7 +571,7 @@ static int ipc_pktio_recv_lockless(pktio_entry_t *pktio_entry, memcpy(pkt_data, remote_pkt_data, phdr.frame_len); /* Copy packets L2, L3 parsed offsets and size */ - copy_packet_parser_metadata(&phdr, odp_packet_hdr(pkt)); + copy_packet_cls_metadata(&phdr, odp_packet_hdr(pkt)); odp_packet_hdr(pkt)->frame_len = phdr.frame_len; odp_packet_hdr(pkt)->headroom = phdr.headroom; diff --git a/platform/linux-generic/pktio/loop.c b/platform/linux-generic/pktio/loop.c index effad9a..a19c2dd 100644 --- a/platform/linux-generic/pktio/loop.c +++ b/platform/linux-generic/pktio/loop.c @@ -111,7 +111,7 @@ static int loopback_recv(pktio_entry_t *pktio_entry, int index ODP_UNUSED, pkt_hdr->input = pktio_entry->s.handle; if (pktio_cls_enabled(pktio_entry)) - copy_packet_parser_metadata(&parsed_hdr, pkt_hdr); + copy_packet_cls_metadata(&parsed_hdr, pkt_hdr); else packet_parse_l2(pkt_hdr); diff --git a/platform/linux-generic/pktio/netmap.c b/platform/linux-generic/pktio/netmap.c index 4ea0d4a..d189aae 100644 --- a/platform/linux-generic/pktio/netmap.c +++ b/platform/linux-generic/pktio/netmap.c @@ -628,7 +628,7 @@ static inline int netmap_pkt_to_odp(pktio_entry_t *pktio_entry, pkt_hdr->input = pktio_entry->s.handle; if (pktio_cls_enabled(pktio_entry)) - copy_packet_parser_metadata(&parsed_hdr, pkt_hdr); + copy_packet_cls_metadata(&parsed_hdr, pkt_hdr); else packet_parse_l2(pkt_hdr); diff --git a/platform/linux-generic/pktio/socket.c b/platform/linux-generic/pktio/socket.c index e07b6ad..b116145 100644 --- a/platform/linux-generic/pktio/socket.c +++ b/platform/linux-generic/pktio/socket.c @@ -678,7 +678,7 @@ static int sock_mmsg_recv(pktio_entry_t *pktio_entry, int index ODP_UNUSED, continue; } pkt_hdr->input = pktio_entry->s.handle; - copy_packet_parser_metadata(&parsed_hdr, pkt_hdr); + copy_packet_cls_metadata(&parsed_hdr, pkt_hdr); packet_set_ts(pkt_hdr, ts); pkt_table[nb_rx++] = pkt; diff --git a/platform/linux-generic/pktio/socket_mmap.c b/platform/linux-generic/pktio/socket_mmap.c index 720004c..30c44e9 100644 --- a/platform/linux-generic/pktio/socket_mmap.c +++ b/platform/linux-generic/pktio/socket_mmap.c @@ -224,7 +224,7 @@ static inline unsigned pkt_mmap_v2_rx(pktio_entry_t *pktio_entry, hdr->input = pktio_entry->s.handle; if (pktio_cls_enabled(pktio_entry)) - copy_packet_parser_metadata(&parsed_hdr, hdr); + copy_packet_cls_metadata(&parsed_hdr, hdr); else packet_parse_l2(hdr);