From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-BY2-obe.outbound.protection.outlook.com (mail-by2nam01on0043.outbound.protection.outlook.com [104.47.34.43]) by dpdk.org (Postfix) with ESMTP id 76760726F for ; Tue, 13 Mar 2018 15:02:05 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=hk+T9LxkqFVOS/Wn9O3d9Mhlx+0yliWaMu77WDjQGz0=; b=Dg541JvyRG6z1E6sX5Ey/woVHIoffbn92j59qkE0y9jrcgpWkzxgCcNydyg26inFfR13uwpd8o6KgK1NcvIgFMpoAWMJlWVsiVg6tAion8KQb8wHD370xJ0VK5WE2Dn9PLLjDy0RdwU73nl8PjlIEOeVwxF0wRcwcaCEhpw20KE= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Jerin.JacobKollanukkaran@cavium.com; Received: from jerin (111.93.218.67) by CY1PR07MB2523.namprd07.prod.outlook.com (2a01:111:e400:c636::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.567.18; Tue, 13 Mar 2018 14:02:02 +0000 Date: Tue, 13 Mar 2018 19:31:56 +0530 From: Jerin Jacob To: Konstantin Ananyev Cc: dev@dpdk.org Message-ID: <20180313140155.GC564@jerin> References: <1520472602-1483-1-git-send-email-konstantin.ananyev@intel.com> <1520472602-1483-6-git-send-email-konstantin.ananyev@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1520472602-1483-6-git-send-email-konstantin.ananyev@intel.com> User-Agent: Mutt/1.9.4 (2018-02-28) X-Originating-IP: [111.93.218.67] X-ClientProxiedBy: SN2PR01CA0025.prod.exchangelabs.com (2603:10b6:804:2::35) To CY1PR07MB2523.namprd07.prod.outlook.com (2a01:111:e400:c636::14) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: de09b796-959b-4169-6fc9-08d588eaffc0 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4604075)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:CY1PR07MB2523; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2523; 3:NBwTQWqOwqWzzRpO6f96PzkSUqdD03+WFBCAO+ObFPzPpkQrEEDtc7PZ7pBc+JNGl4OxOkggKnxvfmmFAY2X9GKAQnKMkSQVHrrw/uDsJ+nK0Kk1sA/RepWLEKA9Lf9AlWwXfFGBD4bfOLnTeiLVq344v0UMNMI/TRi5F0lgAy6STQuNLqd+rxzloR3hz6diyz+JsMogt8mbuszsSII8Rqb8RPfpKNhCsFyzCvtdOgp2eNkfx7ot0mN10YkamhVv; 25:KIFMBv2tq/fkb34ErzC8+/QnTWsFEXyS14aBwfaYwxQMt3FTIyeTU3ktnJl61louwpLW60WCY5zrRUB5emlHmHo8WzJ4TwyNqol1PMATNB2zKXG1qX44bScGFcUhEBU6FpUzyIpOAMo8+GFrwccey0iPNaets0iJxDRmngkOrxzhSf5F2QZgHRFjZic8HsLTc+1xscmi5sT00ttknrFNj3+hKF39BwtI3rbhsc0SV1XDDl7XcwuizHmdqEpyOfCSeF0y2bVUiRCWPAwKMSPsUlqTMCbicQGdy7Km+LJ+6kppl4K9Pm87K33oWsYrcP7iM5OGrxi+jqz/AGMeZkrINg==; 31:QEFyVBx8uVJnA6OFtDbxBE9fuZM6tAxKia3XCIRHJ2j8SmtcWkoLWQabkr7irO7/toGO9LJVkirqrbJIYOSyYkVL1UR283LFHUtpnNfFKudOggW2M7LUVjamno/9UWNNNlYnFSh74BMO2ekeM7nKOnCe4rUgcllozilOpBwPNM9FpFkMjq1l2+NIAxCRaypsOiGDTk+G66zaM02AskNkY8oDlqf6Z4Hi8H/2u0ZihMw= X-MS-TrafficTypeDiagnostic: CY1PR07MB2523: X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2523; 20:ST14NtpcpxmcE6oDPzg+StRShyHI9nqMoAfUjXBRgEPTVjZA7FFGogn0OFt+mz9HY3AdfMFKpfc0VW5hmiBmuKoiU/Cto2ZOt5cAzqem8+jtqongdq+xVCUfz65rB4JgRu8H8d2fjNntY8fv1vz7D3zbCMCWcxNIQ+5yhzbbdpgXrCsYfC4vO8OXTxD1vTq1wez4DvWNDYr76TFiMR0QW5W+KGMFUjr4fc/aSPyRA47az+I8Yv859Ys+UljNdUrQbXwxaqsU4kCXGec2dvzuKDgXO6SUr8QrKP8KyliLVzsBQ6c6vn95AdrUOeKlpW+5Op/IN7xifzQ1g04p014CDl2g7HKklBYT1MTEH19WaLjuaZ5kd/UAl15XDWq1kFrLIjBvxlhW1Vkg1dTQ9oI0/yRhsmvvXRd6D1Zei1U5Q2GijgirYxAb5x62pTULq//Aof255Z9iXs6ZNdvVcetqeCaMlwb0TZTkd8A6hIvWqamaffT0HVU6Q5y8Cq8iMGzeSqtI9Ub03o+kOchIi8+bpN1VTpRHGicluMZ5hQiyorgmsCcFzXBjqBEYKgu6Hm7sm6ibNiNVBA6i5IwIDmTk50MedFbtpnTZsTsvasYI1t4=; 4:HzrdDvvkoCqQDxVIyYQ6W0lt5m5oD818A4QSoxFc0GXVIOfkcQdzVFgnMRf/PebXacxWEKgkpV7zowngvC1H1atHNxnKhHKiytPXjN0F4HM1UiVJtfXIS8RGhaiX8e4jHBw8zNGtHfOAwGJ6Pn2qo89PtPB6OmXw4GGv+9JHmfIxj6BXdjwdbQFCcdreOlHt5oXUYalf0i2iB5IpMeeC/fKAeJsBd7YMY1SUqRB0/Ur8AH18KlqyJ5JfV5cC3voMjvY9dCpA/GBACyWmUWCP32cBIRX8Z1My0s4qjm4h9LEclFSlh9fXkM/ujsUTQYSj X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(228905959029699); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3002001)(10201501046)(93006095)(3231221)(944501244)(52105095)(6041310)(20161123558120)(20161123560045)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:CY1PR07MB2523; BCL:0; PCL:0; RULEID:; SRVR:CY1PR07MB2523; X-Forefront-PRVS: 0610D16BBE X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(346002)(376002)(366004)(39860400002)(396003)(39380400002)(189003)(199004)(13464003)(81166006)(50466002)(7736002)(106356001)(66066001)(229853002)(2906002)(33656002)(23726003)(3846002)(6116002)(25786009)(4326008)(1076002)(5009440100003)(478600001)(72206003)(26005)(2950100002)(305945005)(5660300001)(6666003)(186003)(16526019)(58126008)(6916009)(386003)(81156014)(33716001)(8936002)(42882007)(316002)(16586007)(8676002)(68736007)(55016002)(97736004)(53936002)(9686003)(76176011)(33896004)(6496006)(52116002)(47776003)(105586002)(6246003)(18370500001)(217873001); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR07MB2523; H:jerin; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR07MB2523; 23:RtvH6OS8TyBq/MlOxGS2mrcwrZrNlLhih/WUVeWwY?= =?us-ascii?Q?bfoUyZCyDZtplt4dln2lNuHR1a2KA9zlr2fnPf55TWGPzSNy16/P7boIm4bL?= =?us-ascii?Q?anPN5xF7XclZcSL6epLyHgFLrCS3lcbHZIQZrQEePnQnCcGn4Fic9hiyralh?= =?us-ascii?Q?oISaJQUaMwuafhCZCy4YQUjNTmOFumD9S74jzqr4xU2bWRUHQ1OzMTNpVax1?= =?us-ascii?Q?S7JU07I3iBGAyugROgOz6J5fzyZSmSVvGDiXS2mTfUE+Ew12h1T3NsSN+4MK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UuTZT1knXG4QY9IyQF+Y43r6nj6xLpCYFjHX2GJnHlYsHeE=; 7:RZ7AXPaCh4kRYje++qamR38Fp9FO39qiQ7GhRzfo6Mh6Op1gMeUB3AfF46zq/a7nEafptiOzMhwGlaCxp6nYWJmldLUpsjJM3IagswMK2njUWA6gOkNPqPfFeVd2nSqT2A4cdRFbksUIufk2qlcJ21rJpMZ81rPyB9Wep2m542qO3iHz5V++ayo3/ZnkJvC/CWsWGbMPoIrfWudhP4O9jqtQ3VX4f99//hfBKSfF7rAlRVIHPXiKUDZ/MywAfog0 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Mar 2018 14:02:02.4663 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: de09b796-959b-4169-6fc9-08d588eaffc0 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR07MB2523 Subject: Re: [dpdk-dev] [RFC PATCH 5/5] test: add few eBPF samples X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Mar 2018 14:02:06 -0000 -----Original Message----- > Date: Thu, 8 Mar 2018 01:30:02 +0000 > From: Konstantin Ananyev > To: dev@dpdk.org > CC: Konstantin Ananyev > Subject: [dpdk-dev] [RFC PATCH 5/5] test: add few eBPF samples > X-Mailer: git-send-email 1.7.0.7 > > Add few simple eBPF programs as an example. > > Signed-off-by: Konstantin Ananyev > diff --git a/test/bpf/mbuf.h b/test/bpf/mbuf.h > new file mode 100644 > index 000000000..aeef6339d > --- /dev/null > +++ b/test/bpf/mbuf.h > @@ -0,0 +1,556 @@ > +/* SPDX-License-Identifier: BSD-3-Clause > + * Copyright(c) 2010-2014 Intel Corporation. > + * Copyright 2014 6WIND S.A. > + */ > + > +/* > + * Snipper from dpdk.org rte_mbuf.h. > + * used to provide BPF programs information about rte_mbuf layout. > + */ > + > +#ifndef _MBUF_H_ > +#define _MBUF_H_ > + > +#include > +#include > +#include Is it worth to keep an copy of mbuf for standalone purpose? Since clang is already supported, I think, if someone need mbuf then they can include DPDK headers. Just thinking in maintainability perspective. > diff --git a/test/bpf/t1.c b/test/bpf/t1.c > new file mode 100644 > index 000000000..e587d5e5b > --- /dev/null > +++ b/test/bpf/t1.c > @@ -0,0 +1,54 @@ > +/* SPDX-License-Identifier: BSD-3-Clause > + * Copyright(c) 2018 Intel Corporation > + */ > + > +/* > + * eBPF program sample. > + * Accepts pointer to first segment packet data as an input parameter. > + * analog of tcpdump -s 1 -d 'dst 1.2.3.4 && udp && dst port 5000' > + * (000) ldh [12] > + * (001) jeq #0x800 jt 2 jf 12 > + * (002) ld [30] > + * (003) jeq #0x1020304 jt 4 jf 12 > + * (004) ldb [23] > + * (005) jeq #0x11 jt 6 jf 12 > + * (006) ldh [20] > + * (007) jset #0x1fff jt 12 jf 8 > + * (008) ldxb 4*([14]&0xf) > + * (009) ldh [x + 16] > + * (010) jeq #0x1388 jt 11 jf 12 > + * (011) ret #1 > + * (012) ret #0 > + * > + * To compile: > + * clang -O2 -DRTE_CACHE_LINE_SIZE=64 -I${RTE_SDK}/${RTE_TARGET}/include \ Does not look like, this application is accessing any DPDK stuff, If so, Should we remove -DRTE_CACHE_LINE_SIZE=64 -I${RTE_SDK}/${RTE_TARGET}/include? > + * -target bpf -c t1.c > + */ > + > +#include > +#include > +#include > +#include > + > +uint64_t > +entry(void *pkt) > +{ > + struct ether_header *ether_header = (void *)pkt; > + > + if (ether_header->ether_type != __builtin_bswap16(0x0800)) > + return 0; > + > + struct iphdr *iphdr = (void *)(ether_header + 1); > + if (iphdr->protocol != 17 || (iphdr->frag_off & 0x1ffff) != 0 || > + iphdr->daddr != __builtin_bswap32(0x1020304)) > + return 0; > + > + int hlen = iphdr->ihl * 4; > + struct udphdr *udphdr = (void *)iphdr + hlen; > + > + if (udphdr->dest != __builtin_bswap16(5000)) > + return 0; > + > + return 1; > +} > + > diff --git a/test/bpf/t2.c b/test/bpf/t2.c > new file mode 100644 > index 000000000..6228609c5 > --- /dev/null > +++ b/test/bpf/t2.c > @@ -0,0 +1,31 @@ > +/* SPDX-License-Identifier: BSD-3-Clause > + * Copyright(c) 2018 Intel Corporation > + */ > + > +/* > + * eBPF program sample. > + * Accepts pointer to struct rte_mbuf as an input parameter. > + * cleanup mbuf's vlan_tci and all related RX flags > + * (PKT_RX_VLAN_PKT | PKT_RX_VLAN_STRIPPED). > + * Doesn't touch contents of packet data. > + * To compile: > + * clang -O2 -DRTE_CACHE_LINE_SIZE=... -I${RTE_SDK}/${RTE_TARGET}/include \ > + * -target bpf -Wno-int-to-void-pointer-cast -c t2.c > + */ > + > +#include > +#include > +#include "mbuf.h" Can we take Cache line size from rte_config.h which anyway included in mbuf.h through rte_memory.h? > + > +uint64_t > +entry(void *pkt) > +{ > + struct rte_mbuf *mb; > + > + mb = pkt; > + mb->vlan_tci = 0; > + mb->ol_flags &= ~(PKT_RX_VLAN_PKT | PKT_RX_VLAN_STRIPPED); > + > + return 1; > +} > + > -- > 2.13.6 >