From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on0074.outbound.protection.outlook.com [104.47.1.74]) by dpdk.org (Postfix) with ESMTP id D40871E401 for ; Mon, 11 Jun 2018 18:06:24 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zZLlMsIukYN6SPFw83ELZScwvOIEtjDYmnESXVkEd80=; b=u8OiGFee+J6IBilC8f0Oq5XGslmNoa3rr6Pt2n0nzo03MEcZoHlkvhvT6nnCJL/VItONsxZcjeq15IQbEQKSWusxO29JY+kEWKpvuANF5ggI/WHI2kzNpbbTDV7iDq48hqYGI2iBMneeDuKeK0KXaXAE1PirhO5qRBeT1xaNTpE= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=ophirmu@mellanox.com; Received: from mellanox.com (37.142.13.130) by VI1PR0501MB2318.eurprd05.prod.outlook.com (2603:10a6:800:2c::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.841.14; Mon, 11 Jun 2018 16:06:22 +0000 From: Ophir Munk To: dev@dpdk.org, Pascal Mazon , Keith Wiles Cc: Thomas Monjalon , Olga Shern , Ophir Munk Date: Mon, 11 Jun 2018 16:06:12 +0000 Message-Id: <1528733172-24747-1-git-send-email-ophirmu@mellanox.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [37.142.13.130] X-ClientProxiedBy: VI1PR08CA0120.eurprd08.prod.outlook.com (2603:10a6:800:d4::22) To VI1PR0501MB2318.eurprd05.prod.outlook.com (2603:10a6:800:2c::19) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(5600026)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:VI1PR0501MB2318; X-Microsoft-Exchange-Diagnostics: 1; VI1PR0501MB2318; 3:zeMfM9diu5XkAbP3mzEdg9vAHv4XpGx4aFKR6XiYpabLTMSLEuGlSF0E2oi0nEVTajPnCkY/fF8xhp11HAIxh7iTelRJQcPjpM36IPeBJxpNvRKm5RW7A3vwNjKsZE4NbqBWJG9woDNyTNAOSL6H0Foc2I3rCfu1O/44qPQk3Y7///nQuHHbMyvFABdWg3ZiT3TPE24wjrLwgi2fm2z1DzNdTHsgFXYeQ/xflXrl/GzmJ8UZr873uNw/Id9UykSf; 25:lviqnxdqPte7LyIYrSg2LL93bGem7DC72i1/mPV1B8UfP4yWqEf+ZBHxSoyuDcQwHkAfUKoBch2d9ufQYST0JRwmxk94iPcvOYduPEk4X4aCKEzK23nUX6RF41OKBauJWZ0XkjPFjyopFT+LIkjT2l2PDpi8mRuvaDUKJLQv019WPQ1iBJIDaMhhkKnSpuh8Nbl1Dc73vSb/WnTylL6jnRetUdR0+hRB9D++S9pspSGy8WSkcGViPoO1PTsE/y9lSC0JOkspnNMlIS7kmorl37th6nocvJLxvYfK4eOqnSzCYG+mIXEX8ASALhugkWTjXbHoWXa1B9zQYK+SmHYNbw==; 31:xSwW89AkZnTxW64CskvGQjdjF4eJkcsE6B+MeyY7CIP3WuyaS6UfyH7SK8LJrFxmVmoWCLv6YAIbf2Dw3SVFml5lRcJUptqn2A88wOTNAl8TcDBwovIZvADL28mjeoNrbTdCwGVMfsaGwkb39Ec5NPQA4RfT5yDNbf3eCvSTVARF2jFsYttOMczavrX3KeZsBcehg6wLLKCMdwqBzkoV6+p2BTwRoPEtoVSDDzKjMJw= X-MS-TrafficTypeDiagnostic: VI1PR0501MB2318: X-LD-Processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr X-Microsoft-Exchange-Diagnostics: 1; VI1PR0501MB2318; 20:r3k8zZIUXU9oXczJgSxxJvtWTo6gNrsprgYq0tWptpyJd+RKPL72J+oGglcmmtomh1AqsmQ5PrrHa5pK5dVVEXZxM8XJp8qW/2FTuH+twXrsFOpha6NEmJb/ahdHBFrY5iAHufnYXnzcjKVAcCgGR1N37VI8S9m4c/KMuaoR1RXQ109Rd4J0vw+AHUeZa/hW7mn6CiBratN1wkK1S/vRaEdJQXOHM2Wt54kSx0CrM9GDCITUFL15iVeSpwi+RKj1y/HIH77VzNhC/aMYNhJwkMy7occvuDDSA1YpWDD2aYNRHgpD3OksAOlfV+cJghNF9qLdTLaqcrwOFSwXHEOZY7Z5RpZ41QC1xoLpXA8k0C0D3N3fMt44E/KcxQ0NhEtmfYQ93apUHch3NtOnzLrUAU6OfoaAvA/UKVumimcOYguSsWZuafoKuRS9PFhHpUZ0t+240SDrPVxdx5VWVQVKsVZiQ9MwaoCVSi2w4mGgNcNZvw/DPaPWgOVeFHDdwyP3; 4:XrwVheRoxFvvmPnFAhazndsogVBREEgfXEiRlhcZabCiNtqRa6sg7Wn3zHbWXLf+VIoeUtfxMpzHyR+g/4kcx9JT42A9nwlMrRZFMEapBI8Ba1aAIHf8b1weJQsNPvy3koDQYhxjh7W0DQyD7dLh5REJDX7C2fuev0P7EVJFMAT/LWAkpTccBbF43V8uL2xX9EW5Umf95wjqluyByYMUFKFkqUDRnFsfaYLIL7a0ykVliy3uWSONCl7xrNDsvKjHcmKN0769mkEq29Le+0FbSCqZoBCpLPm2kBQtDj8YaXPAZ+E4mwkXBOKPCJOsJEKT X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(84791874153150); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3002001)(3231254)(944501410)(52105095)(93006095)(93001095)(10201501046)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(6072148)(201708071742011)(7699016); SRVR:VI1PR0501MB2318; BCL:0; PCL:0; RULEID:; SRVR:VI1PR0501MB2318; X-Forefront-PRVS: 070092A9D3 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(376002)(39380400002)(346002)(396003)(366004)(39860400002)(174874002)(199004)(189003)(50226002)(8936002)(16586007)(50466002)(956004)(2616005)(476003)(8676002)(81156014)(81166006)(66066001)(486006)(305945005)(7736002)(47776003)(110136005)(54906003)(5660300001)(52116002)(2906002)(7696005)(106356001)(6116002)(3846002)(105586002)(68736007)(51416003)(966005)(6306002)(26005)(86362001)(97736004)(186003)(55016002)(316002)(4326008)(478600001)(48376002)(69596002)(4720700003)(53936002)(25786009)(107886003)(16526019)(33026002)(6666003)(21086003)(386003)(36756003); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0501MB2318; H:mellanox.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR0501MB2318; 23:AFPwvaq1XFZoYWoHTwisW/fQWoIpqztHx4BXOUS?= =?us-ascii?Q?OHHDmZ3UQFiVCeltngNVfml9kGrm6yKZ7Oho5cnHfmkNdJLM5LPdoWsB4O0d?= =?us-ascii?Q?URA+dofIzTY57HgWPbiiUfc+nxOJOZ9d5sT0wYg7qnn1/Yb7OvNOJ81RmEgT?= =?us-ascii?Q?DQBLkUiQoWPXAOuMDychTySBM6c7ZNtlEKexQE5J/sBs52ZJQMB9+EYzz+IW?= =?us-ascii?Q?1OOuW5yPW+yxwidgcr/NdugDvbLVNBZXu147yo748yC0wIgBPP5yKAlRE5FP?= =?us-ascii?Q?Ve+QcgvCSMVAWahGxRQjXDpmOFjHG52htQZnXylqVRau0luULyb7d/OTnDlm?= =?us-ascii?Q?G/g/ZxMEfhPMzG27+sJ0nvBce6mkWyfb8pGJmZfkOvwdO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idY= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; VI1PR0501MB2318; 7:dAZGOVONfeI8Kpopt20ODV2vc7Ofc+VSwDcmj40ElEESjdkD5dBrmZt2cXSscf5HsJ/n7IS0vtkITQ9wpq2sj6tQQtZqj3moZqWKRKk9oiucgZiNS+AMmSe9UdXc8CVzjDH7gBKbR+Dz2kb8sX62pZjNewd0+X4jYP0hcHwJjixwER+ANdxYGCAGKhiiDSEdQgijeVtp3qvv05PbDIPPsp1j8YBJEIcYUgpThDD5lA7sYtZrrhP/3oZwpKuKNNSh X-MS-Office365-Filtering-Correlation-Id: 261d51cb-7cc1-41a9-2817-08d5cfb5476a X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jun 2018 16:06:22.8614 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 261d51cb-7cc1-41a9-2817-08d5cfb5476a X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0501MB2318 Subject: [dpdk-dev] [PATCH v1] net/tap: explain how to compile eBPF C file 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: Mon, 11 Jun 2018 16:06:25 -0000 This commit explains how to manually compile the C source file tap_bpf_program.c into an ELF file using the clang compiler. The code in tap_bpf_program.c requires definitions found in iproute2 source code. This commit suggests cloning the iproute2 git tree and include its path in the clang command. It also adds inclusion of file bpf_api.h (required for eBPF definitions) which is located in iproute2 source tree. For more details refer to TAP documentation. This commit is related to commits [1] and [2]. [1] commit cdc07e83bb24 ("net/tap: add eBPF program file") [2] commit aabe70df73a3 ("net/tap: add eBPF bytes code") Signed-off-by: Ophir Munk --- doc/guides/nics/tap.rst | 21 +++++++++++++++++---- drivers/net/tap/tap_bpf_program.c | 5 +++++ 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/doc/guides/nics/tap.rst b/doc/guides/nics/tap.rst index 2714868..af6c534 100644 --- a/doc/guides/nics/tap.rst +++ b/doc/guides/nics/tap.rst @@ -234,13 +234,26 @@ C functions under different ELF sections. 2. Install ``LLVM`` library and ``clang`` compiler versions 3.7 and above -3. Compile ``tap_bpf_program.c`` via ``LLVM`` into an object file:: +3. The code in ``tap_bpf_program.c`` requires definitions found in iproute2 +source code. - clang -O2 -emit-llvm -c tap_bpf_program.c -o - | llc -march=bpf \ - -filetype=obj -o +Clone the iproute2 git tree and make it accessible to the build environment, say +under directory ```` :: + + git clone https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/ \ + + +The code in ``tap_bpf_program.c`` must include file ``bpf_api.h`` which is +located under ```` directory. This file contains eBPF +related definitions. +4. Compile ``tap_bpf_program.c`` via ``LLVM`` into an object file:: + + clang -I /iproute2/include \ + -O2 -emit-llvm -c tap_bpf_program.c -o - | llc -march=bpf \ + -filetype=obj -o -4. Use a tool that receives two parameters: an eBPF object file and a section +5. Use a tool that receives two parameters: an eBPF object file and a section name, and prints out the section as a C array of eBPF instructions. Embed the C array in your TAP PMD tree. diff --git a/drivers/net/tap/tap_bpf_program.c b/drivers/net/tap/tap_bpf_program.c index 1cb7382..60b069b 100644 --- a/drivers/net/tap/tap_bpf_program.c +++ b/drivers/net/tap/tap_bpf_program.c @@ -17,6 +17,11 @@ #include #include "tap_rss.h" +/* + * bpf_api.h file is located under iproute2 + * tree, see TAP documentation. + */ +#include "bpf_api.h" /** Create IPv4 address */ #define IPv4(a, b, c, d) ((__u32)(((a) & 0xff) << 24) | \ -- 1.8.3.1