From patchwork Sat Jan 20 21:11:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ophir Munk X-Patchwork-Id: 34164 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id CCFB61B04C; Sat, 20 Jan 2018 22:12:05 +0100 (CET) Received: from EUR03-DB5-obe.outbound.protection.outlook.com (mail-eopbgr40076.outbound.protection.outlook.com [40.107.4.76]) by dpdk.org (Postfix) with ESMTP id AE76DA48C for ; Sat, 20 Jan 2018 22:11:56 +0100 (CET) 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; bh=tHQfl/8DBTh05b5Vgr7N5Gy7ZRb/25UEIxMWJuZaT7Q=; b=WCTduMyUAGB4W7055rPpvzRkfaTNzRBe/2SVaeLvxtx12+cQR2AxPlPb5TswCIhybBt+0CPjHQYwmgClrJ25x+bnQKQ8wPhaVnsCoJ9sYaHK9XaEZNVkr9peprHbLjeHrFQlFe4gjqxsVJoYRrS3kbZDIYFguwyIgb13ukyVxaQ= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=ophirmu@mellanox.com; Received: from mellanox.com (37.142.13.130) by AM0PR0502MB3875.eurprd05.prod.outlook.com (2603:10a6:208:20::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.407.7; Sat, 20 Jan 2018 21:11:54 +0000 From: Ophir Munk To: dev@dpdk.org, Pascal Mazon Cc: Thomas Monjalon , Olga Shern , Ophir Munk Date: Sat, 20 Jan 2018 21:11:37 +0000 Message-Id: <1516482697-8348-7-git-send-email-ophirmu@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1516482697-8348-1-git-send-email-ophirmu@mellanox.com> References: <1516282691-29698-1-git-send-email-ophirmu@mellanox.com> <1516482697-8348-1-git-send-email-ophirmu@mellanox.com> MIME-Version: 1.0 X-Originating-IP: [37.142.13.130] X-ClientProxiedBy: VI1PR08CA0212.eurprd08.prod.outlook.com (2603:10a6:802:15::21) To AM0PR0502MB3875.eurprd05.prod.outlook.com (2603:10a6:208:20::17) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 92b0f4fd-840f-4cad-cfc4-08d5604a6f5a X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(2017052603307)(7153060)(7193020); SRVR:AM0PR0502MB3875; X-Microsoft-Exchange-Diagnostics: 1; AM0PR0502MB3875; 3:HH5vhCvWt0esTTIDsiJmDR2hwEzBmkQlDOT00Kxb4oXUGJ/KXJL2F88vWHIgq6viX2tIaTfbQTPd3brPVMggGqmFIAT0JEmBu0qzsnlmlxCj0ZcT+NFtpXA1x3crNP5N/9lh+iiYGgYK2vq/b+ehufwbNE2F8QFQUZBcRgpUbj3xJHd9i3UdxZiAifZMp1tT2K+UblCHMPtflpln6uHfklF5QGoaLMC5oZPrLgbVp/unF9uqipgCV39nIaKysvYY; 25:EvS0+k+84u7PkCWQRVdk6gUPNqfgas46IUoNBUCUBkKe1TBOK0AcAb7OQ51wPPgTYYe5JLjpr3SWelzkjQO2S+VZXZ50Oc6MERcytzdudfUHGhf9qTiJEyRyTxfho1RKKmCGN+gBUUvz4Bg4bZChIn4hOHU+Rm9C442ntLElNxKkeh1PwSTKMtRCZc/Bk1FspTbrHcx4RY6CN+O8s8zQc68V5B9SI6DWlMmtumGGkX6yZhQzP3SuTiR8F2XIrAiSD25hjBl7nB15hdgyfUoYk+OFzJ2bSOBnqdejwKpPdGcOMQf91LFuT7+qeLXr7fLNdalqETPD7FIqft9P2etiGw==; 31:yYuPqw+RRwoc6d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bqEHXSZU8qkeOeZcpq1LX62d1scaPnBnTeJZHnPApSH7WEKPP3AifA== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040501)(2401047)(8121501046)(5005006)(3231023)(2400081)(944501161)(93006095)(93001095)(10201501046)(3002001)(6055026)(6041288)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123564045)(20161123558120)(20161123562045)(6072148)(201708071742011); SRVR:AM0PR0502MB3875; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:AM0PR0502MB3875; X-Forefront-PRVS: 0558D3C5AC X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(39860400002)(366004)(396003)(346002)(39380400002)(376002)(189003)(199004)(25786009)(4326008)(478600001)(7696005)(66066001)(47776003)(107886003)(76176011)(52116002)(51416003)(97736004)(2906002)(21086003)(26005)(316002)(54906003)(86362001)(16586007)(16526018)(8676002)(81166006)(81156014)(59450400001)(5660300001)(50226002)(3846002)(36756003)(69596002)(7736002)(305945005)(386003)(6116002)(6666003)(105586002)(6916009)(4720700003)(50466002)(53936002)(33026002)(68736007)(2950100002)(106356001)(8936002)(48376002)(55016002)(21314002); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR0502MB3875; H:mellanox.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; AM0PR0502MB3875; 23:FfchUs5Np+XjryXL96KUEWkVzgiLGc8wfA6uq1C?= dEV0XG8wFYPjZMucIFGG5u0LGGrd/snxKwSI51YwPGQQE5kKjiz85hmmITbVk53bPjypx/vbxK3yA0Jqyu6UbYCjTKgAQt01X8aemj5bpe8CzumT/eMgpC9QmWBxYt3UynEfcF5FZZ4M88OZ7RB7ZwHWnA3VyHQn7hR1m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agnostics: 1; AM0PR0502MB3875; 6:70xM2nTjzW1hlDTKTju5QPRopHmobevge8iUBMbMqJjlrxwf3q2uyVxt7z9GbuDYTebrMXjZ+y5qFgr9IssOCEg4RJkuKdz9Onu36KFSl7HWUnakG/JFdBCrWgwtmbBytA4jFGtuAz1dvm1+4aRyZctkjfa6R1tfKUr4cWccq/Xf/ApdeKcm9gB2QITPhreyAiU2G8NGDPUpc6iPCiXNdWshuPSxPFKKzGNQSJDMCZ8iiW0Tor8iLnJv29/j1y3xrg6dJltk4YN165n7eTx5itP3IQ+/SkXGEmEKDKIAjd/Fe7dvQXMs3BSl5o15JFC1vUw9IodoVLLQJE7SEhmUIbK1lajfjvfKDP4QBV5pFbc=; 5:JfWEMWUD0dN9mES8T8PIU55BGJcO5KwO8bXoY2bhguzVkn677vTtQIXj5FILxqBXlTyJX/hcxPJ35hZM0N9vqpaO74beMuNmpZ+hxTOFLp8yMx+w7vyehTULKx4yYlPRE87m1RELp436eD30v0Zlb1PDIku3d9yrhMMDsoWfIaQ=; 24:RODbJZoP+Edrt1sBy6oPBFnjYBT2cnu86iwfZ6pqLUN9LmTlJoyxBChiKP92TttEL6Yfj7g4tmKY62HnMT22kWstbHZG2LHx1DRP31H5VYI=; 7:hxFNdsdDEXCpP5SFdKgikhxwDh+gAkYe9lv29Y0sr06NruV5t31++iFSkguu3Lh+cslOjagSVY/po8aM35aFZlj3F6Ii+UrDFd6F9WGZL0aXnxBokZnm5rnYLiLUAEZS0wQ9H+2C7cr2Au1lFuB0K8j//tcZKyVtiVLNYSbNoGwMkfIjSgJnhYCWmQCaKK9K+VagD9a3eCU+nCmAwoCwbCxVdvXc1uD0r8llVX/xi/ph73ivo8nPLhYu6XTfQxNH SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jan 2018 21:11:54.5486 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 92b0f4fd-840f-4cad-cfc4-08d5604a6f5a X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR0502MB3875 Subject: [dpdk-dev] [PATCH v6 6/6] doc: detail new tap RSS feature in guides 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Signed-off-by: Ophir Munk Acked-by: Pascal Mazon --- doc/guides/nics/tap.rst | 60 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/doc/guides/nics/tap.rst b/doc/guides/nics/tap.rst index 04086b1..dc6f834 100644 --- a/doc/guides/nics/tap.rst +++ b/doc/guides/nics/tap.rst @@ -132,6 +132,7 @@ Supported actions: - DROP - QUEUE - PASSTHRU +- RSS It is generally not possible to provide a "last" item. However, if the "last" item, once masked, is identical to the masked spec, then it is supported. @@ -161,6 +162,11 @@ Drop UDP packets in vlan 3:: testpmd> flow create 0 priority 3 ingress pattern eth / vlan vid is 3 / \ ipv4 proto is 17 / end actions drop / end +Distribute IPv4 TCP packets using RSS to a given MAC address over queues 0-3:: + + testpmd> flow create 0 priority 4 ingress pattern eth dst is 0a:0b:0c:0d:0e:0f \ + / ipv4 / tcp / end actions rss queues 0 1 2 3 end / end + Example ------- @@ -213,3 +219,57 @@ traffic is being looped back. You can use ``set all size XXX`` to change the size of the packets after you stop the traffic. Use pktgen ``help`` command to see a list of all commands. You can also use the ``-f`` option to load commands at startup in command line or Lua script in pktgen. + +RSS specifics +------------- +Packet distribution in TAP is done by the kernel which has a default +distribution. This feature is adding RSS distribution based on eBPF code. +The default eBPF code calculates RSS hash based on Toeplitz algorithm for +a fixed RSS key. It is calculated on fixed packet offsets. For IPv4 and IPv6 it +is calculated over src/dst addresses (8 or 32 bytes for IPv4 or IPv6 +respectively) and src/dst TCP/UDP ports (4 bytes). + +The RSS algorithm is written in file ``tap_bpf_program.c`` which +does not take part in TAP PMD compilation. Instead this file is compiled +in advance to eBPF object file. The eBPF object file is then parsed and +translated into eBPF byte code in the format of C arrays of eBPF +instructions. The C array of eBPF instructions is part of TAP PMD tree and +is taking part in TAP PMD compilation. At run time the C arrays are uploaded to +the kernel via BPF system calls and the RSS hash is calculated by the +kernel. + +It is possible to support different RSS hash algorithms by updating file +``tap_bpf_program.c`` In order to add a new RSS hash algorithm follow these +steps: + +1. Write the new RSS implementation in file ``tap_bpf_program.c`` + +BPF programs which are uploaded to the kernel correspond to +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:: + + clang -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 +name, and prints out the section as a C array of eBPF instructions. +Embed the C array in your TAP PMD tree. + +The C arrays are uploaded to the kernel using BPF system calls. + +``tc`` (traffic control) is a well known user space utility program used to +configure the Linux kernel packet scheduler. It is usually packaged as +part of the ``iproute2`` package. +Since commit 11c39b5e9 ("tc: add eBPF support to f_bpf") ``tc`` can be used +to uploads eBPF code to the kernel and can be patched in order to print the +C arrays of eBPF instructions just before calling the BPF system call. +Please refer to ``iproute2`` package file ``lib/bpf.c`` function +``bpf_prog_load()``. + +An example utility for eBPF instruction generation in the format of C arrays will +be added in next releases +